mach + rustup: use the minimal profile and install rustc-dev

This commit is contained in:
Simon Sapin 2020-01-02 15:27:25 +01:00
parent 6f70a9c1de
commit 1110cac184
5 changed files with 15 additions and 26 deletions

View file

@ -181,9 +181,6 @@ def linux_tidy_unit_untrusted():
.with_dockerfile(dockerfile_path("build")) .with_dockerfile(dockerfile_path("build"))
.with_env(**build_env, **unix_build_env, **linux_build_env) .with_env(**build_env, **unix_build_env, **linux_build_env)
.with_repo_bundle() .with_repo_bundle()
.with_script("rustup set profile minimal")
# required by components/script_plugins:
.with_script("rustup component add rustc-dev")
.with_script(""" .with_script("""
./mach test-tidy --no-progress --all ./mach test-tidy --no-progress --all
./mach test-tidy --no-progress --self-test ./mach test-tidy --no-progress --self-test
@ -304,11 +301,10 @@ def with_rust_nightly():
modified_build_env["RUSTFLAGS"] = " ".join(flags) modified_build_env["RUSTFLAGS"] = " ".join(flags)
return ( return (
linux_build_task("with Rust Nightly", build_env=modified_build_env, install_rustc_dev=False) linux_build_task("with Rust Nightly", build_env=modified_build_env)
.with_treeherder("Linux x64", "RustNightly") .with_treeherder("Linux x64", "RustNightly")
.with_script(""" .with_script("""
echo "nightly" > rust-toolchain echo "nightly" > rust-toolchain
rustup component add rustc-dev
./mach build --dev ./mach build --dev
./mach test-unit ./mach test-unit
""") """)
@ -850,7 +846,7 @@ def macos_task(name):
) )
def linux_build_task(name, *, build_env=build_env, install_rustc_dev=True): def linux_build_task(name, *, build_env=build_env):
task = ( task = (
linux_task(name) linux_task(name)
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/caches # https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/caches
@ -867,14 +863,8 @@ def linux_build_task(name, *, build_env=build_env, install_rustc_dev=True):
.with_dockerfile(dockerfile_path("build")) .with_dockerfile(dockerfile_path("build"))
.with_env(**build_env, **unix_build_env, **linux_build_env) .with_env(**build_env, **unix_build_env, **linux_build_env)
.with_repo_bundle() .with_repo_bundle()
.with_script(""" .with_script("./mach bootstrap-gstreamer")
rustup set profile minimal
./mach bootstrap-gstreamer
""")
) )
if install_rustc_dev:
# required by components/script_plugins:
task = task.with_script("rustup component add rustc-dev")
return task return task
@ -920,9 +910,6 @@ def windows_build_task(name, package=True, arch="x86_64"):
path="python3", path="python3",
) )
.with_rustup() .with_rustup()
.with_script("rustup set profile minimal")
# required by components/script_plugins:
.with_script("rustup component add rustc-dev")
) )
if arch in hashes["non-devel"] and arch in hashes["devel"]: if arch in hashes["non-devel"] and arch in hashes["devel"]:
task = ( task = (
@ -968,11 +955,6 @@ def macos_build_task(name):
.with_repo_bundle(alternate_object_dir="/var/cache/servo.git/objects") .with_repo_bundle(alternate_object_dir="/var/cache/servo.git/objects")
.with_python2() .with_python2()
.with_rustup() .with_rustup()
# Since macOS workers are long-lived and ~/.rustup kept across tasks:
.with_script("rustup self update")
.with_script("rustup set profile minimal")
# required by components/script_plugins:
.with_script("rustup component add rustc-dev")
.with_index_and_artifacts_expire_in(build_artifacts_expire_in) .with_index_and_artifacts_expire_in(build_artifacts_expire_in)
# Debugging for surprising generic-worker behaviour # Debugging for surprising generic-worker behaviour
.with_early_script("ls") .with_early_script("ls")

View file

@ -693,6 +693,7 @@ class MacOsGenericWorkerTask(UnixTaskMixin, GenericWorkerTask):
return self.with_early_script(""" return self.with_early_script("""
export PATH="$HOME/.cargo/bin:$PATH" export PATH="$HOME/.cargo/bin:$PATH"
which rustup || curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y which rustup || curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y
rustup self update
""") """)

View file

@ -44,7 +44,8 @@ RUN \
# #
&& \ && \
# #
# # Install the version of rustup that is current when this Docker image is being built:
# We want at least 1.21 (increment in this comment to force an image rebuild).
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none --profile=minimal -y && \ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none --profile=minimal -y && \
# #
# #

View file

@ -1009,7 +1009,12 @@ install them, let us know by filing a bug!")
toolchain = self.rust_toolchain() toolchain = self.rust_toolchain()
if toolchain not in check_output(["rustup", "toolchain", "list"]): if toolchain not in check_output(["rustup", "toolchain", "list"]):
check_call(["rustup", "toolchain", "install", toolchain]) check_call(["rustup", "toolchain", "install", "--profile", "minimal", toolchain])
if "rustc-dev" not in check_output(
["rustup", "component", "list", "--installed", "--toolchain", toolchain]
):
check_call(["rustup", "component", "add", "--toolchain", toolchain, "rustc-dev"])
if target and "uwp" not in target and target not in check_output( if target and "uwp" not in target and target not in check_output(
["rustup", "target", "list", "--installed", "--toolchain", toolchain] ["rustup", "target", "list", "--installed", "--toolchain", toolchain]
@ -1029,7 +1034,7 @@ install them, let us know by filing a bug!")
return 1 return 1
raise raise
version = tuple(map(int, re.match(b"rustup (\d+)\.(\d+)\.(\d+)", version_line).groups())) version = tuple(map(int, re.match(b"rustup (\d+)\.(\d+)\.(\d+)", version_line).groups()))
if version < (1, 11, 0): if version < (1, 21, 0):
print("rustup is at version %s.%s.%s, Servo requires 1.11.0 or more recent." % version) print("rustup is at version %s.%s.%s, Servo requires 1.11.0 or more recent." % version)
print("Try running 'rustup self update'.") print("Try running 'rustup self update'.")
return 1 return 1

View file

@ -24,7 +24,7 @@ from mach.decorators import (
Command, Command,
) )
from servo.command_base import CommandBase, cd, call, BIN_SUFFIX from servo.command_base import CommandBase, cd, call
from servo.build_commands import notify_build_done from servo.build_commands import notify_build_done
from servo.util import get_static_rust_lang_org_dist, get_urlopen_kwargs from servo.util import get_static_rust_lang_org_dist, get_urlopen_kwargs
@ -213,7 +213,7 @@ class MachCommands(CommandBase):
filename = path.join(self.context.topdir, "rust-toolchain") filename = path.join(self.context.topdir, "rust-toolchain")
with open(filename, "w") as f: with open(filename, "w") as f:
f.write(toolchain + "\n") f.write(toolchain + "\n")
return call(["rustup" + BIN_SUFFIX, "component", "add", "rustc-dev"]) self.ensure_bootstrapped()
@Command('fetch', @Command('fetch',
description='Fetch Rust, Cargo and Cargo dependencies', description='Fetch Rust, Cargo and Cargo dependencies',