diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2017-12-12 22:19:59 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-01-10 18:05:45 +0100 |
commit | 2618e4ed9d15d75efb21802dfbd0788127b63e11 (patch) | |
tree | ffd793df99d304d4d6e2d3bbe6daf36e381ecf00 /python/servo/command_base.py | |
parent | e0f8f09c0561be31cfb02c008f31fefe6fab48dc (diff) | |
download | servo-2618e4ed9d15d75efb21802dfbd0788127b63e11.tar.gz servo-2618e4ed9d15d75efb21802dfbd0788127b63e11.zip |
Use rustup "proxies" instead of `rustup run`
To make sure we’re indeed running rustup’s proxy
rather than some other `cargo` for example,
run the `rustup` executable with a different `argv[0]`.
Diffstat (limited to 'python/servo/command_base.py')
-rw-r--r-- | python/servo/command_base.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py index c7d6f51d1f9..dd1f6fdc885 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -14,7 +14,6 @@ import itertools import locale import os from os import path -import re import contextlib import subprocess from subprocess import PIPE @@ -137,7 +136,8 @@ def call(*args, **kwargs): kwargs['env'] = normalize_env(kwargs['env']) # we have to use shell=True in order to get PATH handling # when looking for the binary on Windows - return subprocess.call(*args, shell=sys.platform == 'win32', **kwargs) + kwargs.setdefault("shell", sys.platform == "win32") + return subprocess.call(*args, **kwargs) def check_output(*args, **kwargs): @@ -149,7 +149,8 @@ def check_output(*args, **kwargs): kwargs['env'] = normalize_env(kwargs['env']) # we have to use shell=True in order to get PATH handling # when looking for the binary on Windows - return subprocess.check_output(*args, shell=sys.platform == 'win32', **kwargs) + kwargs.setdefault("shell", sys.platform == "win32") + return subprocess.check_output(*args, **kwargs) def check_call(*args, **kwargs): @@ -165,7 +166,8 @@ def check_call(*args, **kwargs): print(' '.join(args[0])) # we have to use shell=True in order to get PATH handling # when looking for the binary on Windows - proc = subprocess.Popen(*args, shell=sys.platform == 'win32', **kwargs) + kwargs.setdefault("shell", sys.platform == "win32") + proc = subprocess.Popen(*args, **kwargs) status = None # Leave it to the subprocess to handle Ctrl+C. If it terminates as # a result of Ctrl+C, proc.wait() will return a status code, and, @@ -322,25 +324,22 @@ class CommandBase(object): return self._default_toolchain def call_rustup_run(self, args, **kwargs): + args[0] += BIN_SUFFIX if self.config["tools"]["use-rustup"]: try: - version_line = subprocess.check_output(["rustup" + BIN_SUFFIX, "--version"]) + kwargs.setdefault("env", {})["RUSTUP_TOOLCHAIN"] = self.toolchain() + return call(args, executable="rustup" + BIN_SUFFIX, shell=False, **kwargs) except OSError as e: if e.errno == NO_SUCH_FILE_OR_DIRECTORY: + print repr(e) + print print "It looks like rustup is not installed. See instructions at " \ "https://github.com/servo/servo/#setting-up-your-environment" print return 1 raise - version = tuple(map(int, re.match("rustup (\d+)\.(\d+)\.(\d+)", version_line).groups())) - if version < (1, 8, 0): - print "rustup is at version %s.%s.%s, Servo requires 1.8.0 or more recent." % version - print "Try running 'rustup self update'." - return 1 - args = ["rustup" + BIN_SUFFIX, "run", "--install", self.toolchain()] + args else: - args[0] += BIN_SUFFIX - return call(args, **kwargs) + return call(args, **kwargs) def get_top_dir(self): return self.context.topdir |