[gnome-builder] runtime: add API to get system include dirs



commit c5c5dada50c7113209d0d071fb8bde335c83d9ec
Author: Christian Hergert <chergert redhat com>
Date:   Sat Nov 25 00:45:17 2017 -0800

    runtime: add API to get system include dirs
    
    Various runtimes might have system include dirs that are different
    from the system defaults. They should use paths that can be translated
    later on using translate_file().

 src/libide/runtimes/ide-runtime.c         |   25 +++++++++++++++++++++++++
 src/libide/runtimes/ide-runtime.h         |   25 ++++++++++++++-----------
 src/plugins/flatpak/gbp-flatpak-runtime.c |    8 ++++++++
 3 files changed, 47 insertions(+), 11 deletions(-)
---
diff --git a/src/libide/runtimes/ide-runtime.c b/src/libide/runtimes/ide-runtime.c
index 41f20de..53ae27f 100644
--- a/src/libide/runtimes/ide-runtime.c
+++ b/src/libide/runtimes/ide-runtime.c
@@ -516,3 +516,28 @@ ide_runtime_translate_file (IdeRuntime *self,
 
   return ret;
 }
+
+/**
+ * ide_runtime_get_system_include_dirs:
+ * @self: a #IdeRuntime
+ *
+ * Gets the system include dirs for the runtime. Usually, this is just
+ * "/usr/include", but more complex runtimes may include additional.
+ *
+ * Returns: (transfer full) (array zero-terminated=1): A newly allocated
+ *   string containing the include dirs.
+ *
+ * Since: 3.28
+ */
+gchar **
+ide_runtime_get_system_include_dirs (IdeRuntime *self)
+{
+  static const gchar *basic[] = { "/usr/include", NULL };
+
+  g_return_val_if_fail (IDE_IS_RUNTIME (self), NULL);
+
+  if (IDE_RUNTIME_GET_CLASS (self)->get_system_include_dirs)
+    return IDE_RUNTIME_GET_CLASS (self)->get_system_include_dirs (self);
+
+  return g_strdupv ((gchar **)basic);
+}
diff --git a/src/libide/runtimes/ide-runtime.h b/src/libide/runtimes/ide-runtime.h
index 530d824..5d7813e 100644
--- a/src/libide/runtimes/ide-runtime.h
+++ b/src/libide/runtimes/ide-runtime.h
@@ -44,17 +44,18 @@ struct _IdeRuntimeClass
 {
   IdeObjectClass parent;
 
-  gboolean               (*contains_program_in_path) (IdeRuntime           *self,
-                                                      const gchar          *program,
-                                                      GCancellable         *cancellable);
-  IdeSubprocessLauncher *(*create_launcher)          (IdeRuntime           *self,
-                                                      GError              **error);
-  void                   (*prepare_configuration)    (IdeRuntime           *self,
-                                                      IdeConfiguration     *configuration);
-  IdeRunner             *(*create_runner)            (IdeRuntime           *self,
-                                                      IdeBuildTarget       *build_target);
-  GFile                 *(*translate_file)           (IdeRuntime           *self,
-                                                      GFile                *file);
+  gboolean                (*contains_program_in_path) (IdeRuntime           *self,
+                                                       const gchar          *program,
+                                                       GCancellable         *cancellable);
+  IdeSubprocessLauncher  *(*create_launcher)          (IdeRuntime           *self,
+                                                       GError              **error);
+  void                    (*prepare_configuration)    (IdeRuntime           *self,
+                                                       IdeConfiguration     *configuration);
+  IdeRunner              *(*create_runner)            (IdeRuntime           *self,
+                                                       IdeBuildTarget       *build_target);
+  GFile                  *(*translate_file)           (IdeRuntime           *self,
+                                                       GFile                *file);
+  gchar                 **(*get_system_include_dirs)  (IdeRuntime           *self);
 
   gpointer _reserved4;
   gpointer _reserved5;
@@ -103,5 +104,7 @@ void                   ide_runtime_set_display_name         (IdeRuntime
 IDE_AVAILABLE_IN_ALL
 GFile                 *ide_runtime_translate_file           (IdeRuntime           *self,
                                                              GFile                *file);
+IDE_AVAILABLE_IN_3_28
+gchar                **ide_runtime_get_system_include_dirs  (IdeRuntime           *self);
 
 G_END_DECLS
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime.c b/src/plugins/flatpak/gbp-flatpak-runtime.c
index c2221d0..4ad6bbf 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime.c
+++ b/src/plugins/flatpak/gbp-flatpak-runtime.c
@@ -546,6 +546,13 @@ gbp_flatpak_runtime_set_sdk (GbpFlatpakRuntime *self,
     }
 }
 
+static gchar **
+gbp_flatpak_runtime_get_system_include_dirs (IdeRuntime *runtime)
+{
+  static const gchar *include_dirs[] = { "/app/include", "/usr/include", NULL };
+  return g_strdupv ((gchar **)include_dirs);
+}
+
 static void
 gbp_flatpak_runtime_get_property (GObject    *object,
                                   guint       prop_id,
@@ -647,6 +654,7 @@ gbp_flatpak_runtime_class_init (GbpFlatpakRuntimeClass *klass)
   runtime_class->contains_program_in_path = gbp_flatpak_runtime_contains_program_in_path;
   runtime_class->prepare_configuration = gbp_flatpak_runtime_prepare_configuration;
   runtime_class->translate_file = gbp_flatpak_runtime_translate_file;
+  runtime_class->get_system_include_dirs = gbp_flatpak_runtime_get_system_include_dirs;
 
   properties [PROP_ARCH] =
     g_param_spec_string ("arch",


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