servo: Merge #20227 - Fix mach build for Servo in Firefox tree (from upsuper:in-firefox-build); r=jdm

Running `mach build` in servo directory in Firefox tree currently doesn't work due to several errors when importing modules.

First error:
```text
Traceback (most recent call last):
  File "mach", line 93, in <module>
    main(sys.argv)
  File "mach", line 23, in main
    mach = mach_bootstrap.bootstrap(topdir)
  File "servo/python/mach_bootstrap.py", line 280, in bootstrap
    mach.load_commands_from_file(os.path.join(topdir, path))
  File "servo/python/_virtualenv/Lib/site-packages/mach/main.py", line 265, in load_commands_from_file
    imp.load_source(module_name, path)
  File "servo/python/servo/testing_commands.py", line 42, in <module>
    from update import updatecommandline
  File "servo/../testing/web-platform/update/__init__.py", line 17, in <module>
    from wptrunner.update import setup_logging, WPTUpdate
  File "servo/../testing/web-platform/tests/tools/wptrunner/wptrunner/update/__init__.py", line 8, in <module>
    from update import WPTUpdate
  File "servo/../testing/web-platform/tests/tools/wptrunner/wptrunner/update/update.py", line 8, in <module>
    from .. import environment as env
  File "servo/../testing/web-platform/tests/tools/wptrunner/wptrunner/environment.py", line 12, in <module>
    from wptserve.handlers import StringHandler
ImportError: No module named wptserve.handlers
```

Second error:
```text
Traceback (most recent call last):
  File "mach", line 93, in <module>
    main(sys.argv)
  File "mach", line 23, in main
    mach = mach_bootstrap.bootstrap(topdir)
  File "servo/python/mach_bootstrap.py", line 291, in bootstrap
    mach.load_commands_from_file(os.path.join(topdir, path))
  File "servo/python/_virtualenv/Lib/site-packages/mach/main.py", line 265, in load_commands_from_file
    imp.load_source(module_name, path)
  File "servo/python/servo/testing_commands.py", line 43, in <module>
    from servo_tidy import tidy
  File "servo/python/tidy/servo_tidy/tidy.py", line 34, in <module>
    from wptmanifest import parser, node
ImportError: No module named wptmanifest
```

The two commits fix these two errors respectively.

Source-Repo: https://github.com/servo/servo
Source-Revision: 4e2f8ec8e162fe707240eff223ec225790bf29fd
This commit is contained in:
Xidorn Quan
2018-03-07 09:19:25 -05:00
parent 36cb8e0a60
commit 6a2211c267
2 changed files with 26 additions and 9 deletions

View File

@@ -30,12 +30,15 @@ wpt = os.path.join(topdir, "tests", "wpt")
def wpt_path(*args):
return os.path.join(wpt, *args)
sys.path.append(wpt_path("web-platform-tests", "tools", "wptrunner", "wptrunner"))
from wptmanifest import parser, node
CONFIG_FILE_PATH = os.path.join(".", "servo-tidy.toml")
WPT_MANIFEST_PATH = wpt_path("include.ini")
# Import wptmanifest only when we do have wpt in tree, i.e. we're not
# inside a Firefox checkout.
if os.path.isfile(WPT_MANIFEST_PATH):
sys.path.append(wpt_path("web-platform-tests", "tools", "wptrunner", "wptrunner"))
from wptmanifest import parser, node
# Default configs
config = {
"skip-check-length": False,
@@ -1166,7 +1169,10 @@ def scan(only_changed_files=False, progress=True, stylo=False):
# check config file for errors
config_errors = check_config_file(CONFIG_FILE_PATH)
# check ini directories exist
manifest_errors = check_manifest_dirs(WPT_MANIFEST_PATH)
if os.path.isfile(WPT_MANIFEST_PATH):
manifest_errors = check_manifest_dirs(WPT_MANIFEST_PATH)
else:
manifest_errors = ()
# check directories contain expected files
directory_errors = check_directory_files(config['check_ext'])
# standard checks