[gnome-builder] buildsystem: allow specifying a type hint to load build system



commit 54af0d0b2775918b92f677e12c711ca0400fbeb3
Author: Christian Hergert <chergert redhat com>
Date:   Mon Mar 13 15:15:08 2017 -0700

    buildsystem: allow specifying a type hint to load build system
    
    If we have an idea of what build system should be used, we can provide that
    during creation so that we sort the build systems in an order that prefers
    the hint'd build system.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780006

 libide/buildsystem/ide-build-system.c |   15 ++++++++++++++-
 libide/buildsystem/ide-build-system.h |    1 +
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-system.c b/libide/buildsystem/ide-build-system.c
index 615ed4b..dffaeec 100644
--- a/libide/buildsystem/ide-build-system.c
+++ b/libide/buildsystem/ide-build-system.c
@@ -133,6 +133,17 @@ sort_priority (gconstpointer a,
 {
   IdeBuildSystem **as = (IdeBuildSystem **)a;
   IdeBuildSystem **bs = (IdeBuildSystem **)b;
+  g_autofree gchar *id_a = ide_build_system_get_id (*as);
+  g_autofree gchar *id_b = ide_build_system_get_id (*bs);
+  const gchar *build_system_hint = data;
+
+  if (build_system_hint != NULL)
+    {
+      if (g_strcmp0 (build_system_hint, id_a) == 0)
+        return -1;
+      else if (g_strcmp0 (build_system_hint, id_b) == 0)
+        return 1;
+    }
 
   return ide_build_system_get_priority (*as) - ide_build_system_get_priority (*bs);
 }
@@ -141,6 +152,7 @@ sort_priority (gconstpointer a,
  * ide_build_system_new_async:
  * @context: #IdeBuildSystem
  * @project_file: A #GFile containing the directory or project file.
+ * @build_system_hint: A hint for the build system to use
  * @cancellable: (allow-none): A #GCancellable
  * @callback: A callback to execute upon completion
  * @user_data: User data for @callback.
@@ -155,6 +167,7 @@ sort_priority (gconstpointer a,
 void
 ide_build_system_new_async (IdeContext          *context,
                             GFile               *project_file,
+                            const gchar         *build_system_hint,
                             GCancellable        *cancellable,
                             GAsyncReadyCallback  callback,
                             gpointer             user_data)
@@ -164,7 +177,7 @@ ide_build_system_new_async (IdeContext          *context,
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
   ide_object_new_for_extension_async (IDE_TYPE_BUILD_SYSTEM,
-                                      sort_priority, NULL,
+                                      sort_priority, (gpointer)build_system_hint,
                                       G_PRIORITY_DEFAULT,
                                       cancellable,
                                       callback,
diff --git a/libide/buildsystem/ide-build-system.h b/libide/buildsystem/ide-build-system.h
index f5d00ec..4f1f29a 100644
--- a/libide/buildsystem/ide-build-system.h
+++ b/libide/buildsystem/ide-build-system.h
@@ -57,6 +57,7 @@ struct _IdeBuildSystemInterface
 gchar          *ide_build_system_get_id                   (IdeBuildSystem       *self);
 void            ide_build_system_new_async                (IdeContext           *context,
                                                            GFile                *project_file,
+                                                           const gchar          *build_system_hint,
                                                            GCancellable         *cancellable,
                                                            GAsyncReadyCallback   callback,
                                                            gpointer              user_data);


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