Distinguish --dry-run from the automatic dry run check

This commit is contained in:
Joshua Nelson 2022-11-06 16:59:43 -06:00
parent cd128880b1
commit 34972c512b
15 changed files with 96 additions and 78 deletions

View File

@ -1074,11 +1074,11 @@ pub(crate) fn verify(&self, path: &Path, expected: &str) -> bool {
let mut hasher = sha2::Sha256::new();
// FIXME: this is ok for rustfmt (4.1 MB large at time of writing), but it seems memory-intensive for rustc and larger components.
// Consider using streaming IO instead?
let contents = if self.config.dry_run { vec![] } else { t!(fs::read(path)) };
let contents = if self.config.dry_run() { vec![] } else { t!(fs::read(path)) };
hasher.update(&contents);
let found = hex::encode(hasher.finalize().as_slice());
let verified = found == expected;
if !verified && !self.config.dry_run {
if !verified && !self.config.dry_run() {
println!(
"invalid checksum: \n\
found: {found}\n\
@ -1292,7 +1292,7 @@ pub fn rustdoc_cmd(&self, compiler: Compiler) -> Command {
/// Note that this returns `None` if LLVM is disabled, or if we're in a
/// check build or dry-run, where there's no need to build all of LLVM.
fn llvm_config(&self, target: TargetSelection) -> Option<PathBuf> {
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run {
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run() {
let llvm_config = self.ensure(native::Llvm { target });
if llvm_config.is_file() {
return Some(llvm_config);
@ -1644,7 +1644,7 @@ pub fn cargo(
//
// Only clear out the directory if we're compiling std; otherwise, we
// should let Cargo take care of things for us (via depdep info)
if !self.config.dry_run && mode == Mode::Std && cmd == "build" {
if !self.config.dry_run() && mode == Mode::Std && cmd == "build" {
self.clear_if_dirty(&out_dir, &self.rustc(compiler));
}
@ -2142,7 +2142,7 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
(out, dur - deps)
};
if self.config.print_step_timings && !self.config.dry_run {
if self.config.print_step_timings && !self.config.dry_run() {
let step_string = format!("{:?}", step);
let brace_index = step_string.find("{").unwrap_or(0);
let type_string = type_name::<S>();
@ -2216,7 +2216,7 @@ pub(crate) fn maybe_open_in_browser<S: Step>(&self, path: impl AsRef<Path>) {
}
pub(crate) fn open_in_browser(&self, path: impl AsRef<Path>) {
if self.config.dry_run || !self.config.cmd.open() {
if self.config.dry_run() || !self.config.cmd.open() {
return;
}

View File

@ -1,5 +1,5 @@
use super::*;
use crate::config::{Config, TargetSelection};
use crate::config::{Config, DryRun, TargetSelection};
use std::thread;
fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
@ -10,7 +10,7 @@ fn configure_with_args(cmd: &[String], host: &[&str], target: &[&str]) -> Config
let mut config = Config::parse(cmd);
// don't save toolstates
config.save_toolstates = None;
config.dry_run = true;
config.dry_run = DryRun::SelfCheck;
// Ignore most submodules, since we don't need them for a dry run.
// But make sure to check out the `doc` and `rust-analyzer` submodules, since some steps need them

View File

@ -447,7 +447,7 @@ fn copy_sanitizers(
) -> Vec<PathBuf> {
let runtimes: Vec<native::SanitizerRuntime> = builder.ensure(native::Sanitizers { target });
if builder.config.dry_run {
if builder.config.dry_run() {
return Vec::new();
}
@ -986,7 +986,7 @@ fn run(self, builder: &Builder<'_>) {
compiler.stage, backend, &compiler.host, target
));
let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false);
if builder.config.dry_run {
if builder.config.dry_run() {
return;
}
let mut files = files.into_iter().filter(|f| {
@ -1034,7 +1034,7 @@ fn copy_codegen_backends_to_sysroot(
let dst = builder.sysroot_codegen_backends(target_compiler);
t!(fs::create_dir_all(&dst), dst);
if builder.config.dry_run {
if builder.config.dry_run() {
return;
}
@ -1332,7 +1332,7 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
if !builder.config.dry_run {
if !builder.config.dry_run() {
let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir"));
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
@ -1402,7 +1402,7 @@ pub fn run_cargo(
additional_target_deps: Vec<(PathBuf, DependencyType)>,
is_check: bool,
) -> Vec<PathBuf> {
if builder.config.dry_run {
if builder.config.dry_run() {
return Vec::new();
}
@ -1542,7 +1542,7 @@ pub fn stream_cargo(
cb: &mut dyn FnMut(CargoMessage<'_>),
) -> bool {
let mut cargo = Command::from(cargo);
if builder.config.dry_run {
if builder.config.dry_run() {
return true;
}
// Instruct Cargo to give us json messages on stdout, critically leaving

View File

@ -33,6 +33,17 @@ macro_rules! check_ci_llvm {
};
}
#[derive(Clone, Default)]
pub enum DryRun {
/// This isn't a dry run.
#[default]
Disabled,
/// This is a dry run enabled by bootstrap itself, so it can verify that no work is done.
SelfCheck,
/// This is a dry run enabled by the `--dry-run` flag.
UserSelected,
}
/// Global configuration for the entire build and/or bootstrap.
///
/// This structure is derived from a combination of both `config.toml` and
@ -84,7 +95,7 @@ pub struct Config {
pub jobs: Option<u32>,
pub cmd: Subcommand,
pub incremental: bool,
pub dry_run: bool,
pub dry_run: DryRun,
/// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should.
#[cfg(not(test))]
download_rustc_commit: Option<String>,
@ -820,7 +831,7 @@ pub fn parse(args: &[String]) -> Config {
config.jobs = flags.jobs.map(threads_from_config);
config.cmd = flags.cmd;
config.incremental = flags.incremental;
config.dry_run = flags.dry_run;
config.dry_run = if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled };
config.keep_stage = flags.keep_stage;
config.keep_stage_std = flags.keep_stage_std;
config.color = flags.color;
@ -965,7 +976,7 @@ pub fn parse(args: &[String]) -> Config {
.unwrap_or_else(|| config.out.join(config.build.triple).join("stage0/bin/cargo"));
// NOTE: it's important this comes *after* we set `initial_rustc` just above.
if config.dry_run {
if config.dry_run() {
let dir = config.out.join("tmp-dry-run");
t!(fs::create_dir_all(&dir));
config.out = dir;
@ -1372,6 +1383,13 @@ pub fn parse(args: &[String]) -> Config {
config
}
pub(crate) fn dry_run(&self) -> bool {
match self.dry_run {
DryRun::Disabled => false,
DryRun::SelfCheck | DryRun::UserSelected => true,
}
}
/// A git invocation which runs inside the source directory.
///
/// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
@ -1461,7 +1479,7 @@ pub(crate) fn ci_llvm_root(&self) -> PathBuf {
/// This is computed on demand since LLVM might have to first be downloaded from CI.
pub(crate) fn llvm_link_shared(builder: &Builder<'_>) -> bool {
let mut opt = builder.config.llvm_link_shared.get();
if opt.is_none() && builder.config.dry_run {
if opt.is_none() && builder.config.dry_run() {
// just assume static for now - dynamic linking isn't supported on all platforms
return false;
}
@ -1488,7 +1506,7 @@ pub(crate) fn llvm_link_shared(builder: &Builder<'_>) -> bool {
/// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
pub(crate) fn download_rustc(builder: &Builder<'_>) -> bool {
static DOWNLOAD_RUSTC: OnceCell<bool> = OnceCell::new();
if builder.config.dry_run && DOWNLOAD_RUSTC.get().is_none() {
if builder.config.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
// avoid trying to actually download the commit
return false;
}
@ -1507,7 +1525,7 @@ pub(crate) fn initial_rustfmt(builder: &Builder<'_>) -> Option<PathBuf> {
RustfmtState::SystemToolchain(p) | RustfmtState::Downloaded(p) => Some(p.clone()),
RustfmtState::Unavailable => None,
r @ RustfmtState::LazyEvaluated => {
if builder.config.dry_run {
if builder.config.dry_run() {
return Some(PathBuf::new());
}
let path = maybe_download_rustfmt(builder);

View File

@ -945,7 +945,7 @@ fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
.arg(builder.src.join("./src/bootstrap/Cargo.toml"))
.current_dir(&plain_dst_src);
let config = if !builder.config.dry_run {
let config = if !builder.config.dry_run() {
t!(String::from_utf8(t!(cmd.output()).stdout))
} else {
String::new()
@ -1386,7 +1386,7 @@ macro_rules! add_component {
let etc = builder.src.join("src/etc/installer");
// Avoid producing tarballs during a dry run.
if builder.config.dry_run {
if builder.config.dry_run() {
return;
}
@ -1818,7 +1818,7 @@ fn filter(contents: &str, marker: &str) -> String {
let _time = timeit(builder);
builder.run(&mut cmd);
if !builder.config.dry_run {
if !builder.config.dry_run() {
t!(fs::rename(exe.join(&filename), distdir(builder).join(&filename)));
}
}
@ -1882,12 +1882,12 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
if llvm_dylib_path.exists() {
builder.install(&llvm_dylib_path, dst_libdir, 0o644);
}
!builder.config.dry_run
!builder.config.dry_run()
} else if let Ok(llvm_config) = crate::native::prebuilt_llvm_config(builder, target) {
let mut cmd = Command::new(llvm_config);
cmd.arg("--libfiles");
builder.verbose(&format!("running {:?}", cmd));
let files = if builder.config.dry_run { "".into() } else { output(&mut cmd) };
let files = if builder.config.dry_run() { "".into() } else { output(&mut cmd) };
let build_llvm_out = &builder.llvm_out(builder.config.build);
let target_llvm_out = &builder.llvm_out(target);
for file in files.trim_end().split(' ') {
@ -1899,7 +1899,7 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
};
builder.install(&file, dst_libdir, 0o644);
}
!builder.config.dry_run
!builder.config.dry_run()
} else {
false
}

View File

@ -151,7 +151,7 @@ fn run(self, builder: &Builder<'_>) {
let index = out.join("index.html");
let rustbook = builder.tool_exe(Tool::Rustbook);
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
if builder.config.dry_run || up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
if builder.config.dry_run() || up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
return;
}
builder.info(&format!("Rustbook ({}) - {}", target, name));
@ -331,8 +331,8 @@ fn run(self, builder: &Builder<'_>) {
&& up_to_date(&footer, &html)
&& up_to_date(&favicon, &html)
&& up_to_date(&full_toc, &html)
&& (builder.config.dry_run || up_to_date(&version_info, &html))
&& (builder.config.dry_run || up_to_date(&rustdoc, &html))
&& (builder.config.dry_run() || up_to_date(&version_info, &html))
&& (builder.config.dry_run() || up_to_date(&rustdoc, &html))
{
continue;
}
@ -402,7 +402,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
let version_input = builder.src.join("src").join("doc").join("version_info.html.template");
let version_info = out.join("version_info.html");
if !builder.config.dry_run && !up_to_date(&version_input, &version_info) {
if !builder.config.dry_run() && !up_to_date(&version_input, &version_info) {
let info = t!(fs::read_to_string(&version_input))
.replace("VERSION", &builder.rust_release())
.replace("SHORT_HASH", builder.rust_info.sha_short().unwrap_or(""))
@ -900,7 +900,7 @@ fn run(self, builder: &Builder<'_>) {
}
fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> {
if config.dry_run {
if config.dry_run() {
return Ok(());
}
if let Ok(m) = fs::symlink_metadata(dst) {

View File

@ -43,7 +43,7 @@ struct RustfmtConfig {
}
pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
if build.config.dry_run {
if build.config.dry_run() {
return;
}
let mut builder = ignore::types::TypesBuilder::new();

View File

@ -112,7 +112,7 @@
use std::process::Command;
use std::str;
use config::Target;
use config::{DryRun, Target};
use filetime::FileTime;
use once_cell::sync::OnceCell;
@ -430,7 +430,7 @@ pub fn new(mut config: Config) -> Build {
// we always try to use git for LLVM builds
let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project"));
let initial_target_libdir_str = if config.dry_run {
let initial_target_libdir_str = if config.dry_run() {
"/dummy/lib/path/to/lib/".to_string()
} else {
output(
@ -444,7 +444,7 @@ pub fn new(mut config: Config) -> Build {
let initial_target_dir = Path::new(&initial_target_libdir_str).parent().unwrap();
let initial_lld = initial_target_dir.join("bin").join("rust-lld");
let initial_sysroot = if config.dry_run {
let initial_sysroot = if config.dry_run() {
"/dummy".to_string()
} else {
output(Command::new(&config.initial_rustc).arg("--print").arg("sysroot"))
@ -689,13 +689,13 @@ pub fn build(&mut self) {
}
}
if !self.config.dry_run {
if !self.config.dry_run() {
{
self.config.dry_run = true;
self.config.dry_run = DryRun::SelfCheck;
let builder = builder::Builder::new(&self);
builder.execute_cli();
}
self.config.dry_run = false;
self.config.dry_run = DryRun::Disabled;
let builder = builder::Builder::new(&self);
builder.execute_cli();
} else {
@ -947,7 +947,7 @@ fn rustc_snapshot_sysroot(&self) -> &Path {
/// Runs a command, printing out nice contextual information if it fails.
fn run(&self, cmd: &mut Command) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
self.verbose(&format!("running: {:?}", cmd));
@ -956,7 +956,7 @@ fn run(&self, cmd: &mut Command) {
/// Runs a command, printing out nice contextual information if it fails.
fn run_quiet(&self, cmd: &mut Command) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
self.verbose(&format!("running: {:?}", cmd));
@ -967,7 +967,7 @@ fn run_quiet(&self, cmd: &mut Command) {
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
fn try_run(&self, cmd: &mut Command) -> bool {
if self.config.dry_run {
if self.config.dry_run() {
return true;
}
self.verbose(&format!("running: {:?}", cmd));
@ -978,7 +978,7 @@ fn try_run(&self, cmd: &mut Command) -> bool {
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
fn try_run_quiet(&self, cmd: &mut Command) -> bool {
if self.config.dry_run {
if self.config.dry_run() {
return true;
}
self.verbose(&format!("running: {:?}", cmd));
@ -989,7 +989,7 @@ fn try_run_quiet(&self, cmd: &mut Command) -> bool {
/// Returns false if do not execute at all, otherwise returns its
/// `status.success()`.
fn check_run(&self, cmd: &mut Command) -> bool {
if self.config.dry_run {
if self.config.dry_run() {
return true;
}
self.verbose(&format!("running: {:?}", cmd));
@ -1019,7 +1019,7 @@ fn verbose_than(&self, level: usize, msg: &str) {
}
fn info(&self, msg: &str) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
println!("{}", msg);
@ -1400,7 +1400,7 @@ fn in_tree_crates(&self, root: &str, target: Option<TargetSelection>) -> Vec<&Cr
}
fn read_stamp_file(&self, stamp: &Path) -> Vec<(PathBuf, DependencyType)> {
if self.config.dry_run {
if self.config.dry_run() {
return Vec::new();
}
@ -1440,7 +1440,7 @@ pub fn copy(&self, src: &Path, dst: &Path) {
}
fn copy_internal(&self, src: &Path, dst: &Path, dereference_symlinks: bool) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
self.verbose_than(1, &format!("Copy {:?} to {:?}", src, dst));
@ -1477,7 +1477,7 @@ fn copy_internal(&self, src: &Path, dst: &Path, dereference_symlinks: bool) {
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
/// when this function is called.
pub fn cp_r(&self, src: &Path, dst: &Path) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
for f in self.read_dir(src) {
@ -1530,7 +1530,7 @@ fn copy_to_folder(&self, src: &Path, dest_folder: &Path) {
}
fn install(&self, src: &Path, dstdir: &Path, perms: u32) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
let dst = dstdir.join(src.file_name().unwrap());
@ -1544,28 +1544,28 @@ fn install(&self, src: &Path, dstdir: &Path, perms: u32) {
}
fn create(&self, path: &Path, s: &str) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
t!(fs::write(path, s));
}
fn read(&self, path: &Path) -> String {
if self.config.dry_run {
if self.config.dry_run() {
return String::new();
}
t!(fs::read_to_string(path))
}
fn create_dir(&self, dir: &Path) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
t!(fs::create_dir_all(dir))
}
fn remove_dir(&self, dir: &Path) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
t!(fs::remove_dir_all(dir))
@ -1574,7 +1574,7 @@ fn remove_dir(&self, dir: &Path) {
fn read_dir(&self, dir: &Path) -> impl Iterator<Item = fs::DirEntry> {
let iter = match fs::read_dir(dir) {
Ok(v) => v,
Err(_) if self.config.dry_run => return vec![].into_iter(),
Err(_) if self.config.dry_run() => return vec![].into_iter(),
Err(err) => panic!("could not read dir {:?}: {:?}", dir, err),
};
iter.map(|e| t!(e)).collect::<Vec<_>>().into_iter()
@ -1585,11 +1585,11 @@ fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::R
use std::os::unix::fs::symlink as symlink_file;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
if !self.config.dry_run { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
if !self.config.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) }
}
fn remove(&self, f: &Path) {
if self.config.dry_run {
if self.config.dry_run() {
return;
}
fs::remove_file(f).unwrap_or_else(|_| panic!("failed to remove {:?}", f));

View File

@ -226,7 +226,7 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) {
let llvm_stamp = llvm_root.join(".llvm-stamp");
let llvm_sha = detect_llvm_sha(&config, builder.rust_info.is_managed_git_subrepository());
let key = format!("{}{}", llvm_sha, config.llvm_assertions);
if program_out_of_date(&llvm_stamp, &key) && !config.dry_run {
if program_out_of_date(&llvm_stamp, &key) && !config.dry_run() {
download_ci_llvm(builder, &llvm_sha);
for entry in t!(fs::read_dir(llvm_root.join("bin"))) {
builder.fix_bin_or_dylib(&t!(entry).path());
@ -505,7 +505,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
// https://llvm.org/docs/HowToCrossCompileLLVM.html
if target != builder.config.build {
let llvm_config = builder.ensure(Llvm { target: builder.config.build });
if !builder.config.dry_run {
if !builder.config.dry_run() {
let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir"));
let host_bin = Path::new(llvm_bindir.trim());
cfg.define(
@ -519,7 +519,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
if builder.config.llvm_clang {
let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");
let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION);
if !builder.config.dry_run && !clang_tblgen.exists() {
if !builder.config.dry_run() && !clang_tblgen.exists() {
panic!("unable to find {}", clang_tblgen.display());
}
cfg.define("CLANG_TABLEGEN", clang_tblgen);
@ -553,7 +553,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
// tools. Figure out how to filter them down and only build the right
// tools and libs on all platforms.
if builder.config.dry_run {
if builder.config.dry_run() {
return build_llvm_config;
}
@ -611,7 +611,7 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
return;
}
if builder.config.dry_run {
if builder.config.dry_run() {
return;
}
@ -872,7 +872,7 @@ fn make_run(run: RunConfig<'_>) {
/// Compile LLD for `target`.
fn run(self, builder: &Builder<'_>) -> PathBuf {
if builder.config.dry_run {
if builder.config.dry_run() {
return PathBuf::from("lld-out-dir-test-gen");
}
let target = self.target;
@ -990,7 +990,7 @@ fn make_run(run: RunConfig<'_>) {
/// Compiles the `rust_test_helpers.c` library which we used in various
/// `run-pass` tests for ABI testing.
fn run(self, builder: &Builder<'_>) {
if builder.config.dry_run {
if builder.config.dry_run() {
return;
}
// The x86_64-fortanix-unknown-sgx target doesn't have a working C
@ -1066,7 +1066,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
}
let llvm_config = builder.ensure(Llvm { target: builder.config.build });
if builder.config.dry_run {
if builder.config.dry_run() {
return runtimes;
}
@ -1240,7 +1240,7 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) -> Self::Output {
let out_dir = builder.native_dir(self.target).join("crt");
if builder.config.dry_run {
if builder.config.dry_run() {
return out_dir;
}
@ -1304,7 +1304,7 @@ fn make_run(run: RunConfig<'_>) {
/// Build linunwind.a
fn run(self, builder: &Builder<'_>) -> Self::Output {
if builder.config.dry_run {
if builder.config.dry_run() {
return PathBuf::new();
}

View File

@ -163,7 +163,7 @@ pub fn check(build: &mut Build) {
continue;
}
if !build.config.dry_run {
if !build.config.dry_run() {
cmd_finder.must_have(build.cc(*target));
if let Some(ar) = build.ar(*target) {
cmd_finder.must_have(ar);
@ -172,7 +172,7 @@ pub fn check(build: &mut Build) {
}
for host in &build.hosts {
if !build.config.dry_run {
if !build.config.dry_run() {
cmd_finder.must_have(build.cxx(*host).unwrap());
}
}

View File

@ -323,7 +323,7 @@ fn run(self, build_cli: impl FnOnce(&Tarball<'a>, &mut Command)) -> GeneratedTar
// Ensure there are no symbolic links in the tarball. In particular,
// rustup-toolchain-install-master and most versions of Windows can't handle symbolic links.
let decompressed_output = self.temp_dir.join(&package_name);
if !self.builder.config.dry_run && !self.permit_symlinks {
if !self.builder.config.dry_run() && !self.permit_symlinks {
for entry in walkdir::WalkDir::new(&decompressed_output) {
let entry = t!(entry);
if entry.path_is_symlink() {

View File

@ -508,7 +508,7 @@ pub fn build_miri_sysroot(
cargo.arg("--print-sysroot");
// FIXME: Is there a way in which we can re-use the usual `run` helpers?
if builder.config.dry_run {
if builder.config.dry_run() {
String::new()
} else {
builder.verbose(&format!("running: {:?}", cargo));
@ -1537,7 +1537,7 @@ fn run(self, builder: &Builder<'_>) {
let mut copts_passed = false;
if builder.config.llvm_enabled() {
let llvm_config = builder.ensure(native::Llvm { target: builder.config.build });
if !builder.config.dry_run {
if !builder.config.dry_run() {
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
// Remove trailing newline from llvm-config output.
@ -1555,14 +1555,14 @@ fn run(self, builder: &Builder<'_>) {
// requirement, but the `-L` library path is not propagated across
// separate compilations. We can add LLVM's library path to the
// platform-specific environment variable as a workaround.
if !builder.config.dry_run && suite.ends_with("fulldeps") {
if !builder.config.dry_run() && suite.ends_with("fulldeps") {
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
}
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") {
// The llvm/bin directory contains many useful cross-platform
// tools. Pass the path to run-make tests so they can use them.
let llvm_bin_path = llvm_config
@ -1590,7 +1590,7 @@ fn run(self, builder: &Builder<'_>) {
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") {
cmd.arg("--cc")
.arg(builder.cc(target))
.arg("--cxx")

View File

@ -522,7 +522,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
builder.ensure(compile::Rustc::new(build_compiler, target_compiler.host));
// NOTE: this implies that `download-rustc` is pretty useless when compiling with the stage0
// compiler, since you do just as much work.
if !builder.config.dry_run && builder.download_rustc() && build_compiler.stage == 0 {
if !builder.config.dry_run() && builder.download_rustc() && build_compiler.stage == 0 {
println!(
"warning: `download-rustc` does nothing when building stage1 tools; consider using `--stage 2` instead"
);

View File

@ -158,7 +158,7 @@ impl Step for ToolStateCheck {
/// stable tool. That is, the status is not allowed to get worse
/// (test-pass to test-fail or build-fail).
fn run(self, builder: &Builder<'_>) {
if builder.config.dry_run {
if builder.config.dry_run() {
return;
}
@ -265,7 +265,7 @@ pub fn save_toolstate(&self, tool: &str, state: ToolState) {
// If we're in a dry run setting we don't want to save toolstates as
// that means if we e.g. panic down the line it'll look like we tested
// everything (but we actually haven't).
if self.config.dry_run {
if self.config.dry_run() {
return;
}
// Toolstate isn't tracked for clippy or rustfmt, but since most tools do, we avoid checking

View File

@ -105,7 +105,7 @@ fn link_lib_path() -> Vec<PathBuf> {
/// Returns an RAII structure that prints out how long it took to drop.
pub fn timeit(builder: &Builder<'_>) -> TimeIt {
TimeIt(builder.config.dry_run, Instant::now())
TimeIt(builder.config.dry_run(), Instant::now())
}
impl Drop for TimeIt {
@ -128,7 +128,7 @@ pub(crate) fn program_out_of_date(stamp: &Path, key: &str) -> bool {
/// Symlinks two directories, using junctions on Windows and normal symlinks on
/// Unix.
pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
if config.dry_run {
if config.dry_run() {
return Ok(());
}
let _ = fs::remove_dir(dest);