Skip to content

Commit

Permalink
mach: check rustup version in ensure_bootstrapped()
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jan 2, 2020
1 parent d4da65d commit 855601e
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions python/servo/command_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"])

Expand All @@ -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()
Expand Down

0 comments on commit 855601e

Please sign in to comment.