-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Stabilize build-dir layout v2
#16807
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
Changes from all commits
7905866
725634b
bf1af02
e49ac71
8843e46
ffa1982
4d21315
72def1c
668039d
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 |
|---|---|---|
|
|
@@ -814,7 +814,7 @@ macro_rules! unstable_cli_options { | |
| /// Cargo, like `rustc`, accepts a suite of `-Z` flags which are intended for | ||
| /// gating unstable functionality to Cargo. These flags are only available on | ||
| /// the nightly channel of Cargo. | ||
| #[derive(Default, Debug, Deserialize)] | ||
| #[derive(Debug, Deserialize)] | ||
| #[serde(default, rename_all = "kebab-case")] | ||
| pub struct CliUnstable { | ||
| $( | ||
|
|
@@ -852,6 +852,70 @@ macro_rules! unstable_cli_options { | |
| } | ||
| } | ||
|
|
||
| // TODO: Move this back to derive(Default) once `build_dir_new_layout` is stabilized and the old | ||
|
weihanglo marked this conversation as resolved.
|
||
| // layout has been removed. | ||
| impl Default for CliUnstable { | ||
|
Comment on lines
+855
to
+857
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. Why not put the hack in My general recommendation is to be as surgical as possible with hacks/todos
Member
Author
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. ehh yeah its a bit tricky to spot the places it gets used.
My thought is that while this chunk is pretty ugly, its less invasive than trying to modify all of the functions that could potentially call |
||
| fn default() -> Self { | ||
| Self { | ||
| build_dir_new_layout: !is_new_build_dir_layout_opt_out(), | ||
|
|
||
| allow_features: Default::default(), | ||
| print_im_a_teapot: Default::default(), | ||
| advanced_env: Default::default(), | ||
| any_build_script_metadata: Default::default(), | ||
| asymmetric_token: Default::default(), | ||
| avoid_dev_deps: Default::default(), | ||
| binary_dep_depinfo: Default::default(), | ||
| bindeps: Default::default(), | ||
| build_analysis: Default::default(), | ||
| build_std: Default::default(), | ||
| build_std_features: Default::default(), | ||
| cargo_lints: Default::default(), | ||
| checksum_freshness: Default::default(), | ||
| codegen_backend: Default::default(), | ||
| direct_minimal_versions: Default::default(), | ||
| dual_proc_macros: Default::default(), | ||
| feature_unification: Default::default(), | ||
| features: Default::default(), | ||
| fine_grain_locking: Default::default(), | ||
| fix_edition: Default::default(), | ||
| gc: Default::default(), | ||
| git: Default::default(), | ||
| gitoxide: Default::default(), | ||
| hint_msrv: Default::default(), | ||
| host_config: Default::default(), | ||
| json_target_spec: Default::default(), | ||
| min_publish_age: Default::default(), | ||
| minimal_versions: Default::default(), | ||
| msrv_policy: Default::default(), | ||
| mtime_on_use: Default::default(), | ||
| next_lockfile_bump: Default::default(), | ||
| no_embed_metadata: Default::default(), | ||
| no_index_update: Default::default(), | ||
| panic_abort_tests: Default::default(), | ||
| panic_immediate_abort: Default::default(), | ||
| profile_hint_mostly_unused: Default::default(), | ||
| profile_rustflags: Default::default(), | ||
| public_dependency: Default::default(), | ||
| publish_timeout: Default::default(), | ||
| root_dir: Default::default(), | ||
| rustc_unicode: Default::default(), | ||
| rustdoc_depinfo: Default::default(), | ||
| rustdoc_map: Default::default(), | ||
| rustdoc_mergeable_info: Default::default(), | ||
| rustdoc_scrape_examples: Default::default(), | ||
| sbom: Default::default(), | ||
| script: Default::default(), | ||
| section_timings: Default::default(), | ||
| separate_nightlies: Default::default(), | ||
| skip_rustdoc_fingerprint: Default::default(), | ||
| target_applies_to_host: Default::default(), | ||
| trim_paths: Default::default(), | ||
| unstable_options: Default::default(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| unstable_cli_options!( | ||
| // Permanently unstable features: | ||
| allow_features: Option<AllowFeatures> = ("Allow *only* the listed unstable features"), | ||
|
|
@@ -1005,6 +1069,8 @@ const STABILIZED_LOCKFILE_PATH: &str = "The `lockfile-path` config key is now al | |
|
|
||
| const STABILIZED_WARNINGS: &str = "The `build.warnings` config key is now always available"; | ||
|
|
||
| const STABILIZED_BUILD_DIR_NEW_LAYOUT: &str = "build.build-dir-new-layout is now always enabled."; | ||
|
|
||
| fn deserialize_comma_separated_list<'de, D>( | ||
| deserializer: D, | ||
| ) -> Result<Option<Vec<String>>, D::Error> | ||
|
|
@@ -1270,6 +1336,12 @@ impl CliUnstable { | |
| self.gitoxide = GitoxideFeatures::safe().into(); | ||
| } | ||
|
|
||
| // NOTE: We set this before `implicitly_enable_features_if_needed` as `-Zfine-grain-locking` | ||
| // must use the new layout so that takes priority. | ||
| if is_new_build_dir_layout_opt_out() { | ||
| self.build_dir_new_layout = false; | ||
| } | ||
|
|
||
| self.implicitly_enable_features_if_needed(); | ||
|
|
||
| Ok(warnings) | ||
|
|
@@ -1395,6 +1467,7 @@ impl CliUnstable { | |
| "config-include" => stabilized_warn(k, "1.93", STABILIZED_CONFIG_INCLUDE), | ||
| "lockfile-path" => stabilized_warn(k, "1.97", STABILIZED_LOCKFILE_PATH), | ||
| "warnings" => stabilized_warn(k, "1.97", STABILIZED_WARNINGS), | ||
| "build-dir-new-layout" => stabilized_warn(k, "1.99", STABILIZED_BUILD_DIR_NEW_LAYOUT), | ||
|
|
||
| // Unstable features | ||
| // Sorted alphabetically: | ||
|
|
@@ -1405,7 +1478,6 @@ impl CliUnstable { | |
| "binary-dep-depinfo" => self.binary_dep_depinfo = parse_empty(k, v)?, | ||
| "bindeps" => self.bindeps = parse_empty(k, v)?, | ||
| "build-analysis" => self.build_analysis = parse_empty(k, v)?, | ||
| "build-dir-new-layout" => self.build_dir_new_layout = parse_empty(k, v)?, | ||
| "build-std" => self.build_std = Some(parse_list(v)), | ||
| "build-std-features" => self.build_std_features = Some(parse_list(v)), | ||
| "cargo-lints" => self.cargo_lints = parse_empty(k, v)?, | ||
|
|
@@ -1592,6 +1664,14 @@ fn cargo_use_gitoxide_instead_of_git2() -> bool { | |
| std::env::var_os("__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2").map_or(false, |value| value == "1") | ||
| } | ||
|
|
||
| #[expect( | ||
| clippy::disallowed_methods, | ||
| reason = "Temporary opt out that is not part of the public interface" | ||
| )] | ||
| fn is_new_build_dir_layout_opt_out() -> bool { | ||
| std::env::var("__CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT").as_deref() == Ok("1") | ||
| } | ||
|
|
||
| /// Generate a link to Cargo documentation for the current release channel | ||
| /// `path` is the URL component after `https://doc.rust-lang.org/{channel}/cargo/` | ||
| pub fn cargo_docs_link(path: &str) -> String { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.