diff options
| -rw-r--r-- | src/bootstrap/src/bin/main.rs | 15 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/format.rs | 11 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/gcc.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/llvm.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder/tests.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 11 | ||||
| -rw-r--r-- | src/bootstrap/src/core/config/flags.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/src/core/download.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/render_tests.rs | 3 |
9 files changed, 28 insertions, 26 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index 88c2d8d9968..443131dc7f3 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -14,7 +14,6 @@ use bootstrap::{ Build, CONFIG_CHANGE_HISTORY, Config, Flags, Subcommand, debug, find_recent_config_change_ids, human_readable_changes, t, }; -use build_helper::ci::CiEnv; #[cfg(feature = "tracing")] use tracing::instrument; @@ -70,12 +69,14 @@ fn main() { } // check_version warnings are not printed during setup, or during CI - let changelog_suggestion = - if matches!(config.cmd, Subcommand::Setup { .. }) || CiEnv::is_ci() || config.dry_run() { - None - } else { - check_version(&config) - }; + let changelog_suggestion = if matches!(config.cmd, Subcommand::Setup { .. }) + || config.is_running_on_ci + || config.dry_run() + { + None + } else { + check_version(&config) + }; // NOTE: Since `./configure` generates a `bootstrap.toml`, distro maintainers will see the // changelog warning, not the `x.py setup` message. diff --git a/src/bootstrap/src/core/build_steps/format.rs b/src/bootstrap/src/core/build_steps/format.rs index 9817e47baa1..840841b0939 100644 --- a/src/bootstrap/src/core/build_steps/format.rs +++ b/src/bootstrap/src/core/build_steps/format.rs @@ -6,7 +6,6 @@ use std::process::Command; use std::sync::Mutex; use std::sync::mpsc::SyncSender; -use build_helper::ci::CiEnv; use build_helper::git::get_git_modified_files; use ignore::WalkBuilder; @@ -104,7 +103,7 @@ struct RustfmtConfig { // Prints output describing a collection of paths, with lines such as "formatted modified file // foo/bar/baz" or "skipped 20 untracked files". -fn print_paths(verb: &str, adjective: Option<&str>, paths: &[String]) { +fn print_paths(build: &Builder<'_>, verb: &str, adjective: Option<&str>, paths: &[String]) { let len = paths.len(); let adjective = if let Some(adjective) = adjective { format!("{adjective} ") } else { String::new() }; @@ -115,7 +114,7 @@ fn print_paths(verb: &str, adjective: Option<&str>, paths: &[String]) { } else { println!("fmt: {verb} {len} {adjective}files"); } - if len > 1000 && !CiEnv::is_ci() { + if len > 1000 && !build.config.is_running_on_ci { println!("hint: if this number seems too high, try running `git fetch origin master`"); } } @@ -135,7 +134,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) { // `--all` is specified or we are in CI. We check all files in CI to avoid bugs in // `get_modified_rs_files` letting regressions slip through; we also care about CI time less // since this is still very fast compared to building the compiler. - let all = all || CiEnv::is_ci(); + let all = all || build.config.is_running_on_ci; let mut builder = ignore::types::TypesBuilder::new(); builder.add_defaults(); @@ -190,7 +189,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) { ) .map(|x| x.to_string()) .collect(); - print_paths("skipped", Some("untracked"), &untracked_paths); + print_paths(build, "skipped", Some("untracked"), &untracked_paths); for untracked_path in untracked_paths { // The leading `/` makes it an exact match against the @@ -319,7 +318,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) { }); let mut paths = formatted_paths.into_inner().unwrap(); paths.sort(); - print_paths(if check { "checked" } else { "formatted" }, adjective, &paths); + print_paths(build, if check { "checked" } else { "formatted" }, adjective, &paths); drop(tx); diff --git a/src/bootstrap/src/core/build_steps/gcc.rs b/src/bootstrap/src/core/build_steps/gcc.rs index 0aa2a332531..b88a5f2bbf1 100644 --- a/src/bootstrap/src/core/build_steps/gcc.rs +++ b/src/bootstrap/src/core/build_steps/gcc.rs @@ -12,8 +12,6 @@ use std::fs; use std::path::{Path, PathBuf}; use std::sync::OnceLock; -use build_helper::ci::CiEnv; - use crate::core::builder::{Builder, Cargo, Kind, RunConfig, ShouldRun, Step}; use crate::core::config::TargetSelection; use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash}; @@ -202,7 +200,7 @@ fn build_gcc(metadata: &Meta, builder: &Builder<'_>, target: TargetSelection) { // source directories as read-only on Linux. // Therefore, as a part of the build in CI, we first copy the whole source directory // to the build directory, and perform the build from there. - let src_dir = if CiEnv::is_ci() { + let src_dir = if builder.config.is_running_on_ci { let src_dir = builder.gcc_out(target).join("src"); if src_dir.exists() { builder.remove_dir(&src_dir); diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 1e3148d631c..0ae5256a18f 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -266,7 +266,7 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool { /// Returns true if we're running in CI with modified LLVM (and thus can't download it) pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool { // If not running in a CI environment, return false. - if !CiEnv::is_ci() { + if !config.is_running_on_ci { return false; } diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 343fbcc0286..e8a1620745e 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -264,7 +264,7 @@ fn ci_rustc_if_unchanged_logic() { let mut paths = vec!["compiler"]; // Handle library tree the same way as in `Config::download_ci_rustc_commit`. - if build_helper::ci::CiEnv::is_ci() { + if builder.config.is_running_on_ci { paths.push("library"); } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index f8ed8072c3d..2b8c1f49afb 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -415,6 +415,8 @@ pub struct Config { /// Command for visual diff display, e.g. `diff-tool --color=always`. pub compiletest_diff_tool: Option<String>, + + pub is_running_on_ci: bool, } #[derive(Clone, Debug, Default)] @@ -1422,6 +1424,7 @@ impl Config { config.llvm_profile_generate = flags.llvm_profile_generate; config.enable_bolt_settings = flags.enable_bolt_settings; config.bypass_bootstrap_lock = flags.bypass_bootstrap_lock; + config.is_running_on_ci = flags.ci.unwrap_or(CiEnv::is_ci()); // Infer the rest of the configuration. @@ -2425,7 +2428,7 @@ impl Config { // CI should always run stage 2 builds, unless it specifically states otherwise #[cfg(not(test))] - if flags.stage.is_none() && build_helper::ci::CiEnv::is_ci() { + if flags.stage.is_none() && config.is_running_on_ci { match config.cmd { Subcommand::Test { .. } | Subcommand::Miri { .. } @@ -2647,7 +2650,7 @@ impl Config { if !self.llvm_from_ci { // This happens when LLVM submodule is updated in CI, we should disable ci-rustc without an error // to not break CI. For non-CI environments, we should return an error. - if CiEnv::is_ci() { + if self.is_running_on_ci { println!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled."); return None; } else { @@ -3036,7 +3039,7 @@ impl Config { // // If you update "library" logic here, update `builder::tests::ci_rustc_if_unchanged_logic` test // logic accordingly. - if !CiEnv::is_ci() { + if !self.is_running_on_ci { allowed_paths.push(":!library"); } @@ -3064,7 +3067,7 @@ impl Config { .expect("git-commit-info is missing in the project root") }; - if CiEnv::is_ci() && { + if self.is_running_on_ci && { let head_sha = output(helpers::git(Some(&self.src)).arg("rev-parse").arg("HEAD").as_command_mut()); let head_sha = head_sha.trim(); diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs index 0f8efcfcc76..08bd87e03a1 100644 --- a/src/bootstrap/src/core/config/flags.rs +++ b/src/bootstrap/src/core/config/flags.rs @@ -179,6 +179,9 @@ pub struct Flags { /// arguments passed to subcommands #[arg(global = true, last(true), value_name = "ARGS")] pub free_args: Vec<String>, + /// Make bootstrap to behave as it's running on the CI environment or not. + #[arg(global = true, long, value_name = "bool")] + pub ci: Option<bool>, } impl Flags { diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 3776dd13676..5bd947f6e63 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -6,7 +6,6 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::sync::OnceLock; -use build_helper::ci::CiEnv; use xz2::bufread::XzDecoder; use crate::core::config::BUILDER_CONFIG_FILENAME; @@ -262,7 +261,7 @@ impl Config { "--fail", ]); // Don't print progress in CI; the \r wrapping looks bad and downloads don't take long enough for progress to be useful. - if CiEnv::is_ci() { + if self.is_running_on_ci { curl.arg("--silent"); } else { curl.arg("--progress-bar"); diff --git a/src/bootstrap/src/utils/render_tests.rs b/src/bootstrap/src/utils/render_tests.rs index 3f58328a5b5..418f3ff975d 100644 --- a/src/bootstrap/src/utils/render_tests.rs +++ b/src/bootstrap/src/utils/render_tests.rs @@ -10,7 +10,6 @@ use std::io::{BufRead, BufReader, Read, Write}; use std::process::{ChildStdout, Stdio}; use std::time::Duration; -use build_helper::ci::CiEnv; use termcolor::{Color, ColorSpec, WriteColor}; use crate::core::builder::Builder; @@ -187,7 +186,7 @@ impl<'a> Renderer<'a> { if self.builder.config.verbose_tests { self.render_test_outcome_verbose(outcome, test); - } else if CiEnv::is_ci() { + } else if self.builder.config.is_running_on_ci { self.render_test_outcome_ci(outcome, test); } else { self.render_test_outcome_terse(outcome, test); |
