Commit 82283e92 authored by Matthew Leeds's avatar Matthew Leeds
Browse files

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.
parent 223a048f
......@@ -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;
}
......@@ -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
......
......@@ -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;
}
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment