summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildstream/element.py25
-rw-r--r--src/buildstream/sandbox/_config.py27
2 files changed, 23 insertions, 29 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index bd702b112..580871802 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -96,7 +96,6 @@ from .utils import FileListResult, BST_ARBITRARY_TIMESTAMP
from . import utils
from . import _cachekey
from . import _site
-from ._platform import Platform
from .node import Node
from .plugin import Plugin
from .sandbox import SandboxFlags, SandboxCommandError
@@ -2708,11 +2707,6 @@ class Element(Plugin):
else:
sandbox_config = project._sandbox.clone()
- # Get the platform to ask for host architecture
- platform = context.platform
- host_arch = platform.get_host_arch()
- host_os = platform.get_host_os()
-
# The default config is already composited with the project overrides
sandbox_defaults = cls.__defaults.get_mapping("sandbox", default={})
sandbox_defaults = sandbox_defaults.clone()
@@ -2721,24 +2715,7 @@ class Element(Plugin):
meta.sandbox._composite(sandbox_config)
sandbox_config._assert_fully_composited()
- # Sandbox config, unlike others, has fixed members so we should validate them
- sandbox_config.validate_keys(["build-uid", "build-gid", "build-os", "build-arch"])
-
- build_os = sandbox_config.get_str("build-os", default=None)
- if build_os:
- build_os = build_os.lower()
- else:
- build_os = host_os
-
- build_arch = sandbox_config.get_str("build-arch", default=None)
- if build_arch:
- build_arch = Platform.canonicalize_arch(build_arch)
- else:
- build_arch = host_arch
-
- return SandboxConfig(
- sandbox_config.get_int("build-uid", None), sandbox_config.get_int("build-gid", None), build_os, build_arch,
- )
+ return SandboxConfig(sandbox_config, context.platform)
# This makes a special exception for the split rules, which
# elements may extend but whos defaults are defined in the project.
diff --git a/src/buildstream/sandbox/_config.py b/src/buildstream/sandbox/_config.py
index 7a71e7d50..114274190 100644
--- a/src/buildstream/sandbox/_config.py
+++ b/src/buildstream/sandbox/_config.py
@@ -17,17 +17,34 @@
# Authors:
# Jim MacArthur <jim.macarthur@codethink.co.uk>
+from .._platform import Platform
+
# SandboxConfig
#
# A container for sandbox configuration data. We want the internals
# of this to be opaque, hence putting it in its own private file.
class SandboxConfig:
- def __init__(self, build_uid, build_gid, build_os=None, build_arch=None):
- self.build_uid = build_uid
- self.build_gid = build_gid
- self.build_os = build_os
- self.build_arch = build_arch
+ def __init__(self, sandbox_config, platform):
+ host_arch = platform.get_host_arch()
+ host_os = platform.get_host_os()
+
+ sandbox_config.validate_keys(["build-uid", "build-gid", "build-os", "build-arch"])
+
+ build_os = sandbox_config.get_str("build-os", default=None)
+ if build_os:
+ self.build_os = build_os.lower()
+ else:
+ self.build_os = host_os
+
+ build_arch = sandbox_config.get_str("build-arch", default=None)
+ if build_arch:
+ self.build_arch = Platform.canonicalize_arch(build_arch)
+ else:
+ self.build_arch = host_arch
+
+ self.build_uid = sandbox_config.get_int("build-uid", None)
+ self.build_gid = sandbox_config.get_int("build-gid", None)
# get_unique_key():
#