-
Notifications
You must be signed in to change notification settings - Fork 987
feat(install): add skip_std flag to allow skipping rust-std installation for custom targets
#4587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ struct ToolchainSection { | |
| components: Option<Vec<String>>, | ||
| targets: Option<Vec<String>>, | ||
| profile: Option<String>, | ||
| skip_std: Option<bool>, | ||
| } | ||
|
|
||
| impl ToolchainSection { | ||
|
|
@@ -64,6 +65,7 @@ impl ToolchainSection { | |
| && self.components.is_none() | ||
| && self.targets.is_none() | ||
| && self.path.is_none() | ||
| && self.skip_std.is_none() | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -137,6 +139,7 @@ enum OverrideCfg { | |
| components: Vec<String>, | ||
| targets: Vec<String>, | ||
| profile: Option<Profile>, | ||
| skip_std: bool, | ||
| }, | ||
| } | ||
|
|
||
|
|
@@ -180,6 +183,7 @@ impl OverrideCfg { | |
| ToolchainName::Official(desc) => { | ||
| let components = file.toolchain.components.unwrap_or_default(); | ||
| let targets = file.toolchain.targets.unwrap_or_default(); | ||
|
|
||
| Self::Official { | ||
| toolchain: desc, | ||
| components, | ||
|
|
@@ -190,6 +194,7 @@ impl OverrideCfg { | |
| .as_deref() | ||
| .map(Profile::from_str) | ||
| .transpose()?, | ||
| skip_std: file.toolchain.skip_std.unwrap_or(false), | ||
| } | ||
| } | ||
| ToolchainName::Custom(name) => Self::Custom(name), | ||
|
|
@@ -213,6 +218,7 @@ impl From<ToolchainName> for OverrideCfg { | |
| components: vec![], | ||
| targets: vec![], | ||
| profile: None, | ||
| skip_std: false, | ||
| }, | ||
| ToolchainName::Custom(name) => Self::Custom(name), | ||
| } | ||
|
|
@@ -737,6 +743,7 @@ impl<'a> Cfg<'a> { | |
| components, | ||
| targets, | ||
| profile, | ||
| skip_std, | ||
| } = override_config | ||
| { | ||
| self.ensure_installed( | ||
|
|
@@ -746,6 +753,7 @@ impl<'a> Cfg<'a> { | |
| profile, | ||
| force_non_host, | ||
| verbose, | ||
| skip_std, | ||
| ) | ||
| .await?; | ||
| } else { | ||
|
|
@@ -755,7 +763,7 @@ impl<'a> Cfg<'a> { | |
| } else if let Some(toolchain) = self.get_default()? { | ||
| let source = ActiveSource::Default; | ||
| if let ToolchainName::Official(desc) = &toolchain { | ||
| self.ensure_installed(desc, vec![], vec![], None, force_non_host, verbose) | ||
| self.ensure_installed(desc, vec![], vec![], None, force_non_host, verbose, false) | ||
| .await?; | ||
| } else { | ||
| Toolchain::with_source(self, toolchain.clone().into(), &source)?; | ||
|
|
@@ -768,6 +776,7 @@ impl<'a> Cfg<'a> { | |
|
|
||
| // Returns a Toolchain matching the given ToolchainDesc, installing it and | ||
| // the given components and targets if they aren't already installed. | ||
| #[allow(clippy::too_many_arguments)] | ||
| #[tracing::instrument(level = "trace", err(level = "trace"), skip_all)] | ||
| pub(crate) async fn ensure_installed( | ||
| &self, | ||
|
|
@@ -777,6 +786,7 @@ impl<'a> Cfg<'a> { | |
| profile: Option<Profile>, | ||
| force_non_host: bool, | ||
| verbose: bool, | ||
| skip_std: bool, | ||
| ) -> Result<(UpdateStatus, Toolchain<'_>)> { | ||
| common::check_non_host_toolchain( | ||
| toolchain.to_string(), | ||
|
|
@@ -800,6 +810,7 @@ impl<'a> Cfg<'a> { | |
| false, | ||
| self, | ||
| )?; | ||
| options.skip_std = skip_std; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry, but this feels very strange. Why are other args passed to the constructor, but this one updated from the outside? @djc What do you think?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I basically suggested this in #4587 (comment)? It seems nicer to me to not bother all callers with supplying a default value. |
||
|
|
||
| let (status, toolchain) = match DistributableToolchain::new(self, toolchain.clone()) { | ||
| Err(RustupError::ToolchainNotInstalled { .. }) => { | ||
|
|
@@ -1030,6 +1041,7 @@ mod tests { | |
| components: None, | ||
| targets: None, | ||
| profile: None, | ||
| skip_std: None, | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -1057,6 +1069,7 @@ profile = "default" | |
| "thumbv2-none-eabi".into() | ||
| ]), | ||
| profile: Some("default".into()), | ||
| skip_std: None, | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -1078,6 +1091,7 @@ channel = "nightly-2020-07-10" | |
| components: None, | ||
| targets: None, | ||
| profile: None, | ||
| skip_std: None, | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -1099,6 +1113,7 @@ path = "foobar" | |
| components: None, | ||
| targets: None, | ||
| profile: None, | ||
| skip_std: None, | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -1121,6 +1136,7 @@ components = [] | |
| components: Some(vec![]), | ||
| targets: None, | ||
| profile: None, | ||
| skip_std: None, | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -1143,6 +1159,7 @@ targets = [] | |
| components: None, | ||
| targets: Some(vec![]), | ||
| profile: None, | ||
| skip_std: None, | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -1164,6 +1181,7 @@ components = [ "rustfmt" ] | |
| components: Some(vec!["rustfmt".into()]), | ||
| targets: None, | ||
| profile: None, | ||
| skip_std: None, | ||
| } | ||
| } | ||
| ); | ||
|
|
@@ -1216,4 +1234,27 @@ channel = nightly | |
| Ok(OverrideFileConfigError::Parsing) | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_toml_toolchain_file_with_skip_std() { | ||
| let contents = r#"[toolchain] | ||
| channel = "nightly-2020-07-10" | ||
| skip_std = true | ||
| "#; | ||
|
|
||
| let result = Cfg::parse_override_file(contents, ParseMode::Both); | ||
| assert_eq!( | ||
| result.unwrap(), | ||
| OverrideFile { | ||
| toolchain: ToolchainSection { | ||
| channel: Some("nightly-2020-07-10".into()), | ||
| path: None, | ||
| components: None, | ||
| targets: None, | ||
| profile: None, | ||
| skip_std: Some(true), | ||
| } | ||
| } | ||
| ); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.