aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/platform/base.py
diff options
context:
space:
mode:
authorMukilan Thiyagarajan <mukilan@igalia.com>2024-08-26 18:38:21 +0530
committerGitHub <noreply@github.com>2024-08-26 13:08:21 +0000
commitb6d5ac09b0b2acbb0f5b00232e53d0111a159063 (patch)
tree18842738e78794ba096a0af44b16d37695cff6d7 /python/servo/platform/base.py
parent4397d8a02156a009d16d8b79796b1e54ca635624 (diff)
downloadservo-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/base.py')
-rw-r--r--python/servo/platform/base.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/python/servo/platform/base.py b/python/servo/platform/base.py
index 3cfbd09b618..6fb2f535f4e 100644
--- a/python/servo/platform/base.py
+++ b/python/servo/platform/base.py
@@ -12,6 +12,8 @@ import shutil
import subprocess
from typing import Optional
+from .build_target import BuildTarget
+
class Base:
def __init__(self, triple: str):
@@ -21,7 +23,7 @@ class Base:
self.is_linux = False
self.is_macos = False
- def gstreamer_root(self, _cross_compilation_target: Optional[str]) -> Optional[str]:
+ def gstreamer_root(self, target: BuildTarget) -> Optional[str]:
raise NotImplementedError("Do not know how to get GStreamer path for platform.")
def executable_suffix(self) -> str:
@@ -30,13 +32,13 @@ class Base:
def _platform_bootstrap(self, _force: bool) -> bool:
raise NotImplementedError("Bootstrap installation detection not yet available.")
- def _platform_bootstrap_gstreamer(self, _force: bool) -> bool:
+ def _platform_bootstrap_gstreamer(self, _target: BuildTarget, _force: bool) -> bool:
raise NotImplementedError(
"GStreamer bootstrap support is not yet available for your OS."
)
- def is_gstreamer_installed(self, cross_compilation_target: Optional[str]) -> bool:
- gstreamer_root = self.gstreamer_root(cross_compilation_target)
+ def is_gstreamer_installed(self, target: BuildTarget) -> bool:
+ gstreamer_root = self.gstreamer_root(target)
if gstreamer_root:
pkg_config = os.path.join(gstreamer_root, "bin", "pkg-config")
else:
@@ -100,8 +102,9 @@ class Base:
return False
def bootstrap_gstreamer(self, force: bool):
- if not self._platform_bootstrap_gstreamer(force):
- root = self.gstreamer_root(None)
+ target = BuildTarget.from_triple(self.triple)
+ if not self._platform_bootstrap_gstreamer(target, force):
+ root = self.gstreamer_root(target)
if root:
print(f"GStreamer found at: {root}")
else: