diff options
author | Vladimir Vukicevic <vladimir@pobox.com> | 2015-09-22 15:09:54 -0400 |
---|---|---|
committer | Lars Bergstrom <lars@lars.com> | 2016-01-20 08:38:24 -0600 |
commit | ee863fde5993f0f7bae2acf06e1fae21bd459c88 (patch) | |
tree | 452fbf59927fee6339756c973cf8ca3074211463 /python/servo/command_base.py | |
parent | 77aea599c76278d7efd92efbdae8392d7e93a832 (diff) | |
download | servo-ee863fde5993f0f7bae2acf06e1fae21bd459c88.tar.gz servo-ee863fde5993f0f7bae2acf06e1fae21bd459c88.zip |
win32: mach and build command fixes
- Add SERVO_USE_NIGHTLY_RUST env var to use the latest rust/cargo nightly snapshot
- Fix up looking for cargo binary (in cargo/bin/cargo, not bin/cargo)
- Fix up win32 executable checking (use .exe suffix)
- fix up win32 PATH handling (subprocess must use shell=True for PATH change to be honored)
Diffstat (limited to 'python/servo/command_base.py')
-rw-r--r-- | python/servo/command_base.py | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py index b2ff5094e33..83d3a77c0dd 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -16,6 +16,10 @@ import toml from mach.registrar import Registrar +BIN_SUFFIX = "" +if sys.platform == "win32": + BIN_SUFFIX = ".exe" + @contextlib.contextmanager def cd(new_path): @@ -36,6 +40,8 @@ def host_triple(): os_type = "apple-darwin" elif os_type == "android": os_type = "linux-androideabi" + elif os_type.startswith("mingw64_nt-"): + os_type = "pc-windows-gnu" else: os_type = "unknown" @@ -52,6 +58,37 @@ def host_triple(): return "%s-%s" % (cpu_type, os_type) +def use_nightly_rust(): + envvar = os.environ.get("SERVO_USE_NIGHTLY_RUST") + if envvar: + return envvar != "0" + return False + + +def call(*args, **kwargs): + """Wrap `subprocess.call`, printing the command if verbose=True.""" + verbose = kwargs.pop('verbose', False) + if verbose: + print(' '.join(args[0])) + if sys.platform == "win32": + # we have to use shell=True in order to get PATH handling + # when looking for the binary on Windows + return subprocess.call(*args, shell=True, **kwargs) + return subprocess.call(*args, **kwargs) + + +def check_call(*args, **kwargs): + """Wrap `subprocess.check_call`, printing the command if verbose=True.""" + verbose = kwargs.pop('verbose', False) + if verbose: + print(' '.join(args[0])) + if sys.platform == "win32": + # we have to use shell=True in order to get PATH handling + # when looking for the binary on Windows + return subprocess.check_call(*args, shell=True, **kwargs) + return subprocess.check_call(*args, **kwargs) + + class CommandBase(object): """Base class for mach command providers. @@ -333,13 +370,13 @@ class CommandBase(object): if not self.config["tools"]["system-rust"] and \ not path.exists(path.join( - self.config["tools"]["rust-root"], "rustc", "bin", "rustc")): + self.config["tools"]["rust-root"], "rustc", "bin", "rustc" + BIN_SUFFIX)): print("looking for rustc at %s" % path.join( - self.config["tools"]["rust-root"], "rustc", "bin", "rustc")) + self.config["tools"]["rust-root"], "rustc", "bin", "rustc" + BIN_SUFFIX)) Registrar.dispatch("bootstrap-rust", context=self.context) if not self.config["tools"]["system-cargo"] and \ not path.exists(path.join( - self.config["tools"]["cargo-root"], "cargo", "bin", "cargo")): + self.config["tools"]["cargo-root"], "cargo", "bin", "cargo" + BIN_SUFFIX)): Registrar.dispatch("bootstrap-cargo", context=self.context) self.context.bootstrapped = True |