[gnome-builder] flatpak: Add support for "simple" buildsystem



commit 5c63571dcaf612995f2423e595a762baa539a08f
Author: Matthew Leeds <mleeds redhat com>
Date:   Wed Mar 29 16:06:18 2017 -0500

    flatpak: Add support for "simple" buildsystem
    
    This commit adds support for flatpak's "simple" buildsystem, which just
    runs the build commands in the manifest. The commands are loaded in the
    IdeBuildPipeline initalization so they are available for any buildsystem
    (and could conceivably be used with a non-flatpak config). Then the
    "directory" build system is used since nothing more needs to be done
    beyond running those commands.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780674

 libide/buildsystem/ide-build-pipeline.c            |   85 ++++++++++++++++
 .../flatpak/gbp-flatpak-build-system-discovery.c   |    6 +-
 plugins/flatpak/gbp-flatpak-pipeline-addin.c       |  104 --------------------
 3 files changed, 86 insertions(+), 109 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-pipeline.c b/libide/buildsystem/ide-build-pipeline.c
index ada391f..b6b7290 100644
--- a/libide/buildsystem/ide-build-pipeline.c
+++ b/libide/buildsystem/ide-build-pipeline.c
@@ -771,6 +771,88 @@ ide_build_pipeline_extension_removed (PeasExtensionSet *set,
   IDE_EXIT;
 }
 
+static void
+register_build_commands_stage (IdeBuildPipeline *self,
+                               IdeContext       *context)
+{
+  g_autoptr(GError) error = NULL;
+  const gchar * const *build_commands;
+
+  g_assert (IDE_IS_BUILD_PIPELINE (self));
+  g_assert (IDE_IS_CONTEXT (context));
+  g_assert (IDE_IS_CONFIGURATION (self->configuration));
+
+  build_commands = ide_configuration_get_build_commands (self->configuration);
+  if (build_commands == NULL)
+    return;
+  for (guint i = 0; build_commands[i]; i++)
+    {
+      g_autoptr(IdeSubprocessLauncher) launcher = NULL;
+      g_autoptr(IdeBuildStage) stage = NULL;
+
+      if (NULL == (launcher = ide_build_pipeline_create_launcher (self, &error)))
+        {
+          g_warning ("%s", error->message);
+          return;
+        }
+
+      ide_subprocess_launcher_push_argv (launcher, "/bin/sh");
+      ide_subprocess_launcher_push_argv (launcher, "-c");
+      ide_subprocess_launcher_push_argv (launcher, build_commands[i]);
+
+      stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
+                            "context", context,
+                            "launcher", launcher,
+                            NULL);
+
+      ide_build_pipeline_connect (self,
+                                  IDE_BUILD_PHASE_BUILD | IDE_BUILD_PHASE_AFTER,
+                                  i,
+                                  stage);
+    }
+}
+
+static void
+register_post_install_commands_stage (IdeBuildPipeline *self,
+                                      IdeContext       *context)
+{
+  g_autoptr(GError) error = NULL;
+  const gchar * const *post_install_commands;
+
+  g_assert (IDE_IS_BUILD_PIPELINE (self));
+  g_assert (IDE_IS_CONTEXT (context));
+  g_assert (IDE_IS_CONFIGURATION (self->configuration));
+
+  post_install_commands = ide_configuration_get_post_install_commands (self->configuration);
+  if (post_install_commands == NULL)
+    return;
+  for (guint i = 0; post_install_commands[i]; i++)
+    {
+      g_autoptr(IdeSubprocessLauncher) launcher = NULL;
+      g_autoptr(IdeBuildStage) stage = NULL;
+
+      if (NULL == (launcher = ide_build_pipeline_create_launcher (self, &error)))
+        {
+          g_warning ("%s", error->message);
+          return;
+        }
+
+      ide_subprocess_launcher_push_argv (launcher, "/bin/sh");
+      ide_subprocess_launcher_push_argv (launcher, "-c");
+      ide_subprocess_launcher_push_argv (launcher, post_install_commands[i]);
+
+      stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
+                            "context", context,
+                            "launcher", launcher,
+                            NULL);
+
+      ide_build_pipeline_connect (self,
+                                  IDE_BUILD_PHASE_INSTALL | IDE_BUILD_PHASE_AFTER,
+                                  i,
+                                  stage);
+    }
+}
+
 /**
  * ide_build_pipeline_load:
  *
@@ -792,6 +874,9 @@ ide_build_pipeline_load (IdeBuildPipeline *self)
 
   context = ide_object_get_context (IDE_OBJECT (self));
 
+  register_build_commands_stage (self, context);
+  register_post_install_commands_stage (self, context);
+
   self->addins = ide_extension_set_new (peas_engine_get_default (),
                                         IDE_TYPE_BUILD_PIPELINE_ADDIN,
                                         "context", context,
diff --git a/plugins/flatpak/gbp-flatpak-build-system-discovery.c 
b/plugins/flatpak/gbp-flatpak-build-system-discovery.c
index f7ac007..42be1b9 100644
--- a/plugins/flatpak/gbp-flatpak-build-system-discovery.c
+++ b/plugins/flatpak/gbp-flatpak-build-system-discovery.c
@@ -166,12 +166,8 @@ gbp_flatpak_build_system_discovery_discover (IdeBuildSystemDiscovery  *discovery
 
           if (ide_str_equal0 (buildsystem, "cmake-ninja"))
             buildsystem = "cmake";
-
-          /* TODO: We could maybe support this if we properly extract the
-           *       build-commands property from the manifest.
-           */
           else if (ide_str_equal0 (buildsystem, "simple"))
-            IDE_RETURN (NULL);
+            buildsystem = "directory";
 
           ret = g_strdup (buildsystem);
           IDE_TRACE_MSG ("Discovered buildsystem of type \"%s\"", ret);
diff --git a/plugins/flatpak/gbp-flatpak-pipeline-addin.c b/plugins/flatpak/gbp-flatpak-pipeline-addin.c
index c69fe86..958fd03 100644
--- a/plugins/flatpak/gbp-flatpak-pipeline-addin.c
+++ b/plugins/flatpak/gbp-flatpak-pipeline-addin.c
@@ -352,108 +352,6 @@ register_dependencies_stage (GbpFlatpakPipelineAddin  *self,
 }
 
 static gboolean
-register_build_commands_stage (GbpFlatpakPipelineAddin  *self,
-                               IdeBuildPipeline         *pipeline,
-                               IdeContext               *context,
-                               GError                  **error)
-{
-  g_autoptr(IdeSubprocessLauncher) launcher = NULL;
-  g_autoptr(IdeBuildStage) stage = NULL;
-  IdeConfiguration *config;
-  guint stage_id;
-  const gchar * const *build_commands;
-
-  g_assert (GBP_IS_FLATPAK_PIPELINE_ADDIN (self));
-  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
-  g_assert (IDE_IS_CONTEXT (context));
-
-  config = ide_build_pipeline_get_configuration (pipeline);
-  if (!GBP_IS_FLATPAK_CONFIGURATION (config))
-    return TRUE;
-
-  if (NULL == (launcher = ide_build_pipeline_create_launcher (pipeline, error)))
-    return FALSE;
-
-  ide_subprocess_launcher_push_argv (launcher, "/bin/sh");
-  ide_subprocess_launcher_push_argv (launcher, "-c");
-
-  build_commands = ide_configuration_get_build_commands (config);
-  if (build_commands == NULL)
-    return TRUE;
-  else
-    {
-      /* Join the commands so we can use one launcher */
-      g_autofree gchar *build_commands_joined = NULL;
-      build_commands_joined = g_strjoinv (" && ", (gchar **)build_commands);
-      ide_subprocess_launcher_push_argv (launcher, build_commands_joined);
-    }
-
-  stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
-                        "context", context,
-                        "launcher", launcher,
-                        NULL);
-
-  stage_id = ide_build_pipeline_connect (pipeline,
-                                         IDE_BUILD_PHASE_BUILD | IDE_BUILD_PHASE_AFTER,
-                                         0,
-                                         stage);
-  ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
-
-  return TRUE;
-}
-
-static gboolean
-register_post_install_commands_stage (GbpFlatpakPipelineAddin  *self,
-                                      IdeBuildPipeline         *pipeline,
-                                      IdeContext               *context,
-                                      GError                  **error)
-{
-  g_autoptr(IdeSubprocessLauncher) launcher = NULL;
-  g_autoptr(IdeBuildStage) stage = NULL;
-  IdeConfiguration *config;
-  guint stage_id;
-  const gchar * const *post_install_commands;
-
-  g_assert (GBP_IS_FLATPAK_PIPELINE_ADDIN (self));
-  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
-  g_assert (IDE_IS_CONTEXT (context));
-
-  config = ide_build_pipeline_get_configuration (pipeline);
-  if (!GBP_IS_FLATPAK_CONFIGURATION (config))
-    return TRUE;
-
-  if (NULL == (launcher = ide_build_pipeline_create_launcher (pipeline, error)))
-    return FALSE;
-
-  ide_subprocess_launcher_push_argv (launcher, "/bin/sh");
-  ide_subprocess_launcher_push_argv (launcher, "-c");
-
-  post_install_commands = ide_configuration_get_post_install_commands (config);
-  if (post_install_commands == NULL)
-    return TRUE;
-  else
-    {
-      /* Join the commands so we can use one launcher */
-      g_autofree gchar *post_install_commands_joined = NULL;
-      post_install_commands_joined = g_strjoinv (" && ", (gchar **)post_install_commands);
-      ide_subprocess_launcher_push_argv (launcher, post_install_commands_joined);
-    }
-
-  stage = g_object_new (IDE_TYPE_BUILD_STAGE_LAUNCHER,
-                        "context", context,
-                        "launcher", launcher,
-                        NULL);
-
-  stage_id = ide_build_pipeline_connect (pipeline,
-                                         IDE_BUILD_PHASE_INSTALL | IDE_BUILD_PHASE_AFTER,
-                                         0,
-                                         stage);
-  ide_build_pipeline_addin_track (IDE_BUILD_PIPELINE_ADDIN (self), stage_id);
-
-  return TRUE;
-}
-
-static gboolean
 register_build_finish_stage (GbpFlatpakPipelineAddin  *self,
                              IdeBuildPipeline         *pipeline,
                              IdeContext               *context,
@@ -623,8 +521,6 @@ gbp_flatpak_pipeline_addin_load (IdeBuildPipelineAddin *addin,
       !register_build_init_stage (self, pipeline, context, &error) ||
       !register_downloads_stage (self, pipeline, context, &error) ||
       !register_dependencies_stage (self, pipeline, context, &error) ||
-      !register_build_commands_stage (self, pipeline, context, &error) ||
-      !register_post_install_commands_stage (self, pipeline, context, &error) ||
       !register_build_finish_stage (self, pipeline, context, &error) ||
       !register_build_bundle_stage (self, pipeline, context, &error))
     g_warning ("%s", error->message);


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