diff options
| author | onur-ozkan <work@onurozkan.dev> | 2024-07-23 18:02:01 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2024-07-23 18:02:01 +0300 |
| commit | d4f3673a54fecf005920ef2fffd5e1f78cc87b85 (patch) | |
| tree | 7edfb75c8a4a4732d8e4d0482dd2b8bd1ef20212 | |
| parent | 8c3a94a1c79c67924558a4adf7fb6d98f5f0f741 (diff) | |
| download | rust-d4f3673a54fecf005920ef2fffd5e1f78cc87b85.tar.gz rust-d4f3673a54fecf005920ef2fffd5e1f78cc87b85.zip | |
make it possible to disable download-rustc if it's incompatible
Primarily needed by CI runners to avoid handling download-rustc incompatible options one by one on shell scripts. Signed-off-by: onur-ozkan <work@onurozkan.dev>
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index f96633b059a..a78a213f530 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1570,11 +1570,22 @@ impl Config { let mut is_user_configured_rust_channel = false; if let Some(rust) = toml.rust { - config.download_rustc_commit = - config.download_ci_rustc_commit(rust.download_rustc.clone()); - - if config.download_rustc_commit.is_some() { - check_incompatible_options_for_ci_rustc(&rust); + if let Some(commit) = config.download_ci_rustc_commit(rust.download_rustc.clone()) { + // Primarily used by CI runners to avoid handling download-rustc incompatible + // options one by one on shell scripts. + let disable_ci_rustc_if_incompatible = + env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE") + .is_some_and(|s| s == "1" || s == "true"); + + if let Err(e) = check_incompatible_options_for_ci_rustc(&rust) { + if disable_ci_rustc_if_incompatible { + config.download_rustc_commit = None; + } else { + panic!("{}", e); + } + } else { + config.download_rustc_commit = Some(commit); + } } let Rust { @@ -2614,14 +2625,15 @@ impl Config { /// Checks the CI rustc incompatible options by destructuring the `Rust` instance /// and makes sure that no rust options from config.toml are missed. -fn check_incompatible_options_for_ci_rustc(rust: &Rust) { +fn check_incompatible_options_for_ci_rustc(rust: &Rust) -> Result<(), String> { macro_rules! err { ($name:expr) => { - assert!( - $name.is_none(), - "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.", - stringify!($name).replace("_", "-") - ); + if $name.is_some() { + return Err(format!( + "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.", + stringify!($name).replace("_", "-") + )); + } }; } @@ -2717,6 +2729,8 @@ fn check_incompatible_options_for_ci_rustc(rust: &Rust) { warn!(channel); warn!(description); warn!(incremental); + + Ok(()) } fn set<T>(field: &mut T, val: Option<T>) { |
