summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-03-25 15:44:53 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2020-04-14 15:30:49 +0000
commit129b19dafdf69f72a7e3638be91ccbf446458d61 (patch)
tree1fe535601749201dfc7b4415db7af346e8e690dd
parent5b48b47c8bd57bd9ad6c8d7f92f3bd08c283e6d0 (diff)
downloadbuildstream-juerg/platform.tar.gz
_sandboxbuildboxrun.py: Detect platforms supported by buildbox-runjuerg/platform
This allows builds where the host OS or architecture doesn't match the build OS or architecture, if the buildbox-run implementation supports it. E.g., this allows x86-32 builds on x86-64 systems.
-rw-r--r--src/buildstream/_platform/platform.py6
-rw-r--r--src/buildstream/sandbox/_sandboxbuildboxrun.py24
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.")