[gnome-builder] autotools: bail when non autotools file is selected



commit 84c648ac927b0541291a7b0426721e82d5b8fcff
Author: Christian Hergert <chergert redhat com>
Date:   Sat Dec 16 15:24:05 2017 -0800

    autotools: bail when non autotools file is selected
    
    Previously, this looked at the parent directory for a
    configure.{ac,in} and would key off of that. This fails when
    meson.build is selected when autotools is also supported.
    
    Instead, we only guess those files if a directory was provided.

 src/plugins/autotools/ide-autotools-build-system.c |   21 +++++++++++++------
 1 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/autotools/ide-autotools-build-system.c 
b/src/plugins/autotools/ide-autotools-build-system.c
index 7bb8801..49963a7 100644
--- a/src/plugins/autotools/ide-autotools-build-system.c
+++ b/src/plugins/autotools/ide-autotools-build-system.c
@@ -84,7 +84,6 @@ ide_autotools_build_system_discover_file_worker (GTask        *task,
                                                  gpointer      task_data,
                                                  GCancellable *cancellable)
 {
-  g_autoptr(GFile) parent = NULL;
   g_autoptr(GFile) configure_ac = NULL;
   g_autoptr(GFile) configure_in = NULL;
   GFile *file = task_data;
@@ -108,19 +107,27 @@ ide_autotools_build_system_discover_file_worker (GTask        *task,
       IDE_EXIT;
     }
 
-  if (g_file_query_file_type (file, 0, cancellable) == G_FILE_TYPE_DIRECTORY)
-    parent = g_object_ref (file);
-  else
-    parent = g_file_get_parent (file);
+  /*
+   * So this file is not the configure file, if it's not a directory,
+   * we'll ignore this request and assume this isn't an autotools project.
+   */
+  if (g_file_query_file_type (file, 0, cancellable) != G_FILE_TYPE_DIRECTORY)
+    {
+      g_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_NOT_FOUND,
+                               "Failed to locate configure.ac");
+      IDE_EXIT;
+    }
 
-  configure_ac = g_file_get_child (parent, "configure.ac");
+  configure_ac = g_file_get_child (file, "configure.ac");
   if (g_file_query_exists (configure_ac, cancellable))
     {
       g_task_return_pointer (task, g_steal_pointer (&configure_ac), g_object_unref);
       IDE_EXIT;
     }
 
-  configure_in = g_file_get_child (parent, "configure.in");
+  configure_in = g_file_get_child (file, "configure.in");
   if (g_file_query_exists (configure_in, cancellable))
     {
       g_task_return_pointer (task, g_steal_pointer (&configure_in), g_object_unref);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]