Skip to content

Commit da619eb

Browse files
committed
feat(install): flag to DistOptions and try_update_from_dist_
1 parent 323bf9f commit da619eb

File tree

6 files changed

+46
-13
lines changed

6 files changed

+46
-13
lines changed

src/cli/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub(crate) async fn update_all_channels(
218218
let profile = cfg.get_profile()?;
219219
let mut toolchains = Vec::new();
220220
for (desc, distributable) in cfg.list_channels()? {
221-
let options = DistOptions::new(&[], &[], &desc, profile, force_update, cfg)?
221+
let options = DistOptions::new(&[], &[], &desc, profile, force_update, false, cfg)?
222222
.for_update(&distributable, false);
223223
let result = InstallMethod::Dist(options).install().await;
224224

src/cli/rustup_mode.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ async fn update(
966966
&desc,
967967
cfg.get_profile()?,
968968
opts.force,
969+
false,
969970
cfg,
970971
)?;
971972

@@ -1516,7 +1517,8 @@ async fn override_add(
15161517
Err(e @ RustupError::ToolchainNotInstalled { .. }) => match &toolchain_name {
15171518
ToolchainName::Custom(_) => Err(e)?,
15181519
ToolchainName::Official(desc) => {
1519-
let options = DistOptions::new(&[], &[], desc, cfg.get_profile()?, false, cfg)?;
1520+
let options =
1521+
DistOptions::new(&[], &[], desc, cfg.get_profile()?, false, false, cfg)?;
15201522
let status = DistributableToolchain::install(options).await?.0;
15211523
writeln!(cfg.process.stdout().lock())?;
15221524
common::show_channel_update(

src/cli/self_update.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,15 @@ async fn maybe_install_rust(opts: InstallOpts<'_>, cfg: &mut Cfg<'_>) -> Result<
999999
let (components, targets) = (opts.components, opts.targets);
10001000
let toolchain = opts.install(cfg)?;
10011001
if let Some(desc) = &toolchain {
1002-
let options = DistOptions::new(components, targets, desc, cfg.get_profile()?, true, cfg)?;
1002+
let options = DistOptions::new(
1003+
components,
1004+
targets,
1005+
desc,
1006+
cfg.get_profile()?,
1007+
true,
1008+
false,
1009+
cfg,
1010+
)?;
10031011
let status = if Toolchain::exists(cfg, &desc.into())? {
10041012
warn!("Updating existing toolchain, profile choice will be ignored");
10051013
// If we have a partial install we might not be able to read content here. We could:

src/config.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct ToolchainSection {
5656
components: Option<Vec<String>>,
5757
targets: Option<Vec<String>>,
5858
profile: Option<String>,
59+
skip_std: Option<bool>,
5960
}
6061

6162
impl ToolchainSection {
@@ -64,6 +65,7 @@ impl ToolchainSection {
6465
&& self.components.is_none()
6566
&& self.targets.is_none()
6667
&& self.path.is_none()
68+
&& self.skip_std.is_none()
6769
}
6870
}
6971

@@ -180,16 +182,18 @@ impl OverrideCfg {
180182
ToolchainName::Official(desc) => {
181183
let components = file.toolchain.components.unwrap_or_default();
182184
let targets = file.toolchain.targets.unwrap_or_default();
185+
let profile = file
186+
.toolchain
187+
.profile
188+
.as_deref()
189+
.map(Profile::from_str)
190+
.transpose()?;
191+
183192
Self::Official {
184193
toolchain: desc,
185194
components,
186195
targets,
187-
profile: file
188-
.toolchain
189-
.profile
190-
.as_deref()
191-
.map(Profile::from_str)
192-
.transpose()?,
196+
profile,
193197
}
194198
}
195199
ToolchainName::Custom(name) => Self::Custom(name),
@@ -798,6 +802,7 @@ impl<'a> Cfg<'a> {
798802
None => self.get_profile()?,
799803
},
800804
false,
805+
false,
801806
self,
802807
)?;
803808

@@ -1030,6 +1035,7 @@ mod tests {
10301035
components: None,
10311036
targets: None,
10321037
profile: None,
1038+
skip_std,
10331039
}
10341040
}
10351041
);

src/dist/mod.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,8 @@ pub(crate) struct DistOptions<'cfg, 'a> {
900900
components: &'a [&'a str],
901901
/// Extra targets to install from dist
902902
targets: &'a [&'a str],
903+
/// Flag to skip installation of rust-std
904+
pub(super) skip_std: bool,
903905
}
904906

905907
impl<'cfg, 'a> DistOptions<'cfg, 'a> {
@@ -909,6 +911,7 @@ impl<'cfg, 'a> DistOptions<'cfg, 'a> {
909911
toolchain: &'a ToolchainDesc,
910912
profile: Profile,
911913
force: bool,
914+
skip_std: bool,
912915
cfg: &'cfg Cfg<'cfg>,
913916
) -> Result<Self> {
914917
Ok(Self {
@@ -923,6 +926,7 @@ impl<'cfg, 'a> DistOptions<'cfg, 'a> {
923926
old_date_version: None,
924927
components,
925928
targets,
929+
skip_std,
926930
})
927931
}
928932

@@ -1034,6 +1038,7 @@ pub(crate) async fn update_from_dist(
10341038
opts.targets,
10351039
&mut fetched,
10361040
opts.cfg,
1041+
opts.skip_std,
10371042
)
10381043
.await;
10391044

@@ -1131,6 +1136,7 @@ async fn try_update_from_dist_(
11311136
targets: &[&str],
11321137
fetched: &mut String,
11331138
cfg: &Cfg<'_>,
1139+
skip_std: bool,
11341140
) -> Result<Option<String>> {
11351141
let toolchain_str = toolchain.to_string();
11361142
let manifestation = Manifestation::open(prefix.clone(), toolchain.target.clone())?;
@@ -1165,6 +1171,10 @@ async fn try_update_from_dist_(
11651171

11661172
let mut all_components: HashSet<Component> = profile_components.into_iter().collect();
11671173

1174+
if skip_std {
1175+
all_components.retain(|c| !c.short_name_in_manifest().starts_with("rust-std"));
1176+
}
1177+
11681178
let rust_package = m.get_package("rust")?;
11691179
let rust_target_package = rust_package.get_target(Some(&toolchain.target.clone()))?;
11701180

@@ -1188,9 +1198,15 @@ async fn try_update_from_dist_(
11881198
all_components.insert(component);
11891199
}
11901200

1191-
for &target in targets {
1192-
let triple = TargetTriple::new(target);
1193-
all_components.insert(Component::new("rust-std".to_string(), Some(triple), false));
1201+
if !skip_std {
1202+
for &target in targets {
1203+
let triple = TargetTriple::new(target);
1204+
all_components.insert(Component::new(
1205+
"rust-std".to_string(),
1206+
Some(triple),
1207+
false,
1208+
));
1209+
}
11941210
}
11951211

11961212
let mut explicit_add_components: Vec<_> = all_components.into_iter().collect();

src/toolchain.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ impl<'a> Toolchain<'a> {
6161
name: ToolchainName::Official(desc),
6262
..
6363
}) if install_if_missing => {
64-
let options = DistOptions::new(&[], &[], &desc, cfg.get_profile()?, true, cfg)?;
64+
let options =
65+
DistOptions::new(&[], &[], &desc, cfg.get_profile()?, true, false, cfg)?;
6566
Ok(DistributableToolchain::install(options).await?.1.toolchain)
6667
}
6768
Err(e) => Err(e.into()),

0 commit comments

Comments
 (0)