[gnome-builder] plugins/cargo: port dependency updater to IdeRunContext
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/cargo: port dependency updater to IdeRunContext
- Date: Thu, 15 Sep 2022 23:14:31 +0000 (UTC)
commit 46fb55f33061ab59e59ded9a295eed689a76f9aa
Author: Christian Hergert <chergert redhat com>
Date: Thu Sep 15 16:13:46 2022 -0700
plugins/cargo: port dependency updater to IdeRunContext
This helps ensure that our layered execution of commands works with the
pipeline design.
src/plugins/cargo/gbp-cargo-dependency-updater.c | 27 ++++++++++++++----------
1 file changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/cargo/gbp-cargo-dependency-updater.c
b/src/plugins/cargo/gbp-cargo-dependency-updater.c
index acc3ea9de..79daadd90 100644
--- a/src/plugins/cargo/gbp-cargo-dependency-updater.c
+++ b/src/plugins/cargo/gbp-cargo-dependency-updater.c
@@ -64,6 +64,7 @@ gbp_cargo_dependency_updater_update_async (IdeDependencyUpdater *updater,
{
g_autoptr(IdeSubprocessLauncher) launcher = NULL;
g_autoptr(IdeSubprocess) subprocess = NULL;
+ g_autoptr(IdeRunContext) run_context = NULL;
g_autoptr(IdeTask) task = NULL;
g_autoptr(GError) error = NULL;
g_autofree char *cargo_toml = NULL;
@@ -107,21 +108,20 @@ gbp_cargo_dependency_updater_update_async (IdeDependencyUpdater *updater,
config = ide_pipeline_get_config (pipeline);
cargo = gbp_cargo_build_system_locate_cargo (GBP_CARGO_BUILD_SYSTEM (build_system), pipeline, config);
cargo_toml = gbp_cargo_build_system_get_cargo_toml_path (GBP_CARGO_BUILD_SYSTEM (build_system));
-
- launcher = ide_pipeline_create_launcher (pipeline, NULL);
builddir = ide_pipeline_get_builddir (pipeline);
- ide_subprocess_launcher_setenv (launcher, "CARGO_TARGET_DIR", builddir, TRUE);
- ide_subprocess_launcher_push_argv (launcher, cargo);
- ide_subprocess_launcher_push_argv (launcher, "update");
- ide_subprocess_launcher_push_argv (launcher, "--manifest-path");
- ide_subprocess_launcher_push_argv (launcher, cargo_toml);
+
+ run_context = ide_run_context_new ();
+ ide_pipeline_prepare_run_context (pipeline, run_context);
+ ide_run_context_append_args (run_context, IDE_STRV_INIT (cargo, "update", "--manifest-path", cargo_toml));
+ ide_run_context_setenv (run_context, "CARGO_TARGET_DIR", builddir);
+
+ if (!(launcher = ide_run_context_end (run_context, &error)))
+ IDE_GOTO (handle_error);
+
ide_pipeline_attach_pty (pipeline, launcher);
if (!(subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, NULL)))
- {
- ide_task_return_error (task, g_steal_pointer (&error));
- IDE_EXIT;
- }
+ IDE_GOTO (handle_error);
ide_subprocess_wait_check_async (subprocess,
cancellable,
@@ -129,6 +129,11 @@ gbp_cargo_dependency_updater_update_async (IdeDependencyUpdater *updater,
g_steal_pointer (&task));
IDE_EXIT;
+
+handle_error:
+ ide_task_return_error (task, g_steal_pointer (&error));
+
+ IDE_EXIT;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]