[gnome-builder] autotools: Make the Run button work when builddir != srcdir
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] autotools: Make the Run button work when builddir != srcdir
- Date: Wed, 3 Aug 2016 19:28:12 +0000 (UTC)
commit 095985e0d05932ec93b6f1c065527a77727380f8
Author: Matthew Leeds <mleeds redhat com>
Date: Wed Aug 3 13:43:24 2016 -0400
autotools: Make the Run button work when builddir != srcdir
To make the Run button work, Builder looks in a project's directory for
a Makefile, which doesn't work when the build directory differs from the
source code directory, such as when you're building in ~/.cache/.... This
commit makes Builder look for Makefiles in the build directory, as determined
by an IdeAutotoolsBuilder instance. It should be okay not to check for
Makefile.am files since this code is only used for autotools projects.
https://bugzilla.gnome.org/show_bug.cgi?id=769482
plugins/autotools/ide-autotools-build-system.c | 19 +++++++++++++
plugins/autotools/ide-makecache.c | 33 ++++++++---------------
plugins/autotools/ide-makecache.h | 1 +
3 files changed, 32 insertions(+), 21 deletions(-)
---
diff --git a/plugins/autotools/ide-autotools-build-system.c b/plugins/autotools/ide-autotools-build-system.c
index 9eb1807..55dd9d7 100644
--- a/plugins/autotools/ide-autotools-build-system.c
+++ b/plugins/autotools/ide-autotools-build-system.c
@@ -576,6 +576,11 @@ ide_autotools_build_system_get_build_targets_cb (GObject *object,
gpointer user_data)
{
IdeAutotoolsBuildSystem *self = (IdeAutotoolsBuildSystem *)object;
+ IdeContext *context;
+ IdeVcs *vcs;
+ g_autoptr(IdeConfiguration) configuration = NULL;
+ g_autoptr(IdeBuilder) builder = NULL;
+ g_autoptr(GFile) build_dir = NULL;
g_autoptr(IdeMakecache) makecache = NULL;
g_autoptr(GTask) task = user_data;
GError *error = NULL;
@@ -591,7 +596,21 @@ ide_autotools_build_system_get_build_targets_cb (GObject *object,
return;
}
+ context = ide_object_get_context (IDE_OBJECT (self));
+ configuration = ide_configuration_new (context, "autotools-bootstrap", "local", "host");
+ builder = ide_autotools_build_system_get_builder (IDE_BUILD_SYSTEM (self), configuration, &error);
+ if (builder)
+ {
+ build_dir = ide_autotools_builder_get_build_directory (IDE_AUTOTOOLS_BUILDER (builder));
+ }
+ else
+ {
+ vcs = ide_context_get_vcs (context);
+ build_dir = ide_vcs_get_working_directory (vcs);
+ }
+
ide_makecache_get_build_targets_async (makecache,
+ build_dir,
g_task_get_cancellable (task),
ide_autotools_build_system_get_build_targets_cb2,
g_object_ref (task));
diff --git a/plugins/autotools/ide-makecache.c b/plugins/autotools/ide-makecache.c
index 01a7c60..f06c9a9 100644
--- a/plugins/autotools/ide-makecache.c
+++ b/plugins/autotools/ide-makecache.c
@@ -1742,7 +1742,6 @@ _find_make_directories (IdeMakecache *self,
g_autoptr(GFileEnumerator) enumerator = NULL;
g_autoptr(GPtrArray) dirs = NULL;
gboolean has_makefile = FALSE;
- gboolean has_makefile_am = FALSE;
GError *local_error = NULL;
gpointer infoptr;
guint i;
@@ -1772,8 +1771,6 @@ _find_make_directories (IdeMakecache *self,
if (g_strcmp0 (name, "Makefile") == 0)
has_makefile = TRUE;
- if (g_strcmp0 (name, "Makefile.am") == 0)
- has_makefile_am = TRUE;
else if (type == G_FILE_TYPE_DIRECTORY)
g_ptr_array_add (dirs, g_file_get_child (dir, name));
}
@@ -1784,7 +1781,7 @@ _find_make_directories (IdeMakecache *self,
return FALSE;
}
- if (has_makefile && has_makefile_am)
+ if (has_makefile)
g_ptr_array_add (ret, g_object_ref (dir));
if (!g_file_enumerator_close (enumerator, cancellable, error))
@@ -1803,23 +1800,19 @@ _find_make_directories (IdeMakecache *self,
static GPtrArray *
find_make_directories (IdeMakecache *self,
- GFile *root,
+ GFile *build_dir,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GPtrArray) ret = NULL;
g_assert (IDE_IS_MAKECACHE (self));
- g_assert (G_IS_FILE (root));
+ g_assert (G_IS_FILE (build_dir));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
- /*
- * TODO: Make this work for builddir != srcdir.
- */
-
ret = g_ptr_array_new_with_free_func (g_object_unref);
- if (!_find_make_directories (self, root, ret, cancellable, error))
+ if (!_find_make_directories (self, build_dir, ret, cancellable, error))
return NULL;
if (ret->len == 0)
@@ -1864,8 +1857,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
const gchar *make_name = "make";
IdeContext *context;
IdeRuntime *runtime;
- IdeVcs *vcs;
- GFile *workdir;
+ GFile *build_dir = task_data;
GError *error = NULL;
gchar *line;
gsize line_len;
@@ -1891,8 +1883,6 @@ ide_makecache_get_build_targets_worker (GTask *task,
configmgr = ide_context_get_configuration_manager (context);
config = ide_configuration_manager_get_current (configmgr);
runtime = ide_configuration_get_runtime (config);
- vcs = ide_context_get_vcs (context);
- workdir = ide_vcs_get_working_directory (vcs);
if (runtime != NULL)
launcher = ide_runtime_create_launcher (runtime, NULL);
@@ -1900,7 +1890,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
if (launcher == NULL)
{
g_autofree gchar *path = NULL;
- path = g_file_get_path (workdir);
+ path = g_file_get_path (build_dir);
launcher = ide_subprocess_launcher_new (0);
ide_subprocess_launcher_set_cwd (launcher, path);
@@ -1934,7 +1924,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
* directories that we know there is a standalone Makefile within.
*/
- makedirs = find_make_directories (self, workdir, cancellable, &error);
+ makedirs = find_make_directories (self, build_dir, cancellable, &error);
if (makedirs == NULL)
{
@@ -1944,9 +1934,8 @@ ide_makecache_get_build_targets_worker (GTask *task,
/*
* We need to extract various programs/libraries/targets from each of
- * our make directories containing a Makefile.am (translated into a Makefile
- * so that we can know what targets are available. With that knowledge, we
- * can build our targets list and cache it for later.
+ * our make directories containing an automake-generated Makefile. With
+ * that knowledge, we can build our targets list and cache it for later.
*/
targets = g_ptr_array_new_with_free_func (g_object_unref);
@@ -1960,7 +1949,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
/*
* Make sure we are running within the directory containing the
- * Makefile.am that we care about.
+ * Makefile that we care about.
*/
makedir = g_ptr_array_index (makedirs, j);
path = g_file_get_path (makedir);
@@ -2048,6 +2037,7 @@ failure:
void
ide_makecache_get_build_targets_async (IdeMakecache *self,
+ GFile *build_dir,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -2060,6 +2050,7 @@ ide_makecache_get_build_targets_async (IdeMakecache *self,
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_task_data (task, g_object_ref (build_dir), g_object_unref);
g_task_set_source_tag (task, ide_makecache_get_build_targets_async);
g_task_set_check_cancellable (task, FALSE);
diff --git a/plugins/autotools/ide-makecache.h b/plugins/autotools/ide-makecache.h
index 9fba3c2..1cbe65e 100644
--- a/plugins/autotools/ide-makecache.h
+++ b/plugins/autotools/ide-makecache.h
@@ -54,6 +54,7 @@ GPtrArray *ide_makecache_get_file_targets_finish (IdeMakecache
GAsyncResult *result,
GError **error);
void ide_makecache_get_build_targets_async (IdeMakecache *self,
+ GFile *build_dir,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]