aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/platform/__init__.py
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-05-19 14:07:46 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-05-25 08:22:21 +0200
commit7d20f16d9f746399811b1c4582e83efde1416bff (patch)
treef9aed7799918e930e43ab7ed834afdea9623b0d2 /python/servo/platform/__init__.py
parenta56abe44e02ddf3e634fd1a3953cd0cffc22d460 (diff)
downloadservo-7d20f16d9f746399811b1c4582e83efde1416bff.tar.gz
servo-7d20f16d9f746399811b1c4582e83efde1416bff.zip
Implement `bootstrap-gstreamer` for all platforms
This change makes it so that the Platform classes can now handle installing GStreamer dependencies and properly setting up the environment including when cross-compiling. For Windows and Linux is now installed into `target/dependencies/gstreamer` when not installed system-wide. In addition: 1. Creating and moving existing environment path append helpers to `util.py`. 2. Combining the `set_run_env` and `build_dev` functions and moving some outside code into them so that it can be shared. Now code that used to call `set_run_env` calls `build_dev` and then `os.environ.update(...)`. 3. Adding Python typing information in many places. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'python/servo/platform/__init__.py')
-rw-r--r--python/servo/platform/__init__.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/python/servo/platform/__init__.py b/python/servo/platform/__init__.py
index 84968550d00..e06bebaf863 100644
--- a/python/servo/platform/__init__.py
+++ b/python/servo/platform/__init__.py
@@ -9,9 +9,10 @@
import platform
-from .base import Base
from .windows import Windows
+__platform__ = None
+
def host_platform():
os_type = platform.system().lower()
@@ -47,18 +48,27 @@ def host_triple():
def get():
+ # pylint: disable=global-statement
+ global __platform__
+ if __platform__:
+ return __platform__
+
# We import the concrete platforms in if-statements here, because
# each one might have platform-specific imports which might not
# resolve on all platforms.
# TODO(mrobinson): We should do this for Windows too, once we
# stop relying on platform-specific code outside of this module.
# pylint: disable=import-outside-toplevel
- if "windows-msvc" in host_triple():
- return Windows()
- if "linux-gnu" in host_triple():
+ triple = host_triple()
+ if "windows-msvc" in triple:
+ __platform__ = Windows(triple)
+ elif "linux-gnu" in triple:
from .linux import Linux
- return Linux()
- if "apple-darwin" in host_triple():
+ __platform__ = Linux(triple)
+ elif "apple-darwin" in triple:
from .macos import MacOS
- return MacOS()
- return Base()
+ __platform__ = MacOS(triple)
+ else:
+ from .base import Base
+ __platform__ = Base(triple)
+ return __platform__