Skip to content
Permalink
Browse files

mach: check rustup version in `ensure_bootstrapped()`

  • Loading branch information
SimonSapin committed Jan 2, 2020
1 parent d4da65d commit 855601ebb47282c1e3a2389979b7cae8247b3f69
Showing with 20 additions and 16 deletions.
  1. +20 −16 python/servo/command_base.py
@@ -360,20 +360,7 @@ def rust_toolchain(self):

def call_rustup_run(self, args, **kwargs):
if self.config["tools"]["use-rustup"]:
try:
version_line = subprocess.check_output(["rustup" + BIN_SUFFIX, "--version"])
except OSError as e:
if e.errno == NO_SUCH_FILE_OR_DIRECTORY:
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(b"rustup (\d+)\.(\d+)\.(\d+)", version_line).groups()))
if version < (1, 11, 0):
print("rustup is at version %s.%s.%s, Servo requires 1.11.0 or more recent." % version)
print("Try running 'rustup self update'.")
return 1
self.ensure_rustup_version()
args = ["rustup" + BIN_SUFFIX, "run", "--install", self.rust_toolchain()] + args
else:
args[0] += BIN_SUFFIX
@@ -1017,8 +1004,9 @@ def ensure_bootstrapped(self, target=None):
if "msvc" in target_platform:
Registrar.dispatch("bootstrap", context=self.context)

if target:
if self.config["tools"]["use-rustup"] and not "uwp" in target:
if self.config["tools"]["use-rustup"]:
self.ensure_rustup_version()
if target and "uwp" not in target:
# 'rustup target add' fails if the toolchain is not installed at all.
self.call_rustup_run(["rustc", "--version"])

@@ -1028,6 +1016,22 @@ def ensure_bootstrapped(self, target=None):

self.context.bootstrapped = True

def ensure_rustup_version(self):
try:
version_line = subprocess.check_output(["rustup" + BIN_SUFFIX, "--version"])
except OSError as e:
if e.errno == NO_SUCH_FILE_OR_DIRECTORY:
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(b"rustup (\d+)\.(\d+)\.(\d+)", version_line).groups()))
if version < (1, 11, 0):
print("rustup is at version %s.%s.%s, Servo requires 1.11.0 or more recent." % version)
print("Try running 'rustup self update'.")
return 1

def ensure_clobbered(self, target_dir=None):
if target_dir is None:
target_dir = self.get_target_dir()

0 comments on commit 855601e

Please sign in to comment.
You can’t perform that action at this time.