[gnome-builder] autotools: check for AC_INIT() in configure
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] autotools: check for AC_INIT() in configure
- Date: Thu, 11 Jan 2018 06:03:09 +0000 (UTC)
commit 9951e22501b2763bf20e06b2010f5b89deaeb988
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 10 22:02:32 2018 -0800
autotools: check for AC_INIT() in configure
If we come across a file that looks like it might be autotools, first
check to see if it has AC_INIT() defined in the file. That way we aren't
fooled by wrapper scripts and dummy files.
https://bugzilla.gnome.org/show_bug.cgi?id=791293
src/plugins/autotools/ide-autotools-build-system.c | 29 ++++++++++++++-----
1 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/autotools/ide-autotools-build-system.c
b/src/plugins/autotools/ide-autotools-build-system.c
index 49963a7..71cc78b 100644
--- a/src/plugins/autotools/ide-autotools-build-system.c
+++ b/src/plugins/autotools/ide-autotools-build-system.c
@@ -23,6 +23,7 @@
#include <gio/gio.h>
#include <gtksourceview/gtksource.h>
#include <ide.h>
+#include <string.h>
#include "ide-autotools-build-system.h"
#include "ide-autotools-makecache-stage.h"
@@ -65,17 +66,29 @@ ide_autotools_build_system_get_tarball_name (IdeAutotoolsBuildSystem *self)
static gboolean
is_configure (GFile *file)
{
- gchar *name;
- gboolean ret;
+ g_autofree gchar *name = NULL;
g_assert (G_IS_FILE (file));
name = g_file_get_basename (file);
- ret = ((0 == g_strcmp0 (name, "configure.ac")) ||
- (0 == g_strcmp0 (name, "configure.in")));
- g_free (name);
+ return dzl_str_equal0 (name, "configure.ac") ||
+ dzl_str_equal0 (name, "configure.in");
+}
- return ret;
+static gboolean
+check_for_ac_init (GFile *file,
+ GCancellable *cancellable)
+{
+ g_autofree gchar *contents = NULL;
+ gsize len = 0;
+
+ g_assert (G_IS_FILE (file));
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ if (g_file_load_contents (file, cancellable, &contents, &len, NULL, NULL))
+ return strstr (contents, "AC_INIT") != NULL;
+
+ return FALSE;
}
static void
@@ -121,14 +134,14 @@ ide_autotools_build_system_discover_file_worker (GTask *task,
}
configure_ac = g_file_get_child (file, "configure.ac");
- if (g_file_query_exists (configure_ac, cancellable))
+ if (check_for_ac_init (configure_ac, cancellable))
{
g_task_return_pointer (task, g_steal_pointer (&configure_ac), g_object_unref);
IDE_EXIT;
}
configure_in = g_file_get_child (file, "configure.in");
- if (g_file_query_exists (configure_in, cancellable))
+ if (check_for_ac_init (configure_in, cancellable))
{
g_task_return_pointer (task, g_steal_pointer (&configure_in), g_object_unref);
IDE_EXIT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]