mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Find WPT files in Firefox repository
The Servo repository is now (mostly) vendored in the Firefox Mercurial repository. For size and duplication reasons, the tests/wpt directory is not included in the vendored copy. This causes problems when running `mach` from the Firefox repository because `mach` references pip requirements files and module search paths from WPT. This commit adds code to detect when Servo's mach is running from a Firefox source tree and to resolve WPT paths to the Firefox location if appropriate. This enables `mach` to "just work" when running from the servo/ directory in the Firefox repository. The file looked for to identify the Firefox repository is identical to what Firefox's `mach` script uses. A potential issue with using Firefox's WPT files is that they may be different from those in the Servo repository and this could lead to differences in behavior - possibly even an error when loading/running `mach`. However, the behavior before this commit was that Servo's `mach` never worked in the Firefox repository (due to missing WPT files). And post-commit it does. So this seems like a "perfect is the enemy of good" scenario.
This commit is contained in:
parent
19deb66e2c
commit
d27be52371
1 changed files with 26 additions and 7 deletions
|
@ -12,8 +12,11 @@ from subprocess import PIPE, Popen
|
||||||
|
|
||||||
SEARCH_PATHS = [
|
SEARCH_PATHS = [
|
||||||
os.path.join("python", "tidy"),
|
os.path.join("python", "tidy"),
|
||||||
os.path.join("tests", "wpt"),
|
]
|
||||||
os.path.join("tests", "wpt", "harness"),
|
|
||||||
|
WPT_SEARCH_PATHS = [
|
||||||
|
".",
|
||||||
|
"harness",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Individual files providing mach commands.
|
# Individual files providing mach commands.
|
||||||
|
@ -103,7 +106,16 @@ def _get_virtualenv_script_dir():
|
||||||
return "bin"
|
return "bin"
|
||||||
|
|
||||||
|
|
||||||
def _activate_virtualenv(topdir):
|
def wpt_path(topdir, paths, is_firefox):
|
||||||
|
if is_firefox:
|
||||||
|
rel = os.path.join("..", "testing", "web-platform")
|
||||||
|
else:
|
||||||
|
rel = os.path.join("tests", "wpt")
|
||||||
|
|
||||||
|
return os.path.join(topdir, rel, *paths)
|
||||||
|
|
||||||
|
|
||||||
|
def _activate_virtualenv(topdir, is_firefox):
|
||||||
virtualenv_path = os.path.join(topdir, "python", "_virtualenv")
|
virtualenv_path = os.path.join(topdir, "python", "_virtualenv")
|
||||||
check_exec_path = lambda path: path.startswith(virtualenv_path)
|
check_exec_path = lambda path: path.startswith(virtualenv_path)
|
||||||
python = _get_exec_path(PYTHON_NAMES) # If there was no python, mach wouldn't have run at all!
|
python = _get_exec_path(PYTHON_NAMES) # If there was no python, mach wouldn't have run at all!
|
||||||
|
@ -145,9 +157,9 @@ def _activate_virtualenv(topdir):
|
||||||
# and it will check for conflicts.
|
# and it will check for conflicts.
|
||||||
requirements_paths = [
|
requirements_paths = [
|
||||||
os.path.join("python", "requirements.txt"),
|
os.path.join("python", "requirements.txt"),
|
||||||
os.path.join("tests", "wpt", "harness", "requirements.txt"),
|
wpt_path(topdir, ("harness", "requirements.txt"), is_firefox),
|
||||||
os.path.join("tests", "wpt", "harness", "requirements_firefox.txt"),
|
wpt_path(topdir, ("harness", "requirements_firefox.txt"), is_firefox),
|
||||||
os.path.join("tests", "wpt", "harness", "requirements_servo.txt"),
|
wpt_path(topdir, ("harness", "requirements_servo.txt"), is_firefox),
|
||||||
]
|
]
|
||||||
|
|
||||||
if need_pip_upgrade:
|
if need_pip_upgrade:
|
||||||
|
@ -239,7 +251,12 @@ def bootstrap(topdir):
|
||||||
print('You are running Python', platform.python_version())
|
print('You are running Python', platform.python_version())
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
_activate_virtualenv(topdir)
|
# See if we're inside a Firefox checkout.
|
||||||
|
parentdir = os.path.normpath(os.path.join(topdir, '..'))
|
||||||
|
is_firefox = os.path.isfile(os.path.join(parentdir,
|
||||||
|
'build/mach_bootstrap.py'))
|
||||||
|
|
||||||
|
_activate_virtualenv(topdir, is_firefox)
|
||||||
|
|
||||||
def populate_context(context, key=None):
|
def populate_context(context, key=None):
|
||||||
if key is None:
|
if key is None:
|
||||||
|
@ -249,6 +266,8 @@ def bootstrap(topdir):
|
||||||
raise AttributeError(key)
|
raise AttributeError(key)
|
||||||
|
|
||||||
sys.path[0:0] = [os.path.join(topdir, path) for path in SEARCH_PATHS]
|
sys.path[0:0] = [os.path.join(topdir, path) for path in SEARCH_PATHS]
|
||||||
|
sys.path[0:0] = [wpt_path(topdir, (path,), is_firefox)
|
||||||
|
for path in WPT_SEARCH_PATHS]
|
||||||
import mach.main
|
import mach.main
|
||||||
mach = mach.main.Mach(os.getcwd())
|
mach = mach.main.Mach(os.getcwd())
|
||||||
mach.populate_context_handler = populate_context
|
mach.populate_context_handler = populate_context
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue