Skip to content

Commit d4c2de9

Browse files
committed
toolchain: switch to the minimal rustup profile and allow configuring it
1 parent 4d1332d commit d4c2de9

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## Unreleased
77

8+
### Added
9+
10+
- New method `WorkspaceBuilder::rustup_profile` to configure the rustup profile
11+
used during builds.
12+
813
### Changed
914

15+
- **BREAKING**: The default rustup profile is now `minimal`.
1016
- The directory `target/` inside local crates won't be copied into the build
1117
anymore.
1218
- Symbolic links will be followed instead of copied as links.

src/toolchain.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ impl std::fmt::Display for Toolchain {
171171
fn init_toolchain_from_dist(workspace: &Workspace, toolchain: &str) -> Result<(), Error> {
172172
info!("installing toolchain {}", toolchain);
173173
Command::new(workspace, &RUSTUP)
174-
.args(&["toolchain", "install", toolchain])
174+
.args(&[
175+
"toolchain",
176+
"install",
177+
toolchain,
178+
"--profile",
179+
workspace.rustup_profile(),
180+
])
175181
.run()
176182
.with_context(|_| format!("unable to install toolchain {} via rustup", toolchain))?;
177183

src/tools/rustup.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,15 @@ impl Tool for Rustup {
5656
crate::native::make_executable(installer)?;
5757
}
5858

59-
// TODO(rustup.rs#998): Remove `.no_output_timeout(true)` once rust-docs is no longer a
60-
// mandatory component.
6159
Command::new(workspace, installer.to_string_lossy().as_ref())
6260
.args(&[
6361
"-y",
6462
"--no-modify-path",
6563
"--default-toolchain",
6664
MAIN_TOOLCHAIN_NAME,
65+
"--profile",
66+
workspace.rustup_profile(),
6767
])
68-
.no_output_timeout(None)
6968
.env("RUSTUP_HOME", workspace.rustup_home())
7069
.env("CARGO_HOME", workspace.cargo_home())
7170
.run()

src/workspace.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ static DEFAULT_SANDBOX_IMAGE: &str = "rustops/crates-build-env";
1818
const DEFAULT_COMMAND_TIMEOUT: Option<Duration> = Some(Duration::from_secs(15 * 60));
1919
const DEFAULT_COMMAND_NO_OUTPUT_TIMEOUT: Option<Duration> = None;
2020

21+
static DEFAULT_RUSTUP_PROFILE: &str = "minimal";
22+
2123
/// Builder of a [`Workspace`](struct.Workspace.html).
2224
pub struct WorkspaceBuilder {
2325
user_agent: String,
@@ -28,6 +30,7 @@ pub struct WorkspaceBuilder {
2830
fetch_registry_index_during_builds: bool,
2931
running_inside_docker: bool,
3032
fast_init: bool,
33+
rustup_profile: String,
3134
}
3235

3336
impl WorkspaceBuilder {
@@ -45,6 +48,7 @@ impl WorkspaceBuilder {
4548
fetch_registry_index_during_builds: true,
4649
running_inside_docker: false,
4750
fast_init: false,
51+
rustup_profile: DEFAULT_RUSTUP_PROFILE.into(),
4852
}
4953
}
5054

@@ -125,6 +129,12 @@ impl WorkspaceBuilder {
125129
self
126130
}
127131

132+
/// Name of the rustup profile used when installing toolchains. The default is `minimal`.
133+
pub fn rustup_profile(mut self, profile: &str) -> Self {
134+
self.rustup_profile = profile.into();
135+
self
136+
}
137+
128138
/// Initialize the workspace. This will create all the necessary local files and fetch the rest from the network. It's
129139
/// not unexpected for this method to take minutes to run on slower network connections.
130140
pub fn init(self) -> Result<Workspace, Error> {
@@ -157,6 +167,7 @@ impl WorkspaceBuilder {
157167
command_no_output_timeout: self.command_no_output_timeout,
158168
fetch_registry_index_during_builds: self.fetch_registry_index_during_builds,
159169
current_container: None,
170+
rustup_profile: self.rustup_profile,
160171
}),
161172
};
162173

@@ -179,6 +190,7 @@ struct WorkspaceInner {
179190
command_no_output_timeout: Option<Duration>,
180191
fetch_registry_index_during_builds: bool,
181192
current_container: Option<CurrentContainer>,
193+
rustup_profile: String,
182194
}
183195

184196
/// Directory on the filesystem containing rustwide's state and caches.
@@ -272,6 +284,10 @@ impl Workspace {
272284
self.inner.current_container.as_ref()
273285
}
274286

287+
pub(crate) fn rustup_profile(&self) -> &str {
288+
&self.inner.rustup_profile
289+
}
290+
275291
fn init(&self, fast_init: bool) -> Result<(), Error> {
276292
info!("installing tools required by rustwide");
277293
crate::tools::install(self, fast_init)?;

0 commit comments

Comments
 (0)