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>
This commit is contained in:
Martin Robinson 2023-05-19 14:07:46 +02:00
parent a56abe44e0
commit 7d20f16d9f
No known key found for this signature in database
GPG key ID: D56AA4FA55EFE6F8
17 changed files with 437 additions and 291 deletions

View file

@ -15,6 +15,8 @@ import os.path as path
import subprocess
from shutil import copytree, rmtree, copy2
import servo.util
from mach.decorators import (
CommandArgument,
CommandProvider,
@ -79,9 +81,15 @@ class PostBuildCommands(CommandBase):
help="Command-line arguments to be passed through to Servo")
def run(self, params, release=False, dev=False, android=None, debug=False, debugger=None,
headless=False, software=False, bin=None, emulator=False, usb=False, nightly=None):
self.set_run_env(android is not None)
env = self.build_env()
env["RUST_BACKTRACE"] = "1"
if software:
if not is_linux():
print("Software rendering is only supported on Linux at the moment.")
return
env['LIBGL_ALWAYS_SOFTWARE'] = "1"
os.environ.update(env)
# Make --debugger imply --debug
if debugger:
@ -129,13 +137,6 @@ class PostBuildCommands(CommandBase):
if headless:
args.append('-z')
if software:
if not is_linux():
print("Software rendering is only supported on Linux at the moment.")
return
env['LIBGL_ALWAYS_SOFTWARE'] = "1"
# Borrowed and modified from:
# http://hg.mozilla.org/mozilla-central/file/c9cfa9b91dea/python/mozbuild/mozbuild/mach_commands.py#l883
if debug:
@ -251,7 +252,7 @@ class PostBuildCommands(CommandBase):
toolchain_path = path.dirname(path.dirname(rustc_path))
rust_docs = path.join(toolchain_path, "share", "doc", "rust", "html")
docs = path.join(self.get_target_dir(), "doc")
docs = path.join(servo.util.get_target_dir(), "doc")
if not path.exists(docs):
os.makedirs(docs)
@ -293,4 +294,4 @@ class PostBuildCommands(CommandBase):
self.doc([])
import webbrowser
webbrowser.open("file://" + path.abspath(path.join(
self.get_target_dir(), "doc", "servo", "index.html")))
servo.util.get_target_dir(), "doc", "servo", "index.html")))