[gnome-builder] builder: push force-rebuild flag down to each builder



commit a89f682030125769dc60d7355ef21a878055c2a9
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Apr 11 15:04:42 2015 +0200

    builder: push force-rebuild flag down to each builder
    
    Pass a flags argument to the build async method and let each
    concrete builder handle it

 libide/autotools/ide-autotools-builder.c |    4 ++++
 libide/ide-builder.c                     |    3 ++-
 libide/ide-builder.h                     |    8 ++++++++
 src/workbench/gb-workbench.c             |    7 +------
 tools/ide-build.c                        |    5 +++--
 5 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/libide/autotools/ide-autotools-builder.c b/libide/autotools/ide-autotools-builder.c
index d7b7437..236a431 100644
--- a/libide/autotools/ide-autotools-builder.c
+++ b/libide/autotools/ide-autotools-builder.c
@@ -197,6 +197,7 @@ ide_autotools_builder_get_build_directory (IdeAutotoolsBuilder *self)
 
 static void
 ide_autotools_builder_build_async (IdeBuilder           *builder,
+                                   IdeBuilderBuildFlags  flags,
                                    IdeBuildResult      **result,
                                    GCancellable         *cancellable,
                                    GAsyncReadyCallback   callback,
@@ -215,6 +216,9 @@ ide_autotools_builder_build_async (IdeBuilder           *builder,
 
   priv = ide_autotools_builder_get_instance_private (self);
 
+  if (flags & IDE_BUILDER_BUILD_FLAGS_FORCE_REBUILD)
+    g_key_file_set_boolean (priv->config, "autotools", "rebuild", TRUE);
+
   task = g_task_new (self, cancellable, callback, user_data);
 
   context = ide_object_get_context (IDE_OBJECT (builder));
diff --git a/libide/ide-builder.c b/libide/ide-builder.c
index fe8d3dc..17c2e0e 100644
--- a/libide/ide-builder.c
+++ b/libide/ide-builder.c
@@ -37,6 +37,7 @@ enum {
 
 void
 ide_builder_build_async (IdeBuilder           *builder,
+                         IdeBuilderBuildFlags  flags,
                          IdeBuildResult      **result,
                          GCancellable         *cancellable,
                          GAsyncReadyCallback   callback,
@@ -54,7 +55,7 @@ ide_builder_build_async (IdeBuilder           *builder,
 
   if (klass->build_async)
     {
-      klass->build_async (builder, result, cancellable, callback, user_data);
+      klass->build_async (builder, flags, result, cancellable, callback, user_data);
       return;
     }
 
diff --git a/libide/ide-builder.h b/libide/ide-builder.h
index 4080c69..132a4a5 100644
--- a/libide/ide-builder.h
+++ b/libide/ide-builder.h
@@ -27,11 +27,18 @@ G_BEGIN_DECLS
 
 G_DECLARE_DERIVABLE_TYPE (IdeBuilder, ide_builder, IDE, BUILDER, IdeObject)
 
+typedef enum
+{
+  IDE_BUILDER_BUILD_FLAGS_NONE          = 0,
+  IDE_BUILDER_BUILD_FLAGS_FORCE_REBUILD = 1 << 0
+} IdeBuilderBuildFlags;
+
 struct _IdeBuilderClass
 {
   GObjectClass parent;
 
   void            (*build_async)  (IdeBuilder           *builder,
+                                   IdeBuilderBuildFlags  flags,
                                    IdeBuildResult      **result,
                                    GCancellable         *cancellable,
                                    GAsyncReadyCallback   callback,
@@ -42,6 +49,7 @@ struct _IdeBuilderClass
 };
 
 void            ide_builder_build_async  (IdeBuilder           *builder,
+                                          IdeBuilderBuildFlags  flags,
                                           IdeBuildResult      **result,
                                           GCancellable         *cancellable,
                                           GAsyncReadyCallback   callback,
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index fc86ff3..be1db7d 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -802,12 +802,6 @@ gb_workbench_build_async (GbWorkbench         *self,
 
   config = g_key_file_new ();
 
-  if (force_rebuild)
-    {
-      /* TODO: we should make this type of operation build system agnostic. */
-      g_key_file_set_boolean (config, "autotools", "rebuild", TRUE);
-    }
-
   builder = ide_build_system_get_builder (build_system, config, device, &error);
 
   if (builder == NULL)
@@ -831,6 +825,7 @@ gb_workbench_build_async (GbWorkbench         *self,
   g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_BUILDING]);
 
   ide_builder_build_async (builder,
+                           force_rebuild ? IDE_BUILDER_BUILD_FLAGS_FORCE_REBUILD : 0,
                            NULL, /* &IdeProgress */
                            cancellable,
                            gb_workbench__builder_build_cb,
diff --git a/tools/ide-build.c b/tools/ide-build.c
index 1bd7761..cc1bc4d 100644
--- a/tools/ide-build.c
+++ b/tools/ide-build.c
@@ -212,6 +212,7 @@ build_for_device (IdeContext *context,
   g_autoptr(IdeBuildResult) build_result = NULL;
   g_autoptr(GError) error = NULL;
   IdeBuildSystem *build_system;
+  IdeBuilderBuildFlags flags = IDE_BUILDER_BUILD_FLAGS_NONE;
   GKeyFile *config;
 
   print_build_info (context, device);
@@ -219,7 +220,7 @@ build_for_device (IdeContext *context,
   config = g_key_file_new ();
 
   if (gRebuild)
-    g_key_file_set_boolean (config, "autotools", "rebuild", TRUE);
+    flags |= IDE_BUILDER_BUILD_FLAGS_FORCE_REBUILD;
 
   if (gParallel)
     g_key_file_set_integer (config, "parallel", "workers", gParallel);
@@ -237,7 +238,7 @@ build_for_device (IdeContext *context,
 
   gBuildStart = g_get_monotonic_time ();
 
-  ide_builder_build_async (builder, &build_result, NULL, build_cb, NULL);
+  ide_builder_build_async (builder, flags, &build_result, NULL, build_cb, NULL);
 
   if (build_result)
     {


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