diff options
author | Mukilan Thiyagarajan <mukilan@igalia.com> | 2024-08-26 18:38:21 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-26 13:08:21 +0000 |
commit | b6d5ac09b0b2acbb0f5b00232e53d0111a159063 (patch) | |
tree | 18842738e78794ba096a0af44b16d37695cff6d7 /python/servo/platform/macos.py | |
parent | 4397d8a02156a009d16d8b79796b1e54ca635624 (diff) | |
download | servo-b6d5ac09b0b2acbb0f5b00232e53d0111a159063.tar.gz servo-b6d5ac09b0b2acbb0f5b00232e53d0111a159063.zip |
mach: introduce `BuildTarget` abstraction (#33114)
Introduce a new `BuildTarget` abstraction to centralize the code for
supporting different ways of choosing the build target (e.g --android,
--target x86_64-linux-android , --target aarch64-linux-ohos). This
is currently handled in an adhoc fashion in different commands (
mach package, install, run) leading to a proliferation of keyword
parameters for the commands and duplicated logic.
The patch introduces a new `allow_target_configuration` decorator to
do the validation and parsing of these parameters into the appropriate
`BuildTarget` subclass, which is now stored as an instance attribute
of the CommandBase class. All the code that previously relied on
`self.cross_compile_target` has been switched to use the BuildTarget.
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Diffstat (limited to 'python/servo/platform/macos.py')
-rw-r--r-- | python/servo/platform/macos.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/python/servo/platform/macos.py b/python/servo/platform/macos.py index de20fe35ad5..a1655dc613e 100644 --- a/python/servo/platform/macos.py +++ b/python/servo/platform/macos.py @@ -14,6 +14,7 @@ from typing import Optional from .. import util from .base import Base +from .build_target import BuildTarget URL_BASE = "https://github.com/servo/servo-build-deps/releases/download/macOS" GSTREAMER_PLUGIN_VERSION = "1.22.3" @@ -27,15 +28,15 @@ class MacOS(Base): super().__init__(*args, **kwargs) self.is_macos = True - def gstreamer_root(self, cross_compilation_target: Optional[str]) -> Optional[str]: + def gstreamer_root(self, target: BuildTarget) -> Optional[str]: # We do not support building with gstreamer while cross-compiling on MacOS. - if cross_compilation_target or not os.path.exists(GSTREAMER_ROOT): + if target.is_cross_build() or not os.path.exists(GSTREAMER_ROOT): return None return GSTREAMER_ROOT - def is_gstreamer_installed(self, cross_compilation_target: Optional[str]) -> bool: + def is_gstreamer_installed(self, target: BuildTarget) -> bool: # Servo only supports the official GStreamer distribution on MacOS. - return not cross_compilation_target and os.path.exists(GSTREAMER_ROOT) + return not target.is_cross_build() and os.path.exists(GSTREAMER_ROOT) def _platform_bootstrap(self, _force: bool) -> bool: installed_something = False @@ -49,11 +50,12 @@ class MacOS(Base): except subprocess.CalledProcessError as e: print("Could not run homebrew. Is it installed?") raise e - installed_something |= self._platform_bootstrap_gstreamer(False) + target = BuildTarget.from_triple(None) + installed_something |= self._platform_bootstrap_gstreamer(target, False) return installed_something - def _platform_bootstrap_gstreamer(self, force: bool) -> bool: - if not force and self.is_gstreamer_installed(cross_compilation_target=None): + def _platform_bootstrap_gstreamer(self, target: BuildTarget, force: bool) -> bool: + if not force and self.is_gstreamer_installed(target): return False with tempfile.TemporaryDirectory() as temp_dir: @@ -78,5 +80,5 @@ class MacOS(Base): ] ) - assert self.is_gstreamer_installed(cross_compilation_target=None) + assert self.is_gstreamer_installed(target) return True |