diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-08-01 16:44:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-01 14:44:57 +0000 |
commit | fef332f38552ae8af83cf69993dd6aabdebffd6a (patch) | |
tree | 577bca564e78c7b8a2e02e7e9b3431518533edae /python/servo/devenv_commands.py | |
parent | 4061d13ba6d06f775e1a4a0fe50662ea3b16d2fa (diff) | |
download | servo-fef332f38552ae8af83cf69993dd6aabdebffd6a.tar.gz servo-fef332f38552ae8af83cf69993dd6aabdebffd6a.zip |
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.
Diffstat (limited to 'python/servo/devenv_commands.py')
-rw-r--r-- | python/servo/devenv_commands.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index b09086a8ed4..9e7527d6fd8 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -97,7 +97,7 @@ class MachCommands(CommandBase): self.ensure_bootstrapped() with cd(self.context.topdir): - self.call_rustup_run(["cargo", "update"] + params, env=self.build_env()) + call(["cargo", "update"] + params, env=self.build_env()) @Command('rustc', description='Run the Rust compiler', @@ -110,7 +110,7 @@ class MachCommands(CommandBase): params = [] self.ensure_bootstrapped() - return self.call_rustup_run(["rustc"] + params, env=self.build_env()) + return call(["rustc"] + params, env=self.build_env()) @Command('cargo-fix', description='Run "cargo fix"', @@ -173,10 +173,16 @@ class MachCommands(CommandBase): def rustup(self): nightly_date = urllib.request.urlopen( "https://static.rust-lang.org/dist/channel-rust-nightly-date.txt").read() - toolchain = b"nightly-" + nightly_date - filename = path.join(self.context.topdir, "rust-toolchain") - with open(filename, "wb") as f: - f.write(toolchain + b"\n") + new_toolchain = f"nightly-{nightly_date.decode('utf-8')}" + old_toolchain = self.rust_toolchain() + + filename = path.join(self.context.topdir, "rust-toolchain.toml") + with open(filename, "r", encoding="utf-8") as file: + contents = file.read() + contents = contents.replace(old_toolchain, new_toolchain) + with open(filename, "w", encoding="utf-8") as file: + file.write(contents) + self.ensure_bootstrapped() @Command('fetch', @@ -184,9 +190,7 @@ class MachCommands(CommandBase): category='devenv') def fetch(self): self.ensure_bootstrapped() - - with cd(self.context.topdir): - return self.call_rustup_run(["cargo", "fetch"], env=self.build_env()) + return call(["cargo", "fetch"], env=self.build_env()) @Command('ndk-stack', description='Invoke the ndk-stack tool with the expected symbol paths', |