aboutsummaryrefslogtreecommitdiffstats
path: root/python/mach_bootstrap.py
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-05-18 15:09:30 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-05-19 13:08:43 +0200
commit5be14ecc3cc92309637604b48bdcf249b110ac16 (patch)
treeef5f13d8e79866eda1a84c847837938c884ebb2c /python/mach_bootstrap.py
parente09f85e17bd504a4c1c218ad14fa1a0ecbcaa839 (diff)
downloadservo-5be14ecc3cc92309637604b48bdcf249b110ac16.tar.gz
servo-5be14ecc3cc92309637604b48bdcf249b110ac16.zip
Start organizing platform-specific Python code
This starts to split platform-specific Python code into its own module, which should help to tidy up our mach commands and make things more reusable.
Diffstat (limited to 'python/mach_bootstrap.py')
-rw-r--r--python/mach_bootstrap.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py
index 26d4ecbb945..06d5377aa84 100644
--- a/python/mach_bootstrap.py
+++ b/python/mach_bootstrap.py
@@ -7,9 +7,10 @@ from __future__ import print_function, unicode_literals
import os
import platform
import sys
+import shutil
+
from distutils.spawn import find_executable
from subprocess import Popen
-import shutil
from tempfile import TemporaryFile
SEARCH_PATHS = [
@@ -228,10 +229,6 @@ def _is_windows():
return sys.platform == 'win32'
-class DummyContext(object):
- pass
-
-
def is_firefox_checkout(topdir):
parentdir = os.path.normpath(os.path.join(topdir, '..'))
is_firefox = os.path.isfile(os.path.join(parentdir,
@@ -244,14 +241,24 @@ def bootstrap_command_only(topdir):
# because the module requires non-standard python packages
_activate_virtualenv(topdir, is_firefox_checkout(topdir))
- from servo.bootstrap import bootstrap
+ # We cannot import these modules until the virtual environment
+ # is active because they depend on modules installed via the
+ # virtual environment.
+ # pylint: disable=import-outside-toplevel
+ import servo.platform
+ import servo.util
+
+ # We are not set up yet, so we always use the default cache directory
+ # for the initial bootstrap.
+ # TODO(mrobinson): Why not just run the bootstrap command in this case?
+
+ try:
+ servo.platform.get().bootstrap(
+ servo.util.get_default_cache_dir(topdir), '-f' in sys.argv)
+ except NotImplementedError as exception:
+ print(exception)
+ return 1
- context = DummyContext()
- context.topdir = topdir
- force = False
- if len(sys.argv) == 3 and sys.argv[2] == "-f":
- force = True
- bootstrap(context, force)
return 0
@@ -260,8 +267,6 @@ def bootstrap(topdir):
topdir = os.path.abspath(topdir)
- len(sys.argv) > 1 and sys.argv[1] == "bootstrap"
-
# We don't support paths with Unicode characters for now
# https://github.com/servo/servo/issues/10002
try: