mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
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)
This commit is contained in:
parent
77aea599c7
commit
ee863fde59
6 changed files with 74 additions and 49 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue