Make rustup a requirement and switch to rust-toolchain.toml (#30056)

This change makes rustup a requirement for building Servo with `./mach`
and switches to the newer `rust-toolchain.toml` format. The goal here is
to make mach builds more similar to non-mach builds.

- The new format allows listing the required components, removing some of
  the complexity from our mach scripts.
- This means we must raise the required version of rustup to 1.23. The
  current version is 1.26.
- We no longer wrap every call to cargo and rustc in "rustup run" calls
  as both cargo and rustc will take care of installing and using all
  necessary components specified in `rust-toolchain.toml` when run
  inside the project directory.
This commit is contained in:
Martin Robinson 2023-08-01 16:44:57 +02:00 committed by GitHub
parent 4061d13ba6
commit fef332f385
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 88 deletions

View file

@ -263,14 +263,6 @@ class MachCommands(CommandBase):
"tests/wpt/mozilla/.")
return 0
def install_rustfmt(self):
self.ensure_bootstrapped()
with open(os.devnull, "w") as devnull:
if self.call_rustup_run(["cargo", "fmt", "--version", "-q"],
stderr=devnull) != 0:
# Rustfmt is not installed. Install:
self.call_rustup_run(["rustup", "component", "add", "rustfmt-preview"])
@Command('test-tidy',
description='Run the source code tidiness check',
category='testing')
@ -289,8 +281,7 @@ class MachCommands(CommandBase):
else:
manifest_dirty = wpt.manifestupdate.update(check_clean=True)
tidy_failed = tidy.scan(not all_files, not no_progress, stylo=stylo, no_wpt=no_wpt)
self.install_rustfmt()
rustfmt_failed = self.call_rustup_run(["cargo", "fmt", "--", "--check"])
rustfmt_failed = call(["cargo", "fmt", "--", "--check"])
if rustfmt_failed:
print("Run `./mach fmt` to fix the formatting")
@ -404,8 +395,7 @@ class MachCommands(CommandBase):
description='Format the Rust and CPP source files with rustfmt',
category='testing')
def format_code(self):
self.install_rustfmt()
return self.call_rustup_run(["cargo", "fmt"])
return call(["cargo", "fmt"])
@Command('update-wpt',
description='Update the web platform tests',