summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildstream/element.py10
-rw-r--r--buildstream/sandbox/_config.py34
2 files changed, 35 insertions, 9 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 57d3732e7..e0cefbbe2 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -926,7 +926,6 @@ class Element(Plugin):
context = self._get_context()
project = self._get_project()
- operating_system, _, _, _, machine_arch = os.uname()
self.__cache_key_dict = {
'artifact-version': "{}.{}".format(_BST_CORE_ARTIFACT_VERSION,
@@ -934,14 +933,7 @@ class Element(Plugin):
'context': context._get_cache_key(),
'project': project._get_cache_key(),
'element': self.get_unique_key(),
-
- # The execution environment may later be delegated
- # to sandboxes which support virtualization
- #
- 'execution-environment': {
- 'os': operating_system,
- 'arch': machine_arch
- },
+ 'execution-environment': self.__sandbox_config.get_unique_key(),
'environment': cache_env,
'sources': [s._get_unique_key() for s in self.__sources],
'public': self.__public,
diff --git a/buildstream/sandbox/_config.py b/buildstream/sandbox/_config.py
index ca5273864..8893e3faa 100644
--- a/buildstream/sandbox/_config.py
+++ b/buildstream/sandbox/_config.py
@@ -17,6 +17,7 @@
#
# Authors:
# Jim MacArthur <jim.macarthur@codethink.co.uk>
+import os
# SandboxConfig
@@ -27,3 +28,36 @@ class SandboxConfig():
def __init__(self, build_uid, build_gid):
self.build_uid = build_uid
self.build_gid = build_gid
+
+ # get_unique_key():
+ #
+ # This returns the SandboxConfig's contribution
+ # to an element's cache key.
+ #
+ # Returns:
+ # (dict): A dictionary to add to an element's cache key
+ #
+ def get_unique_key(self):
+
+ # Currently operating system and machine architecture
+ # are not configurable and we have no sandbox implementation
+ # which can conform to such configurations.
+ #
+ # However this should be the right place to support
+ # such configurations in the future.
+ #
+ operating_system, _, _, _, machine_arch = os.uname()
+ unique_key = {
+ 'os': operating_system,
+ 'arch': machine_arch
+ }
+
+ # Avoid breaking cache key calculation with
+ # the addition of configurabuild build uid/gid
+ if self.build_uid != 0:
+ unique_key['build-uid'] = self.build_uid
+
+ if self.build_gid != 0:
+ unique_key['build-gid'] = self.build_gid
+
+ return unique_key