diff options
Diffstat (limited to 'src/buildstream')
-rw-r--r-- | src/buildstream/_platform/platform.py | 6 | ||||
-rw-r--r-- | src/buildstream/sandbox/_sandboxbuildboxrun.py | 24 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py index f3a9964d1..dddb52bd4 100644 --- a/src/buildstream/_platform/platform.py +++ b/src/buildstream/_platform/platform.py @@ -266,18 +266,18 @@ class Platform: # Buildbox run sandbox methods def _check_sandbox_config_buildboxrun(self, config): - from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun + from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun # pylint: disable=cyclic-import SandboxBuildBoxRun.check_sandbox_config(self, config) @staticmethod def _create_buildboxrun_sandbox(*args, **kwargs): - from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun + from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun # pylint: disable=cyclic-import return SandboxBuildBoxRun(*args, **kwargs) def setup_buildboxrun_sandbox(self): - from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun + from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun # pylint: disable=cyclic-import self._check_sandbox(SandboxBuildBoxRun) self.check_sandbox_config = self._check_sandbox_config_buildboxrun diff --git a/src/buildstream/sandbox/_sandboxbuildboxrun.py b/src/buildstream/sandbox/_sandboxbuildboxrun.py index 80858f338..246fdd450 100644 --- a/src/buildstream/sandbox/_sandboxbuildboxrun.py +++ b/src/buildstream/sandbox/_sandboxbuildboxrun.py @@ -26,6 +26,7 @@ from .. import utils, _signals from . import SandboxFlags from .._exceptions import SandboxError from .._message import Message, MessageType +from .._platform import Platform from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 from ._sandboxreapi import SandboxREAPI @@ -59,17 +60,30 @@ class SandboxBuildBoxRun(SandboxREAPI): cls._dummy_reasons += ["buildbox-run: {}".format(output)] raise SandboxError(" and ".join(cls._dummy_reasons), reason="unavailable-local-sandbox") + osfamily_prefix = "platform:OSFamily=" + cls._osfamilies = {cap[len(osfamily_prefix) :] for cap in cls._capabilities if cap.startswith(osfamily_prefix)} + if not cls._osfamilies: + # buildbox-run is too old to list supported OS families, + # limit support to native building on the host OS. + cls._osfamilies.add(Platform.get_host_os()) + + isa_prefix = "platform:ISA=" + cls._isas = {cap[len(isa_prefix) :] for cap in cls._capabilities if cap.startswith(isa_prefix)} + if not cls._isas: + # buildbox-run is too old to list supported ISAs, + # limit support to native building on the host ISA. + cls._isas.add(Platform.get_host_arch()) + @classmethod def check_sandbox_config(cls, platform, config): if platform.does_multiprocessing_start_require_pickling(): # Reinitialize class as class data is not pickled. cls.check_available() - # Check host os and architecture match - if config.build_os != platform.get_host_os(): - raise SandboxError("Configured and host OS don't match.") - if config.build_arch != platform.get_host_arch(): - raise SandboxError("Configured and host architecture don't match.") + if config.build_os not in cls._osfamilies: + raise SandboxError("OS '{}' is not supported by buildbox-run.".format(config.build_os)) + if config.build_arch not in cls._isas: + raise SandboxError("ISA '{}' is not supported by buildbox-run.".format(config.build_arch)) if config.build_uid is not None and "platform:unixUID" not in cls._capabilities: raise SandboxError("Configuring sandbox UID is not supported by buildbox-run.") |