[gnome-builder/wip/chergert/pipeline-merge: 76/78] flatpak: Use flatpak-build for the runner



commit 82283e92afc2e644bc154b095b902842dcecae02
Author: Matthew Leeds <mleeds redhat com>
Date:   Tue Feb 7 21:57:20 2017 -0600

    flatpak: Use flatpak-build for the runner
    
    We're not doing a full flatpak install to a repo, just building the app
    and running the built binary. So this commit fixes the flatpak runtime's
    create_runner function to use flatpak-build rather than flatpak-run.
    In order to get the name of the binary, it was necessary to add a
    get_name function to the IdeBuildTarget interface and implement it for
    IdeAutotoolsBuildTarget.

 libide/buildsystem/ide-build-target.c          |   16 ++++++++++++++
 libide/buildsystem/ide-build-target.h          |    3 +-
 plugins/autotools/ide-autotools-build-target.c |    9 ++++++++
 plugins/flatpak/gbp-flatpak-runtime.c          |   26 +++++++++++------------
 4 files changed, 39 insertions(+), 15 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-target.c b/libide/buildsystem/ide-build-target.c
index 939fde8..cffc8fb 100644
--- a/libide/buildsystem/ide-build-target.c
+++ b/libide/buildsystem/ide-build-target.c
@@ -42,3 +42,19 @@ ide_build_target_get_install_directory (IdeBuildTarget *self)
 
   return NULL;
 }
+
+/**
+ * ide_build_target_get_name:
+ *
+ * Returns: (nullable) (transfer full): A filename or %NULL.
+ */
+gchar *
+ide_build_target_get_name (IdeBuildTarget *self)
+{
+  g_return_val_if_fail (IDE_IS_BUILD_TARGET (self), NULL);
+
+  if (IDE_BUILD_TARGET_GET_IFACE (self)->get_name)
+    return IDE_BUILD_TARGET_GET_IFACE (self)->get_name (self);
+
+  return NULL;
+}
diff --git a/libide/buildsystem/ide-build-target.h b/libide/buildsystem/ide-build-target.h
index bc756d4..578eb12 100644
--- a/libide/buildsystem/ide-build-target.h
+++ b/libide/buildsystem/ide-build-target.h
@@ -34,8 +34,8 @@ struct _IdeBuildTargetInterface
   GTypeInterface parent_iface;
 
   GFile *(*get_install_directory) (IdeBuildTarget *self);
+  gchar *(*get_name)              (IdeBuildTarget *self);
 
-  gpointer _reserved1;
   gpointer _reserved2;
   gpointer _reserved3;
   gpointer _reserved4;
@@ -46,6 +46,7 @@ struct _IdeBuildTargetInterface
 };
 
 GFile *ide_build_target_get_install_directory (IdeBuildTarget *self);
+gchar *ide_build_target_get_name (IdeBuildTarget *self);
 
 G_END_DECLS
 
diff --git a/plugins/autotools/ide-autotools-build-target.c b/plugins/autotools/ide-autotools-build-target.c
index faa3a7d..d59738c 100644
--- a/plugins/autotools/ide-autotools-build-target.c
+++ b/plugins/autotools/ide-autotools-build-target.c
@@ -159,8 +159,17 @@ ide_autotools_build_target_get_install_directory (IdeBuildTarget *target)
   return NULL;
 }
 
+static gchar *
+ide_autotools_build_target_get_name (IdeBuildTarget *target)
+{
+  IdeAutotoolsBuildTarget *self = (IdeAutotoolsBuildTarget *)target;
+
+  return g_strdup (self->name);
+}
+
 static void
 build_target_iface_init (IdeBuildTargetInterface *iface)
 {
   iface->get_install_directory = ide_autotools_build_target_get_install_directory;
+  iface->get_name = ide_autotools_build_target_get_name;
 }
diff --git a/plugins/flatpak/gbp-flatpak-runtime.c b/plugins/flatpak/gbp-flatpak-runtime.c
index 30b93fc..9f71f8b 100644
--- a/plugins/flatpak/gbp-flatpak-runtime.c
+++ b/plugins/flatpak/gbp-flatpak-runtime.c
@@ -264,37 +264,35 @@ gbp_flatpak_runtime_create_runner (IdeRuntime     *runtime,
 {
   GbpFlatpakRuntime *self = (GbpFlatpakRuntime *)runtime;
   IdeContext *context;
-  IdeConfigurationManager *config_manager;
-  IdeConfiguration *configuration;
   GbpFlatpakRunner *runner;
-  const gchar *app_id = NULL;
-  g_autofree gchar *own_name = NULL;
-  g_autofree gchar *app_id_override = NULL;
+  g_autofree gchar *build_path = NULL;
+  g_autofree gchar *binary_name = NULL;
 
   g_assert (GBP_IS_FLATPAK_RUNTIME (self));
   g_assert (IDE_IS_BUILD_TARGET (build_target));
 
   context = ide_object_get_context (IDE_OBJECT (self));
-  config_manager = ide_context_get_configuration_manager (context);
-  configuration = ide_configuration_manager_get_current (config_manager);
-
   runner = gbp_flatpak_runner_new (context);
   g_assert (GBP_IS_FLATPAK_RUNNER (runner));
 
-  app_id = ide_configuration_get_app_id (configuration);
-  if (ide_str_empty0 (app_id))
+  build_path = get_staging_directory (self);
+  binary_name = ide_build_target_get_name (build_target);
+  /* Use the project name if we can't determine the binary */
+  if (ide_str_empty0 (binary_name))
     {
-      g_warning ("Could not determine application ID");
-      app_id = "org.gnome.FlatpakApp";
+      IdeProject *project;
+      project = ide_context_get_project (context);
+      binary_name = g_strdup (ide_project_get_name (project));
     }
 
   ide_runner_set_run_on_host (IDE_RUNNER (runner), TRUE);
   ide_runner_append_argv (IDE_RUNNER (runner), "flatpak");
-  ide_runner_append_argv (IDE_RUNNER (runner), "run");
+  ide_runner_append_argv (IDE_RUNNER (runner), "build");
   ide_runner_append_argv (IDE_RUNNER (runner), "--share=ipc");
   ide_runner_append_argv (IDE_RUNNER (runner), "--socket=x11");
   ide_runner_append_argv (IDE_RUNNER (runner), "--socket=wayland");
-  ide_runner_append_argv (IDE_RUNNER (runner), app_id);
+  ide_runner_append_argv (IDE_RUNNER (runner), build_path);
+  ide_runner_append_argv (IDE_RUNNER (runner), binary_name);
 
   return IDE_RUNNER (runner);
 }


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