From a770759ebc6a4974da54b510988e5824ea9dcccf Mon Sep 17 00:00:00 2001
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
Date: Fri, 17 Aug 2018 10:06:37 +0100
Subject: [PATCH] Add "remote-execution" project configuration option.

This just adds one option, "remote-execution/url". Affects multiple files.
---
 buildstream/_project.py             |  6 +++++-
 buildstream/data/projectconfig.yaml |  3 +++
 buildstream/element.py              | 15 +++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/buildstream/_project.py b/buildstream/_project.py
index c489e90252..fb0745406f 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -129,6 +129,7 @@ class Project():
 
         self.artifact_cache_specs = None
         self._sandbox = None
+        self._remote_execution = None
         self._splits = None
 
         self._context.add_project(self)
@@ -460,7 +461,7 @@ class Project():
             'aliases', 'name',
             'artifacts', 'options',
             'fail-on-overlap', 'shell', 'fatal-warnings',
-            'ref-storage', 'sandbox', 'mirrors'
+            'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
         ])
 
         #
@@ -478,6 +479,9 @@ class Project():
         # Load sandbox configuration
         self._sandbox = _yaml.node_get(config, Mapping, 'sandbox')
 
+        # Load remote execution configuration
+        self._remote_execution = _yaml.node_get(config, Mapping, 'remote-execution')
+
         # Load project split rules
         self._splits = _yaml.node_get(config, Mapping, 'split-rules')
 
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index 686040ee05..a36da6cefb 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -204,3 +204,6 @@ shell:
   # Command to run when `bst shell` does not provide a command
   #
   command: [ 'sh', '-i' ]
+
+remote-execution:
+  url: ""
\ No newline at end of file
diff --git a/buildstream/element.py b/buildstream/element.py
index a34b1ca368..a24fb3d5f6 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -250,6 +250,9 @@ class Element(Plugin):
         # Extract Sandbox config
         self.__sandbox_config = self.__extract_sandbox_config(meta)
 
+        # Extract remote execution URL
+        self.__remote_execution_url = self.__extract_remote_execution_config(meta)
+
     def __lt__(self, other):
         return self.name < other.name
 
@@ -2289,6 +2292,18 @@ class Element(Plugin):
         return SandboxConfig(self.node_get_member(sandbox_config, int, 'build-uid'),
                              self.node_get_member(sandbox_config, int, 'build-gid'))
 
+    def __extract_remote_execution_config(self, meta):
+        if self.__is_junction:
+            return ''
+        else:
+            project = self._get_project()
+            project.ensure_fully_loaded()
+            if project._remote_execution:
+                rexec_config = _yaml.node_chain_copy(project._remote_execution)
+                return self.node_get_member(rexec_config, str, 'url')
+            else:
+                return ''
+
     # This makes a special exception for the split rules, which
     # elements may extend but whos defaults are defined in the project.
     #
-- 
GitLab