[gnome-builder] cargo: hoist cargo lookup into helper function
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] cargo: hoist cargo lookup into helper function
- Date: Thu, 23 Nov 2017 01:09:45 +0000 (UTC)
commit 1d72dac8daafac3dbb1ac757bb600bc17c734d61
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 22 16:48:06 2017 -0800
cargo: hoist cargo lookup into helper function
So that we can use this later when necessary outside of the
build pipeline.
src/plugins/cargo/cargo_plugin.py | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/cargo/cargo_plugin.py b/src/plugins/cargo/cargo_plugin.py
index 6c82a45..abf501a 100644
--- a/src/plugins/cargo/cargo_plugin.py
+++ b/src/plugins/cargo/cargo_plugin.py
@@ -71,6 +71,20 @@ class CargoBuildSystem(Ide.Object, Ide.BuildSystem, Gio.AsyncInitable):
def do_get_priority(self):
return 300
+def locate_cargo_from_config(config):
+ cargo = _CARGO
+
+ if config:
+ runtime = config.get_runtime()
+ if config.getenv('CARGO'):
+ cargo = config.getenv('CARGO')
+ elif not runtime or not runtime.contains_program_in_path(_CARGO):
+ cargo_in_home = os.path.expanduser('~/.cargo/bin/cargo')
+ if os.path.exists(cargo_in_home):
+ cargo = cargo_in_home
+
+ return cargo
+
class CargoPipelineAddin(Ide.Object, Ide.BuildPipelineAddin):
"""
The CargoPipelineAddin is responsible for creating the necessary build
@@ -92,13 +106,7 @@ class CargoPipelineAddin(Ide.Object, Ide.BuildPipelineAddin):
runtime = config.get_runtime()
# We might need to use cargo from ~/.cargo/bin
- cargo = _CARGO
- if config.getenv('CARGO'):
- cargo = config.getenv('CARGO')
- elif not runtime.contains_program_in_path(_CARGO):
- cargo_in_home = os.path.expanduser('~/.cargo/bin/cargo')
- if os.path.exists(cargo_in_home):
- cargo = cargo_in_home
+ cargo = locate_cargo_from_config(config)
# Fetch dependencies so that we no longer need network access
fetch_launcher = pipeline.create_launcher()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]