[gnome-builder/wip/libide] libide: add ide_build_system_get_build_flags_async()



commit a3c1cd63b22aa783ef043b9cd5f9210929081cc5
Author: Christian Hergert <christian hergert me>
Date:   Fri Feb 27 18:50:35 2015 -0800

    libide: add ide_build_system_get_build_flags_async()
    
    This function will return the flags necessary for building a file. It
    will be highly build system specific, so I expect we'll go through a
    couple of iterations here.
    
    In the short term, this is going to be how we plumb CFLAGS from automake
    to be used by the diagnostics engine.

 libide/ide-build-system.c |   50 +++++++++++++++++++++++++++++++++++++++++++++
 libide/ide-build-system.h |   49 ++++++++++++++++++++++++++++---------------
 2 files changed, 82 insertions(+), 17 deletions(-)
---
diff --git a/libide/ide-build-system.c b/libide/ide-build-system.c
index 706ba3d..ef70def 100644
--- a/libide/ide-build-system.c
+++ b/libide/ide-build-system.c
@@ -21,6 +21,7 @@
 #include "ide-build-system.h"
 #include "ide-context.h"
 #include "ide-device.h"
+#include "ide-file.h"
 
 typedef struct
 {
@@ -37,6 +38,55 @@ enum {
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 
+/**
+ * ide_build_system_get_build_flags_async:
+ *
+ * Asynchronously requests the build flags for a file. For autotools and C based projects, this
+ * would be similar to the $CFLAGS variable and is suitable for generating warnings and errors
+ * with clang.
+ */
+void
+ide_build_system_get_build_flags_async (IdeBuildSystem      *self,
+                                        IdeFile             *file,
+                                        GCancellable        *cancellable,
+                                        GAsyncReadyCallback  callback,
+                                        gpointer             user_data)
+{
+  g_autoptr(GTask) task = NULL;
+
+  g_return_if_fail (IDE_IS_BUILD_SYSTEM (self));
+  g_return_if_fail (IDE_IS_FILE (file));
+  g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  if (IDE_BUILD_SYSTEM_GET_CLASS (self)->get_build_flags_async)
+    return IDE_BUILD_SYSTEM_GET_CLASS (self)->get_build_flags_async (self, file, cancellable,
+                                                                     callback, user_data);
+
+  task = g_task_new (self, cancellable, callback, user_data);
+  g_task_return_pointer (task, NULL, NULL);
+}
+
+/**
+ * ide_build_system_get_build_flags_finish:
+ *
+ * Completes an asynchronous request to get the build flags for a file.
+ *
+ * Returns: (transfer none): An array of strings containing the build flags, or %NULL upon failure
+ *   and @error is set.
+ */
+gchar **
+ide_build_system_get_build_flags_finish (IdeBuildSystem  *self,
+                                         GAsyncResult    *result,
+                                         GError         **error)
+{
+  g_return_val_if_fail (IDE_IS_BUILD_SYSTEM (self), NULL);
+
+  if (IDE_BUILD_SYSTEM_GET_CLASS (self)->get_build_flags_finish)
+    return IDE_BUILD_SYSTEM_GET_CLASS (self)->get_build_flags_finish (self, result, error);
+
+  return g_new0 (gchar*, 1);
+}
+
 GFile *
 ide_build_system_get_project_file (IdeBuildSystem *system)
 {
diff --git a/libide/ide-build-system.h b/libide/ide-build-system.h
index d9de9d8..6b9ee58 100644
--- a/libide/ide-build-system.h
+++ b/libide/ide-build-system.h
@@ -28,30 +28,45 @@ G_BEGIN_DECLS
 #define IDE_TYPE_BUILD_SYSTEM            (ide_build_system_get_type())
 #define IDE_BUILD_SYSTEM_EXTENSION_POINT "org.gnome.libide.extensions.build-system"
 
-G_DECLARE_DERIVABLE_TYPE (IdeBuildSystem, ide_build_system,
-                          IDE, BUILD_SYSTEM, IdeObject)
+G_DECLARE_DERIVABLE_TYPE (IdeBuildSystem, ide_build_system, IDE, BUILD_SYSTEM, IdeObject)
 
 struct _IdeBuildSystemClass
 {
   IdeObjectClass parent;
 
-  IdeBuilder *(*get_builder) (IdeBuildSystem  *system,
-                              GKeyFile        *config,
-                              IdeDevice       *device,
-                              GError         **error);
+  IdeBuilder *(*get_builder)            (IdeBuildSystem       *system,
+                                         GKeyFile             *config,
+                                         IdeDevice            *device,
+                                         GError              **error);
+  void        (*get_build_flags_async)  (IdeBuildSystem       *self,
+                                         IdeFile              *file,
+                                         GCancellable         *cancellable,
+                                         GAsyncReadyCallback   callback,
+                                         gpointer              user_data);
+  gchar     **(*get_build_flags_finish) (IdeBuildSystem       *self,
+                                         GAsyncResult         *result,
+                                         GError              **error);
 };
 
-void            ide_build_system_new_async   (IdeContext           *context,
-                                              GFile                *project_file,
-                                              GCancellable         *cancellable,
-                                              GAsyncReadyCallback   callback,
-                                              gpointer              user_data);
-IdeBuildSystem *ide_build_system_new_finish  (GAsyncResult         *result,
-                                              GError              **error);
-IdeBuilder     *ide_build_system_get_builder (IdeBuildSystem       *system,
-                                              GKeyFile             *config,
-                                              IdeDevice            *device,
-                                              GError              **error);
+void            ide_build_system_get_build_flags_async  (IdeBuildSystem       *self,
+                                                         IdeFile              *file,
+                                                         GCancellable         *cancellable,
+                                                         GAsyncReadyCallback   callback,
+                                                         gpointer              user_data);
+gchar         **ide_build_system_get_build_flags_finish (IdeBuildSystem       *self,
+                                                         GAsyncResult         *result,
+                                                         GError              **error);
+void            ide_build_system_new_async              (IdeContext           *context,
+                                                         GFile                *project_file,
+                                                         GCancellable         *cancellable,
+                                                         GAsyncReadyCallback   callback,
+                                                         gpointer              user_data);
+IdeBuildSystem *ide_build_system_new_finish             (GAsyncResult         *result,
+                                                         GError              **error);
+IdeBuilder     *ide_build_system_get_builder            (IdeBuildSystem       *system,
+                                                         GKeyFile             *config,
+                                                         IdeDevice            *device,
+                                                         GError              **error);
 
 G_END_DECLS
 


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