From be1e7893d5a3174ab9347b6b3de0fa607aec4f9f Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sat, 14 Apr 2018 17:27:57 -0600 Subject: [PATCH] Remove uses of Build across Builder steps --- src/bootstrap/builder.rs | 41 ++- src/bootstrap/check.rs | 63 ++-- src/bootstrap/compile.rs | 295 +++++++++---------- src/bootstrap/dist.rs | 609 +++++++++++++++++++-------------------- src/bootstrap/doc.rs | 218 +++++++------- src/bootstrap/install.rs | 31 +- src/bootstrap/native.rs | 142 +++++---- src/bootstrap/test.rs | 325 ++++++++++----------- src/bootstrap/tool.rs | 82 +++--- src/bootstrap/util.rs | 6 +- 10 files changed, 873 insertions(+), 939 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index b29ac0e1efc8e..20c89f99b2b0c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -154,18 +154,17 @@ impl StepDescription { eprintln!("{:?} not skipped for {:?} -- not in {:?}", pathset, self.name, builder.config.exclude); } - let build = builder.build; - let hosts = &build.hosts; + let hosts = &builder.hosts; // Determine the targets participating in this rule. let targets = if self.only_hosts { - if !build.config.run_host_only { + if !builder.config.run_host_only { return; // don't run anything } else { - &build.hosts + &builder.hosts } } else { - &build.targets + &builder.targets }; for host in hosts { @@ -476,7 +475,7 @@ impl<'a> Builder<'a> { pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf { self.sysroot_libdir(compiler, compiler.host) - .with_file_name(self.build.config.rust_codegen_backends_dir.clone()) + .with_file_name(self.config.rust_codegen_backends_dir.clone()) } /// Returns the compiler's libdir where it stores the dynamic libraries that @@ -486,7 +485,7 @@ impl<'a> Builder<'a> { /// Windows. pub fn rustc_libdir(&self, compiler: Compiler) -> PathBuf { if compiler.is_snapshot(self) { - self.build.rustc_snapshot_libdir() + self.rustc_snapshot_libdir() } else { self.sysroot(compiler).join(libdir(&compiler.host)) } @@ -523,12 +522,12 @@ impl<'a> Builder<'a> { let compiler = self.compiler(self.top_stage, host); cmd.env("RUSTC_STAGE", compiler.stage.to_string()) .env("RUSTC_SYSROOT", self.sysroot(compiler)) - .env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.build.build)) - .env("CFG_RELEASE_CHANNEL", &self.build.config.channel) + .env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build)) + .env("CFG_RELEASE_CHANNEL", &self.config.channel) .env("RUSTDOC_REAL", self.rustdoc(host)) - .env("RUSTDOC_CRATE_VERSION", self.build.rust_version()) + .env("RUSTDOC_CRATE_VERSION", self.rust_version()) .env("RUSTC_BOOTSTRAP", "1"); - if let Some(linker) = self.build.linker(host) { + if let Some(linker) = self.linker(host) { cmd.env("RUSTC_TARGET_LINKER", linker); } cmd @@ -609,17 +608,17 @@ impl<'a> Builder<'a> { .env("TEST_MIRI", self.config.test_miri.to_string()) .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir()); - if let Some(host_linker) = self.build.linker(compiler.host) { + if let Some(host_linker) = self.linker(compiler.host) { cargo.env("RUSTC_HOST_LINKER", host_linker); } - if let Some(target_linker) = self.build.linker(target) { + if let Some(target_linker) = self.linker(target) { cargo.env("RUSTC_TARGET_LINKER", target_linker); } if let Some(ref error_format) = self.config.rustc_error_format { cargo.env("RUSTC_ERROR_FORMAT", error_format); } if cmd != "build" && cmd != "check" { - cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build))); + cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build))); } if mode == Mode::Tool { @@ -677,7 +676,7 @@ impl<'a> Builder<'a> { // // If LLVM support is disabled we need to use the snapshot compiler to compile // build scripts, as the new compiler doesn't support executables. - if mode == Mode::Libstd || !self.build.config.llvm_enabled { + if mode == Mode::Libstd || !self.config.llvm_enabled { cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc) .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir()); } else { @@ -761,7 +760,7 @@ impl<'a> Builder<'a> { } // For `cargo doc` invocations, make rustdoc print the Rust version into the docs - cargo.env("RUSTDOC_CRATE_VERSION", self.build.rust_version()); + cargo.env("RUSTDOC_CRATE_VERSION", self.rust_version()); // Environment variables *required* throughout the build // @@ -769,7 +768,7 @@ impl<'a> Builder<'a> { cargo.env("CFG_COMPILER_HOST_TRIPLE", target); // Set this for all builds to make sure doc builds also get it. - cargo.env("CFG_RELEASE_CHANNEL", &self.build.config.channel); + cargo.env("CFG_RELEASE_CHANNEL", &self.config.channel); // This one's a bit tricky. As of the time of this writing the compiler // links to the `winapi` crate on crates.io. This crate provides raw @@ -854,7 +853,7 @@ impl<'a> Builder<'a> { panic!(out); } if let Some(out) = self.cache.get(&step) { - self.build.verbose(&format!("{}c {:?}", " ".repeat(stack.len()), step)); + self.verbose(&format!("{}c {:?}", " ".repeat(stack.len()), step)); { let mut graph = self.graph.borrow_mut(); @@ -869,7 +868,7 @@ impl<'a> Builder<'a> { return out; } - self.build.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step)); + self.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step)); stack.push(Box::new(step.clone())); } @@ -899,7 +898,7 @@ impl<'a> Builder<'a> { self.parent.set(prev_parent); - if self.build.config.print_step_timings && dur > Duration::from_millis(100) { + if self.config.print_step_timings && dur > Duration::from_millis(100) { println!("[TIMING] {:?} -- {}.{:03}", step, dur.as_secs(), @@ -911,7 +910,7 @@ impl<'a> Builder<'a> { let cur_step = stack.pop().expect("step stack empty"); assert_eq!(cur_step.downcast_ref(), Some(&step)); } - self.build.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)); + self.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)); self.cache.put(step, out.clone()); out } diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index a39fad67ebea4..adebd424d7eb6 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -12,7 +12,7 @@ use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, add_to_sysroot}; use builder::{RunConfig, Builder, ShouldRun, Step}; -use {Build, Compiler, Mode}; +use {Compiler, Mode}; use cache::Interned; use std::path::PathBuf; @@ -36,24 +36,23 @@ impl Step for Std { } fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; - let compiler = builder.compiler(0, build.build); + let compiler = builder.compiler(0, builder.config.build); - let out_dir = build.stage_out(compiler, Mode::Libstd); - build.clear_if_dirty(&out_dir, &builder.rustc(compiler)); + let out_dir = builder.stage_out(compiler, Mode::Libstd); + builder.clear_if_dirty(&out_dir, &builder.rustc(compiler)); let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check"); std_cargo(builder, &compiler, target, &mut cargo); - let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage)); + let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage)); println!("Checking std artifacts ({} -> {})", &compiler.host, target); - run_cargo(build, + run_cargo(builder, &mut cargo, - &libstd_stamp(build, compiler, target), + &libstd_stamp(builder, compiler, target), true); let libdir = builder.sysroot_libdir(compiler, target); - add_to_sysroot(&build, &libdir, &libstd_stamp(build, compiler, target)); + add_to_sysroot(&builder, &libdir, &libstd_stamp(builder, compiler, target)); } } @@ -83,26 +82,25 @@ impl Step for Rustc { /// the `compiler` targeting the `target` architecture. The artifacts /// created will also be linked into the sysroot directory. fn run(self, builder: &Builder) { - let build = builder.build; - let compiler = builder.compiler(0, build.build); + let compiler = builder.compiler(0, builder.config.build); let target = self.target; let stage_out = builder.stage_out(compiler, Mode::Librustc); - build.clear_if_dirty(&stage_out, &libstd_stamp(build, compiler, target)); - build.clear_if_dirty(&stage_out, &libtest_stamp(build, compiler, target)); + builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target)); + builder.clear_if_dirty(&stage_out, &libtest_stamp(builder, compiler, target)); let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check"); - rustc_cargo(build, &mut cargo); + rustc_cargo(builder, &mut cargo); - let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage)); + let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage)); println!("Checking compiler artifacts ({} -> {})", &compiler.host, target); - run_cargo(build, + run_cargo(builder, &mut cargo, - &librustc_stamp(build, compiler, target), + &librustc_stamp(builder, compiler, target), true); let libdir = builder.sysroot_libdir(compiler, target); - add_to_sysroot(&build, &libdir, &librustc_stamp(build, compiler, target)); + add_to_sysroot(&builder, &libdir, &librustc_stamp(builder, compiler, target)); } } @@ -126,41 +124,40 @@ impl Step for Test { } fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; - let compiler = builder.compiler(0, build.build); + let compiler = builder.compiler(0, builder.config.build); - let out_dir = build.stage_out(compiler, Mode::Libtest); - build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target)); + let out_dir = builder.stage_out(compiler, Mode::Libtest); + builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target)); let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check"); - test_cargo(build, &compiler, target, &mut cargo); + test_cargo(builder, &compiler, target, &mut cargo); - let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage)); + let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage)); println!("Checking test artifacts ({} -> {})", &compiler.host, target); - run_cargo(build, + run_cargo(builder, &mut cargo, - &libtest_stamp(build, compiler, target), + &libtest_stamp(builder, compiler, target), true); let libdir = builder.sysroot_libdir(compiler, target); - add_to_sysroot(&build, &libdir, &libtest_stamp(build, compiler, target)); + add_to_sysroot(builder, &libdir, &libtest_stamp(builder, compiler, target)); } } /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. -pub fn libstd_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { - build.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp") +pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp") } /// Cargo's output path for libtest in a given stage, compiled by a particular /// compiler for the specified target. -pub fn libtest_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { - build.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp") +pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp") } /// Cargo's output path for librustc in a given stage, compiled by a particular /// compiler for the specified target. -pub fn librustc_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { - build.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp") +pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp") } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index b411b19bd53d2..07bce77af8d24 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -31,7 +31,7 @@ use filetime::FileTime; use serde_json; use util::{exe, libdir, is_dylib, CiEnv}; -use {Build, Compiler, Mode}; +use {Compiler, Mode}; use native; use tool; @@ -65,14 +65,13 @@ impl Step for Std { /// using the `compiler` targeting the `target` architecture. The artifacts /// created will also be linked into the sysroot directory. fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; let compiler = self.compiler; builder.ensure(StartupObjects { compiler, target }); - if build.force_use_stage1(compiler, target) { - let from = builder.compiler(1, build.build); + if builder.force_use_stage1(compiler, target) { + let from = builder.compiler(1, builder.config.build); builder.ensure(Std { compiler: from, target, @@ -83,7 +82,7 @@ impl Step for Std { // still contain the musl startup objects. if target.contains("musl") { let libdir = builder.sysroot_libdir(compiler, target); - copy_musl_third_party_objects(build, target, &libdir); + copy_musl_third_party_objects(builder, target, &libdir); } builder.ensure(StdLink { @@ -96,24 +95,24 @@ impl Step for Std { if target.contains("musl") { let libdir = builder.sysroot_libdir(compiler, target); - copy_musl_third_party_objects(build, target, &libdir); + copy_musl_third_party_objects(builder, target, &libdir); } - let out_dir = build.cargo_out(compiler, Mode::Libstd, target); - build.clear_if_dirty(&out_dir, &builder.rustc(compiler)); + let out_dir = builder.cargo_out(compiler, Mode::Libstd, target); + builder.clear_if_dirty(&out_dir, &builder.rustc(compiler)); let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build"); std_cargo(builder, &compiler, target, &mut cargo); - let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage)); - build.info(&format!("Building stage{} std artifacts ({} -> {})", compiler.stage, + let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage)); + builder.info(&format!("Building stage{} std artifacts ({} -> {})", compiler.stage, &compiler.host, target)); - run_cargo(build, + run_cargo(builder, &mut cargo, - &libstd_stamp(build, compiler, target), + &libstd_stamp(builder, compiler, target), false); builder.ensure(StdLink { - compiler: builder.compiler(compiler.stage, build.build), + compiler: builder.compiler(compiler.stage, builder.config.build), target_compiler: compiler, target, }); @@ -126,17 +125,17 @@ impl Step for Std { /// with a glibc-targeting toolchain, given we have the appropriate startup /// files. As those shipped with glibc won't work, copy the ones provided by /// musl so we have them on linux-gnu hosts. -fn copy_musl_third_party_objects(build: &Build, +fn copy_musl_third_party_objects(builder: &Builder, target: Interned, into: &Path) { for &obj in &["crt1.o", "crti.o", "crtn.o"] { - build.copy(&build.musl_root(target).unwrap().join("lib").join(obj), &into.join(obj)); + builder.copy(&builder.musl_root(target).unwrap().join("lib").join(obj), &into.join(obj)); } } /// Configure cargo to compile the standard library, adding appropriate env vars /// and such. -pub fn std_cargo(build: &Builder, +pub fn std_cargo(builder: &Builder, compiler: &Compiler, target: Interned, cargo: &mut Command) { @@ -144,27 +143,27 @@ pub fn std_cargo(build: &Builder, cargo.env("MACOSX_DEPLOYMENT_TARGET", target); } - if build.no_std(target) == Some(true) { + if builder.no_std(target) == Some(true) { // for no-std targets we only compile a few no_std crates cargo.arg("--features").arg("c mem") .args(&["-p", "alloc"]) .args(&["-p", "compiler_builtins"]) .args(&["-p", "std_unicode"]) .arg("--manifest-path") - .arg(build.src.join("src/rustc/compiler_builtins_shim/Cargo.toml")); + .arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml")); } else { - let mut features = build.std_features(); + let mut features = builder.std_features(); // When doing a local rebuild we tell cargo that we're stage1 rather than // stage0. This works fine if the local rust and being-built rust have the // same view of what the default allocator is, but fails otherwise. Since // we don't have a way to express an allocator preference yet, work // around the issue in the case of a local rebuild with jemalloc disabled. - if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc { + if compiler.stage == 0 && builder.local_rebuild && !builder.config.use_jemalloc { features.push_str(" force_alloc_system"); } - if compiler.stage != 0 && build.config.sanitizers { + if compiler.stage != 0 && builder.config.sanitizers { // This variable is used by the sanitizer runtime crates, e.g. // rustc_lsan, to build the sanitizer runtime from C code // When this variable is missing, those crates won't compile the C code, @@ -172,8 +171,8 @@ pub fn std_cargo(build: &Builder, // missing // We also only build the runtimes when --enable-sanitizers (or its // config.toml equivalent) is used - let llvm_config = build.ensure(native::Llvm { - target: build.config.build, + let llvm_config = builder.ensure(native::Llvm { + target: builder.config.build, emscripten: false, }); cargo.env("LLVM_CONFIG", llvm_config); @@ -181,15 +180,15 @@ pub fn std_cargo(build: &Builder, cargo.arg("--features").arg(features) .arg("--manifest-path") - .arg(build.src.join("src/libstd/Cargo.toml")); + .arg(builder.src.join("src/libstd/Cargo.toml")); - if let Some(target) = build.config.target_config.get(&target) { + if let Some(target) = builder.config.target_config.get(&target) { if let Some(ref jemalloc) = target.jemalloc { cargo.env("JEMALLOC_OVERRIDE", jemalloc); } } if target.contains("musl") { - if let Some(p) = build.musl_root(target) { + if let Some(p) = builder.musl_root(target) { cargo.env("MUSL_ROOT", p); } } @@ -219,24 +218,23 @@ impl Step for StdLink { /// libraries for `target`, and this method will find them in the relevant /// output directory. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target_compiler = self.target_compiler; let target = self.target; - build.info(&format!("Copying stage{} std from stage{} ({} -> {} / {})", + builder.info(&format!("Copying stage{} std from stage{} ({} -> {} / {})", target_compiler.stage, compiler.stage, &compiler.host, target_compiler.host, target)); let libdir = builder.sysroot_libdir(target_compiler, target); - add_to_sysroot(&build, &libdir, &libstd_stamp(build, compiler, target)); + add_to_sysroot(builder, &libdir, &libstd_stamp(builder, compiler, target)); - if build.config.sanitizers && compiler.stage != 0 && target == "x86_64-apple-darwin" { + if builder.config.sanitizers && compiler.stage != 0 && target == "x86_64-apple-darwin" { // The sanitizers are only built in stage1 or above, so the dylibs will // be missing in stage0 and causes panic. See the `std()` function above // for reason why the sanitizers are not built in stage0. - copy_apple_sanitizer_dylibs(&build, &build.native_dir(target), "osx", &libdir); + copy_apple_sanitizer_dylibs(builder, &builder.native_dir(target), "osx", &libdir); } builder.ensure(tool::CleanTools { @@ -247,7 +245,7 @@ impl Step for StdLink { } } -fn copy_apple_sanitizer_dylibs(build: &Build, native_dir: &Path, platform: &str, into: &Path) { +fn copy_apple_sanitizer_dylibs(builder: &Builder, native_dir: &Path, platform: &str, into: &Path) { for &sanitizer in &["asan", "tsan"] { let filename = format!("libclang_rt.{}_{}_dynamic.dylib", sanitizer, platform); let mut src_path = native_dir.join(sanitizer); @@ -255,7 +253,7 @@ fn copy_apple_sanitizer_dylibs(build: &Build, native_dir: &Path, platform: &str, src_path.push("lib"); src_path.push("darwin"); src_path.push(&filename); - build.copy(&src_path, &into.join(filename)); + builder.copy(&src_path, &into.join(filename)); } } @@ -286,15 +284,14 @@ impl Step for StartupObjects { /// files, so we just use the nightly snapshot compiler to always build them (as /// no other compilers are guaranteed to be available). fn run(self, builder: &Builder) { - let build = builder.build; let for_compiler = self.compiler; let target = self.target; if !target.contains("pc-windows-gnu") { return } - let src_dir = &build.src.join("src/rtstartup"); - let dst_dir = &build.native_dir(target).join("rtstartup"); + let src_dir = &builder.src.join("src/rtstartup"); + let dst_dir = &builder.native_dir(target).join("rtstartup"); let sysroot_dir = &builder.sysroot_libdir(for_compiler, target); t!(fs::create_dir_all(dst_dir)); @@ -302,8 +299,8 @@ impl Step for StartupObjects { let src_file = &src_dir.join(file.to_string() + ".rs"); let dst_file = &dst_dir.join(file.to_string() + ".o"); if !up_to_date(src_file, dst_file) { - let mut cmd = Command::new(&build.initial_rustc); - build.run(cmd.env("RUSTC_BOOTSTRAP", "1") + let mut cmd = Command::new(&builder.initial_rustc); + builder.run(cmd.env("RUSTC_BOOTSTRAP", "1") .arg("--cfg").arg("stage0") .arg("--target").arg(target) .arg("--emit=obj") @@ -311,15 +308,15 @@ impl Step for StartupObjects { .arg(src_file)); } - build.copy(dst_file, &sysroot_dir.join(file.to_string() + ".o")); + builder.copy(dst_file, &sysroot_dir.join(file.to_string() + ".o")); } for obj in ["crt2.o", "dllcrt2.o"].iter() { - let src = compiler_file(build, - build.cc(target), + let src = compiler_file(builder, + builder.cc(target), target, obj); - build.copy(&src, &sysroot_dir.join(obj)); + builder.copy(&src, &sysroot_dir.join(obj)); } } } @@ -351,41 +348,41 @@ impl Step for Test { /// the build using the `compiler` targeting the `target` architecture. The /// artifacts created will also be linked into the sysroot directory. fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; let compiler = self.compiler; builder.ensure(Std { compiler, target }); - if build.force_use_stage1(compiler, target) { + if builder.force_use_stage1(compiler, target) { builder.ensure(Test { - compiler: builder.compiler(1, build.build), + compiler: builder.compiler(1, builder.config.build), target, }); - build.info(&format!("Uplifting stage1 test ({} -> {})", &build.build, target)); + builder.info( + &format!("Uplifting stage1 test ({} -> {})", builder.config.build, target)); builder.ensure(TestLink { - compiler: builder.compiler(1, build.build), + compiler: builder.compiler(1, builder.config.build), target_compiler: compiler, target, }); return; } - let out_dir = build.cargo_out(compiler, Mode::Libtest, target); - build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target)); + let out_dir = builder.cargo_out(compiler, Mode::Libtest, target); + builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target)); let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "build"); - test_cargo(build, &compiler, target, &mut cargo); + test_cargo(builder, &compiler, target, &mut cargo); - let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage)); - build.info(&format!("Building stage{} test artifacts ({} -> {})", compiler.stage, + let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage)); + builder.info(&format!("Building stage{} test artifacts ({} -> {})", compiler.stage, &compiler.host, target)); - run_cargo(build, + run_cargo(builder, &mut cargo, - &libtest_stamp(build, compiler, target), + &libtest_stamp(builder, compiler, target), false); builder.ensure(TestLink { - compiler: builder.compiler(compiler.stage, build.build), + compiler: builder.compiler(compiler.stage, builder.config.build), target_compiler: compiler, target, }); @@ -393,7 +390,7 @@ impl Step for Test { } /// Same as `std_cargo`, but for libtest -pub fn test_cargo(build: &Build, +pub fn test_cargo(builder: &Builder, _compiler: &Compiler, _target: Interned, cargo: &mut Command) { @@ -401,7 +398,7 @@ pub fn test_cargo(build: &Build, cargo.env("MACOSX_DEPLOYMENT_TARGET", target); } cargo.arg("--manifest-path") - .arg(build.src.join("src/libtest/Cargo.toml")); + .arg(builder.src.join("src/libtest/Cargo.toml")); } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -420,18 +417,17 @@ impl Step for TestLink { /// Same as `std_link`, only for libtest fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target_compiler = self.target_compiler; let target = self.target; - build.info(&format!("Copying stage{} test from stage{} ({} -> {} / {})", + builder.info(&format!("Copying stage{} test from stage{} ({} -> {} / {})", target_compiler.stage, compiler.stage, &compiler.host, target_compiler.host, target)); - add_to_sysroot(&build, &builder.sysroot_libdir(target_compiler, target), - &libtest_stamp(build, compiler, target)); + add_to_sysroot(builder, &builder.sysroot_libdir(target_compiler, target), + &libtest_stamp(builder, compiler, target)); builder.ensure(tool::CleanTools { compiler: target_compiler, target, @@ -468,20 +464,20 @@ impl Step for Rustc { /// the `compiler` targeting the `target` architecture. The artifacts /// created will also be linked into the sysroot directory. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target = self.target; builder.ensure(Test { compiler, target }); - if build.force_use_stage1(compiler, target) { + if builder.force_use_stage1(compiler, target) { builder.ensure(Rustc { - compiler: builder.compiler(1, build.build), + compiler: builder.compiler(1, builder.config.build), target, }); - build.info(&format!("Uplifting stage1 rustc ({} -> {})", &build.build, target)); + builder.info(&format!("Uplifting stage1 rustc ({} -> {})", + builder.config.build, target)); builder.ensure(RustcLink { - compiler: builder.compiler(1, build.build), + compiler: builder.compiler(1, builder.config.build), target_compiler: compiler, target, }); @@ -490,71 +486,71 @@ impl Step for Rustc { // Ensure that build scripts have a std to link against. builder.ensure(Std { - compiler: builder.compiler(self.compiler.stage, build.build), - target: build.build, + compiler: builder.compiler(self.compiler.stage, builder.config.build), + target: builder.config.build, }); let cargo_out = builder.cargo_out(compiler, Mode::Librustc, target); - build.clear_if_dirty(&cargo_out, &libstd_stamp(build, compiler, target)); - build.clear_if_dirty(&cargo_out, &libtest_stamp(build, compiler, target)); + builder.clear_if_dirty(&cargo_out, &libstd_stamp(builder, compiler, target)); + builder.clear_if_dirty(&cargo_out, &libtest_stamp(builder, compiler, target)); let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build"); - rustc_cargo(build, &mut cargo); + rustc_cargo(builder, &mut cargo); - let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage)); - build.info(&format!("Building stage{} compiler artifacts ({} -> {})", + let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage)); + builder.info(&format!("Building stage{} compiler artifacts ({} -> {})", compiler.stage, &compiler.host, target)); - run_cargo(build, + run_cargo(builder, &mut cargo, - &librustc_stamp(build, compiler, target), + &librustc_stamp(builder, compiler, target), false); builder.ensure(RustcLink { - compiler: builder.compiler(compiler.stage, build.build), + compiler: builder.compiler(compiler.stage, builder.config.build), target_compiler: compiler, target, }); } } -pub fn rustc_cargo(build: &Build, cargo: &mut Command) { - cargo.arg("--features").arg(build.rustc_features()) +pub fn rustc_cargo(builder: &Builder, cargo: &mut Command) { + cargo.arg("--features").arg(builder.rustc_features()) .arg("--manifest-path") - .arg(build.src.join("src/rustc/Cargo.toml")); - rustc_cargo_env(build, cargo); + .arg(builder.src.join("src/rustc/Cargo.toml")); + rustc_cargo_env(builder, cargo); } -fn rustc_cargo_env(build: &Build, cargo: &mut Command) { +fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) { // Set some configuration variables picked up by build scripts and // the compiler alike - cargo.env("CFG_RELEASE", build.rust_release()) - .env("CFG_RELEASE_CHANNEL", &build.config.channel) - .env("CFG_VERSION", build.rust_version()) - .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default()) - .env("CFG_CODEGEN_BACKENDS_DIR", &build.config.rust_codegen_backends_dir); + cargo.env("CFG_RELEASE", builder.rust_release()) + .env("CFG_RELEASE_CHANNEL", &builder.config.channel) + .env("CFG_VERSION", builder.rust_version()) + .env("CFG_PREFIX", builder.config.prefix.clone().unwrap_or_default()) + .env("CFG_CODEGEN_BACKENDS_DIR", &builder.config.rust_codegen_backends_dir); - let libdir_relative = build.config.libdir_relative().unwrap_or(Path::new("lib")); + let libdir_relative = builder.config.libdir_relative().unwrap_or(Path::new("lib")); cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative); // If we're not building a compiler with debugging information then remove // these two env vars which would be set otherwise. - if build.config.rust_debuginfo_only_std { + if builder.config.rust_debuginfo_only_std { cargo.env_remove("RUSTC_DEBUGINFO"); cargo.env_remove("RUSTC_DEBUGINFO_LINES"); } - if let Some(ref ver_date) = build.rust_info.commit_date() { + if let Some(ref ver_date) = builder.rust_info.commit_date() { cargo.env("CFG_VER_DATE", ver_date); } - if let Some(ref ver_hash) = build.rust_info.sha() { + if let Some(ref ver_hash) = builder.rust_info.sha() { cargo.env("CFG_VER_HASH", ver_hash); } - if !build.unstable_features() { + if !builder.unstable_features() { cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1"); } - if let Some(ref s) = build.config.rustc_default_linker { + if let Some(ref s) = builder.config.rustc_default_linker { cargo.env("CFG_DEFAULT_LINKER", s); } - if build.config.rustc_parallel_queries { + if builder.config.rustc_parallel_queries { cargo.env("RUSTC_PARALLEL_QUERIES", "1"); } } @@ -575,18 +571,17 @@ impl Step for RustcLink { /// Same as `std_link`, only for librustc fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target_compiler = self.target_compiler; let target = self.target; - build.info(&format!("Copying stage{} rustc from stage{} ({} -> {} / {})", + builder.info(&format!("Copying stage{} rustc from stage{} ({} -> {} / {})", target_compiler.stage, compiler.stage, &compiler.host, target_compiler.host, target)); - add_to_sysroot(&build, &builder.sysroot_libdir(target_compiler, target), - &librustc_stamp(build, compiler, target)); + add_to_sysroot(builder, &builder.sysroot_libdir(target_compiler, target), + &librustc_stamp(builder, compiler, target)); builder.ensure(tool::CleanTools { compiler: target_compiler, target, @@ -624,15 +619,14 @@ impl Step for CodegenBackend { } fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target = self.target; builder.ensure(Rustc { compiler, target }); - if build.force_use_stage1(compiler, target) { + if builder.force_use_stage1(compiler, target) { builder.ensure(CodegenBackend { - compiler: builder.compiler(1, build.build), + compiler: builder.compiler(1, builder.config.build), target, backend: self.backend, }); @@ -640,10 +634,10 @@ impl Step for CodegenBackend { } let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build"); - let mut features = build.rustc_features().to_string(); + let mut features = builder.rustc_features().to_string(); cargo.arg("--manifest-path") - .arg(build.src.join("src/librustc_trans/Cargo.toml")); - rustc_cargo_env(build, &mut cargo); + .arg(builder.src.join("src/librustc_trans/Cargo.toml")); + rustc_cargo_env(builder, &mut cargo); match &*self.backend { "llvm" | "emscripten" => { @@ -658,45 +652,45 @@ impl Step for CodegenBackend { features.push_str(" emscripten"); } - build.info(&format!("Building stage{} codegen artifacts ({} -> {}, {})", + builder.info(&format!("Building stage{} codegen artifacts ({} -> {}, {})", compiler.stage, &compiler.host, target, self.backend)); // Pass down configuration from the LLVM build into the build of // librustc_llvm and librustc_trans. - if build.is_rust_llvm(target) { + if builder.is_rust_llvm(target) { cargo.env("LLVM_RUSTLLVM", "1"); } cargo.env("LLVM_CONFIG", &llvm_config); if self.backend != "emscripten" { - let target_config = build.config.target_config.get(&target); + let target_config = builder.config.target_config.get(&target); if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { cargo.env("CFG_LLVM_ROOT", s); } } // Building with a static libstdc++ is only supported on linux right now, // not for MSVC or macOS - if build.config.llvm_static_stdcpp && + if builder.config.llvm_static_stdcpp && !target.contains("freebsd") && !target.contains("windows") && !target.contains("apple") { - let file = compiler_file(build, - build.cxx(target).unwrap(), + let file = compiler_file(builder, + builder.cxx(target).unwrap(), target, "libstdc++.a"); cargo.env("LLVM_STATIC_STDCPP", file); } - if build.config.llvm_link_shared { + if builder.config.llvm_link_shared { cargo.env("LLVM_LINK_SHARED", "1"); } } _ => panic!("unknown backend: {}", self.backend), } - let tmp_stamp = build.cargo_out(compiler, Mode::Librustc, target) + let tmp_stamp = builder.cargo_out(compiler, Mode::Librustc, target) .join(".tmp.stamp"); - let _folder = build.fold_output(|| format!("stage{}-rustc_trans", compiler.stage)); - let files = run_cargo(build, + let _folder = builder.fold_output(|| format!("stage{}-rustc_trans", compiler.stage)); + let files = run_cargo(builder, cargo.arg("--features").arg(features), &tmp_stamp, false); @@ -717,7 +711,7 @@ impl Step for CodegenBackend { codegen_backend.display(), f.display()); } - let stamp = codegen_backend_stamp(build, compiler, target, self.backend); + let stamp = codegen_backend_stamp(builder, compiler, target, self.backend); let codegen_backend = codegen_backend.to_str().unwrap(); t!(t!(File::create(&stamp)).write_all(codegen_backend.as_bytes())); } @@ -732,7 +726,6 @@ impl Step for CodegenBackend { fn copy_codegen_backends_to_sysroot(builder: &Builder, compiler: Compiler, target_compiler: Compiler) { - let build = builder.build; let target = target_compiler.host; // Note that this step is different than all the other `*Link` steps in @@ -751,7 +744,7 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder, } for backend in builder.config.rust_codegen_backends.iter() { - let stamp = codegen_backend_stamp(build, compiler, target, *backend); + let stamp = codegen_backend_stamp(builder, compiler, target, *backend); let mut dylib = String::new(); t!(t!(File::open(&stamp)).read_to_string(&mut dylib)); let file = Path::new(&dylib); @@ -765,7 +758,7 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder, backend, &filename[dot..]) }; - build.copy(&file, &dst.join(target_filename)); + builder.copy(&file, &dst.join(target_filename)); } } @@ -786,36 +779,36 @@ fn copy_lld_to_sysroot(builder: &Builder, /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. -pub fn libstd_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { - build.cargo_out(compiler, Mode::Libstd, target).join(".libstd.stamp") +pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd.stamp") } /// Cargo's output path for libtest in a given stage, compiled by a particular /// compiler for the specified target. -pub fn libtest_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { - build.cargo_out(compiler, Mode::Libtest, target).join(".libtest.stamp") +pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest.stamp") } /// Cargo's output path for librustc in a given stage, compiled by a particular /// compiler for the specified target. -pub fn librustc_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { - build.cargo_out(compiler, Mode::Librustc, target).join(".librustc.stamp") +pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc.stamp") } -fn codegen_backend_stamp(build: &Build, +fn codegen_backend_stamp(builder: &Builder, compiler: Compiler, target: Interned, backend: Interned) -> PathBuf { - build.cargo_out(compiler, Mode::Librustc, target) + builder.cargo_out(compiler, Mode::Librustc, target) .join(format!(".librustc_trans-{}.stamp", backend)) } -fn compiler_file(build: &Build, +fn compiler_file(builder: &Builder, compiler: &Path, target: Interned, file: &str) -> PathBuf { let mut cmd = Command::new(compiler); - cmd.args(build.cflags(target)); + cmd.args(builder.cflags(target)); cmd.arg(format!("-print-file-name={}", file)); let out = output(&mut cmd); PathBuf::from(out.trim()) @@ -840,12 +833,11 @@ impl Step for Sysroot { /// thinks it is by default, but it's the same as the default for stages /// 1-3. fn run(self, builder: &Builder) -> Interned { - let build = builder.build; let compiler = self.compiler; let sysroot = if compiler.stage == 0 { - build.out.join(&compiler.host).join("stage0-sysroot") + builder.out.join(&compiler.host).join("stage0-sysroot") } else { - build.out.join(&compiler.host).join(format!("stage{}", compiler.stage)) + builder.out.join(&compiler.host).join(format!("stage{}", compiler.stage)) }; let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); @@ -872,14 +864,13 @@ impl Step for Assemble { /// Prepare a new compiler from the artifacts in `stage` /// /// This will assemble a compiler in `build/$host/stage$stage`. The compiler - /// must have been previously produced by the `stage - 1` build.build + /// must have been previously produced by the `stage - 1` builder.build /// compiler. fn run(self, builder: &Builder) -> Compiler { - let build = builder.build; let target_compiler = self.target_compiler; if target_compiler.stage == 0 { - assert_eq!(build.build, target_compiler.host, + assert_eq!(builder.config.build, target_compiler.host, "Cannot obtain compiler for non-native build triple at stage 0"); // The stage 0 compiler for the build triple is always pre-built. return target_compiler; @@ -902,14 +893,14 @@ impl Step for Assemble { // FIXME: It may be faster if we build just a stage 1 compiler and then // use that to bootstrap this compiler forward. let build_compiler = - builder.compiler(target_compiler.stage - 1, build.build); + builder.compiler(target_compiler.stage - 1, builder.config.build); // Build the libraries for this compiler to link to (i.e., the libraries // it uses at runtime). NOTE: Crates the target compiler compiles don't // link to these. (FIXME: Is that correct? It seems to be correct most // of the time but I think we do link to these for stage2/bin compilers // when not performing a full bootstrap). - if builder.build.config.keep_stage.map_or(false, |s| target_compiler.stage <= s) { + if builder.config.keep_stage.map_or(false, |s| target_compiler.stage <= s) { builder.verbose("skipping compilation of compiler due to --keep-stage"); let compiler = build_compiler; for stage in 0..min(target_compiler.stage, builder.config.keep_stage.unwrap()) { @@ -924,7 +915,7 @@ impl Step for Assemble { compiler: build_compiler, target: target_compiler.host, }); - for &backend in build.config.rust_codegen_backends.iter() { + for &backend in builder.config.rust_codegen_backends.iter() { builder.ensure(CodegenBackend { compiler: build_compiler, target: target_compiler.host, @@ -933,7 +924,7 @@ impl Step for Assemble { } } - let lld_install = if build.config.lld_enabled { + let lld_install = if builder.config.lld_enabled { Some(builder.ensure(native::Lld { target: target_compiler.host, })) @@ -943,7 +934,7 @@ impl Step for Assemble { let stage = target_compiler.stage; let host = target_compiler.host; - build.info(&format!("Assembling stage{} compiler ({})", stage, host)); + builder.info(&format!("Assembling stage{} compiler ({})", stage, host)); // Link in all dylibs to the libdir let sysroot = builder.sysroot(target_compiler); @@ -965,7 +956,7 @@ impl Step for Assemble { } // Link the compiler binary itself into place - let out_dir = build.cargo_out(build_compiler, Mode::Librustc, host); + let out_dir = builder.cargo_out(build_compiler, Mode::Librustc, host); let rustc = out_dir.join(exe("rustc", &*host)); let bindir = sysroot.join("bin"); t!(fs::create_dir_all(&bindir)); @@ -981,10 +972,10 @@ impl Step for Assemble { /// /// For a particular stage this will link the file listed in `stamp` into the /// `sysroot_dst` provided. -pub fn add_to_sysroot(build: &Build, sysroot_dst: &Path, stamp: &Path) { +pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) { t!(fs::create_dir_all(&sysroot_dst)); - for path in build.read_stamp_file(stamp) { - build.copy(&path, &sysroot_dst.join(path.file_name().unwrap())); + for path in builder.read_stamp_file(stamp) { + builder.copy(&path, &sysroot_dst.join(path.file_name().unwrap())); } } @@ -1011,10 +1002,10 @@ fn stderr_isatty() -> bool { } } -pub fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path, is_check: bool) +pub fn run_cargo(builder: &Builder, cargo: &mut Command, stamp: &Path, is_check: bool) -> Vec { - if build.config.dry_run { + if builder.config.dry_run { return Vec::new(); } @@ -1032,7 +1023,7 @@ pub fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path, is_check: boo // files we need to probe for later. let mut deps = Vec::new(); let mut toplevel = Vec::new(); - let ok = stream_cargo(build, cargo, &mut |msg| { + let ok = stream_cargo(builder, cargo, &mut |msg| { let filenames = match msg { CargoMessage::CompilerArtifact { filenames, .. } => filenames, _ => return, @@ -1141,25 +1132,25 @@ pub fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path, is_check: boo let max = max.unwrap(); let max_path = max_path.unwrap(); if stamp_contents == new_contents && max <= stamp_mtime { - build.verbose(&format!("not updating {:?}; contents equal and {:?} <= {:?}", + builder.verbose(&format!("not updating {:?}; contents equal and {:?} <= {:?}", stamp, max, stamp_mtime)); return deps } if max > stamp_mtime { - build.verbose(&format!("updating {:?} as {:?} changed", stamp, max_path)); + builder.verbose(&format!("updating {:?} as {:?} changed", stamp, max_path)); } else { - build.verbose(&format!("updating {:?} as deps changed", stamp)); + builder.verbose(&format!("updating {:?} as deps changed", stamp)); } t!(t!(File::create(stamp)).write_all(&new_contents)); deps } pub fn stream_cargo( - build: &Build, + builder: &Builder, cargo: &mut Command, cb: &mut FnMut(CargoMessage), ) -> bool { - if build.config.dry_run { + if builder.config.dry_run { return true; } // Instruct Cargo to give us json messages on stdout, critically leaving @@ -1167,7 +1158,7 @@ pub fn stream_cargo( cargo.arg("--message-format").arg("json") .stdout(Stdio::piped()); - if stderr_isatty() && build.ci_env == CiEnv::None && + if stderr_isatty() && builder.ci_env == CiEnv::None && // if the terminal is reported as dumb, then we don't want to enable color for rustc env::var_os("TERM").map(|t| t != *"dumb").unwrap_or(true) { // since we pass message-format=json to cargo, we need to tell the rustc @@ -1176,7 +1167,7 @@ pub fn stream_cargo( cargo.env("RUSTC_COLOR", "1"); } - build.verbose(&format!("running: {:?}", cargo)); + builder.verbose(&format!("running: {:?}", cargo)); let mut child = match cargo.spawn() { Ok(child) => child, Err(e) => panic!("failed to execute command: {:?}\nerror: {}", cargo, e), diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index e1f5d34bf6723..e21a59390b7b6 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -26,7 +26,7 @@ use std::process::{Command, Stdio}; use build_helper::output; -use {Build, Compiler, Mode}; +use {Compiler, Mode}; use channel; use util::{libdir, is_dylib, exe}; use builder::{Builder, RunConfig, ShouldRun, Step}; @@ -36,25 +36,25 @@ use tool::{self, Tool}; use cache::{INTERNER, Interned}; use time; -pub fn pkgname(build: &Build, component: &str) -> String { +pub fn pkgname(builder: &Builder, component: &str) -> String { if component == "cargo" { - format!("{}-{}", component, build.cargo_package_vers()) + format!("{}-{}", component, builder.cargo_package_vers()) } else if component == "rls" { - format!("{}-{}", component, build.rls_package_vers()) + format!("{}-{}", component, builder.rls_package_vers()) } else if component == "rustfmt" { - format!("{}-{}", component, build.rustfmt_package_vers()) + format!("{}-{}", component, builder.rustfmt_package_vers()) } else { assert!(component.starts_with("rust")); - format!("{}-{}", component, build.rust_package_vers()) + format!("{}-{}", component, builder.rust_package_vers()) } } -fn distdir(build: &Build) -> PathBuf { - build.out.join("dist") +fn distdir(builder: &Builder) -> PathBuf { + builder.out.join("dist") } -pub fn tmpdir(build: &Build) -> PathBuf { - build.out.join("tmp/dist") +pub fn tmpdir(builder: &Builder) -> PathBuf { + builder.out.join("tmp/dist") } fn rust_installer(builder: &Builder) -> Command { @@ -84,26 +84,25 @@ impl Step for Docs { /// Builds the `rust-docs` installer component. fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let host = self.host; - let name = pkgname(build, "rust-docs"); + let name = pkgname(builder, "rust-docs"); - build.info(&format!("Dist docs ({})", host)); - if !build.config.docs { - build.info(&format!("\tskipping - docs disabled")); - return distdir(build).join(format!("{}-{}.tar.gz", name, host)); + builder.info(&format!("Dist docs ({})", host)); + if !builder.config.docs { + builder.info(&format!("\tskipping - docs disabled")); + return distdir(builder).join(format!("{}-{}.tar.gz", name, host)); } builder.default_doc(None); - let image = tmpdir(build).join(format!("{}-{}-image", name, host)); + let image = tmpdir(builder).join(format!("{}-{}-image", name, host)); let _ = fs::remove_dir_all(&image); let dst = image.join("share/doc/rust/html"); t!(fs::create_dir_all(&dst)); - let src = build.doc_out(host); - build.cp_r(&src, &dst); + let src = builder.doc_out(host); + builder.cp_r(&src, &dst); let mut cmd = rust_installer(builder); cmd.arg("generate") @@ -111,16 +110,16 @@ impl Step for Docs { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-documentation-is-installed.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rust-docs") .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--bulk-dirs=share/doc/rust/html"); - build.run(&mut cmd); - build.remove_dir(&image); + builder.run(&mut cmd); + builder.remove_dir(&image); - distdir(build).join(format!("{}-{}.tar.gz", name, host)) + distdir(builder).join(format!("{}-{}.tar.gz", name, host)) } } @@ -147,26 +146,25 @@ impl Step for RustcDocs { /// Builds the `rustc-docs` installer component. fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let host = self.host; - let name = pkgname(build, "rustc-docs"); + let name = pkgname(builder, "rustc-docs"); - build.info(&format!("Dist compiler docs ({})", host)); - if !build.config.compiler_docs { - build.info(&format!("\tskipping - compiler docs disabled")); - return distdir(build).join(format!("{}-{}.tar.gz", name, host)); + builder.info(&format!("Dist compiler docs ({})", host)); + if !builder.config.compiler_docs { + builder.info(&format!("\tskipping - compiler docs disabled")); + return distdir(builder).join(format!("{}-{}.tar.gz", name, host)); } builder.default_doc(None); - let image = tmpdir(build).join(format!("{}-{}-image", name, host)); + let image = tmpdir(builder).join(format!("{}-{}-image", name, host)); let _ = fs::remove_dir_all(&image); let dst = image.join("share/doc/rust/html"); t!(fs::create_dir_all(&dst)); - let src = build.compiler_doc_out(host); - build.cp_r(&src, &dst); + let src = builder.compiler_doc_out(host); + builder.cp_r(&src, &dst); let mut cmd = rust_installer(builder); cmd.arg("generate") @@ -174,16 +172,16 @@ impl Step for RustcDocs { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rustc-documentation-is-installed.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rustc-docs") .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--bulk-dirs=share/doc/rust/html"); - build.run(&mut cmd); - build.remove_dir(&image); + builder.run(&mut cmd); + builder.remove_dir(&image); - distdir(build).join(format!("{}-{}.tar.gz", name, host)) + distdir(builder).join(format!("{}-{}.tar.gz", name, host)) } } @@ -207,10 +205,10 @@ fn find_files(files: &[&str], path: &[PathBuf]) -> Vec { } fn make_win_dist( - rust_root: &Path, plat_root: &Path, target_triple: Interned, build: &Build + rust_root: &Path, plat_root: &Path, target_triple: Interned, builder: &Builder ) { //Ask gcc where it keeps its stuff - let mut cmd = Command::new(build.cc(target_triple)); + let mut cmd = Command::new(builder.cc(target_triple)); cmd.arg("-print-search-dirs"); let gcc_out = output(&mut cmd); @@ -296,21 +294,21 @@ fn make_win_dist( let dist_bin_dir = rust_root.join("bin/"); fs::create_dir_all(&dist_bin_dir).expect("creating dist_bin_dir failed"); for src in rustc_dlls { - build.copy_to_folder(&src, &dist_bin_dir); + builder.copy_to_folder(&src, &dist_bin_dir); } //Copy platform tools to platform-specific bin directory let target_bin_dir = plat_root.join("lib").join("rustlib").join(target_triple).join("bin"); fs::create_dir_all(&target_bin_dir).expect("creating target_bin_dir failed"); for src in target_tools { - build.copy_to_folder(&src, &target_bin_dir); + builder.copy_to_folder(&src, &target_bin_dir); } //Copy platform libs to platform-specific lib directory let target_lib_dir = plat_root.join("lib").join("rustlib").join(target_triple).join("lib"); fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed"); for src in target_libs { - build.copy_to_folder(&src, &target_lib_dir); + builder.copy_to_folder(&src, &target_lib_dir); } } @@ -336,16 +334,15 @@ impl Step for Mingw { /// This contains all the bits and pieces to run the MinGW Windows targets /// without any extra installed software (e.g. we bundle gcc, libraries, etc). fn run(self, builder: &Builder) -> Option { - let build = builder.build; let host = self.host; if !host.contains("pc-windows-gnu") { return None; } - build.info(&format!("Dist mingw ({})", host)); - let name = pkgname(build, "rust-mingw"); - let image = tmpdir(build).join(format!("{}-{}-image", name, host)); + builder.info(&format!("Dist mingw ({})", host)); + let name = pkgname(builder, "rust-mingw"); + let image = tmpdir(builder).join(format!("{}-{}-image", name, host)); let _ = fs::remove_dir_all(&image); t!(fs::create_dir_all(&image)); @@ -353,7 +350,7 @@ impl Step for Mingw { // thrown away (this contains the runtime DLLs included in the rustc package // above) and the second argument is where to place all the MinGW components // (which is what we want). - make_win_dist(&tmpdir(build), &image, host, &build); + make_win_dist(&tmpdir(builder), &image, host, &builder); let mut cmd = rust_installer(builder); cmd.arg("generate") @@ -361,14 +358,14 @@ impl Step for Mingw { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-MinGW-is-installed.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rust-mingw") .arg("--legacy-manifest-dirs=rustlib,cargo"); - build.run(&mut cmd); + builder.run(&mut cmd); t!(fs::remove_dir_all(&image)); - Some(distdir(build).join(format!("{}-{}.tar.gz", name, host))) + Some(distdir(builder).join(format!("{}-{}.tar.gz", name, host))) } } @@ -394,15 +391,14 @@ impl Step for Rustc { /// Creates the `rustc` installer component. fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let compiler = self.compiler; let host = self.compiler.host; - build.info(&format!("Dist rustc stage{} ({})", compiler.stage, compiler.host)); - let name = pkgname(build, "rustc"); - let image = tmpdir(build).join(format!("{}-{}-image", name, host)); + builder.info(&format!("Dist rustc stage{} ({})", compiler.stage, compiler.host)); + let name = pkgname(builder, "rustc"); + let image = tmpdir(builder).join(format!("{}-{}-image", name, host)); let _ = fs::remove_dir_all(&image); - let overlay = tmpdir(build).join(format!("{}-{}-overlay", name, host)); + let overlay = tmpdir(builder).join(format!("{}-{}-overlay", name, host)); let _ = fs::remove_dir_all(&overlay); // Prepare the rustc "image", what will actually end up getting installed @@ -411,17 +407,17 @@ impl Step for Rustc { // Prepare the overlay which is part of the tarball but won't actually be // installed let cp = |file: &str| { - build.install(&build.src.join(file), &overlay, 0o644); + builder.install(&builder.src.join(file), &overlay, 0o644); }; cp("COPYRIGHT"); cp("LICENSE-APACHE"); cp("LICENSE-MIT"); cp("README.md"); // tiny morsel of metadata is used by rust-packaging - let version = build.rust_version(); - build.create(&overlay.join("version"), &version); - if let Some(sha) = build.rust_sha() { - build.create(&overlay.join("git-commit-hash"), &sha); + let version = builder.rust_version(); + builder.create(&overlay.join("version"), &version); + if let Some(sha) = builder.rust_sha() { + builder.create(&overlay.join("git-commit-hash"), &sha); } // On MinGW we've got a few runtime DLL dependencies that we need to @@ -435,11 +431,11 @@ impl Step for Rustc { // install will *also* include the rust-mingw package, which also needs // licenses, so to be safe we just include it here in all MinGW packages. if host.contains("pc-windows-gnu") { - make_win_dist(&image, &tmpdir(build), host, build); + make_win_dist(&image, &tmpdir(builder), host, builder); let dst = image.join("share/doc"); t!(fs::create_dir_all(&dst)); - build.cp_r(&build.src.join("src/etc/third-party"), &dst); + builder.cp_r(&builder.src.join("src/etc/third-party"), &dst); } // Finally, wrap everything up in a nice tarball! @@ -449,37 +445,36 @@ impl Step for Rustc { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-is-ready-to-roll.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, host)) .arg("--component-name=rustc") .arg("--legacy-manifest-dirs=rustlib,cargo"); - build.run(&mut cmd); - build.remove_dir(&image); - build.remove_dir(&overlay); + builder.run(&mut cmd); + builder.remove_dir(&image); + builder.remove_dir(&overlay); - return distdir(build).join(format!("{}-{}.tar.gz", name, host)); + return distdir(builder).join(format!("{}-{}.tar.gz", name, host)); fn prepare_image(builder: &Builder, compiler: Compiler, image: &Path) { let host = compiler.host; - let build = builder.build; let src = builder.sysroot(compiler); let libdir = libdir(&host); // Copy rustc/rustdoc binaries t!(fs::create_dir_all(image.join("bin"))); - build.cp_r(&src.join("bin"), &image.join("bin")); + builder.cp_r(&src.join("bin"), &image.join("bin")); - build.install(&builder.rustdoc(compiler.host), &image.join("bin"), 0o755); + builder.install(&builder.rustdoc(compiler.host), &image.join("bin"), 0o755); // Copy runtime DLLs needed by the compiler if libdir != "bin" { - for entry in build.read_dir(&src.join(libdir)) { + for entry in builder.read_dir(&src.join(libdir)) { let name = entry.file_name(); if let Some(s) = name.to_str() { if is_dylib(s) { - build.install(&entry.path(), &image.join(libdir), 0o644); + builder.install(&entry.path(), &image.join(libdir), 0o644); } } } @@ -490,7 +485,7 @@ impl Step for Rustc { let backends_rel = backends_src.strip_prefix(&src).unwrap(); let backends_dst = image.join(&backends_rel); t!(fs::create_dir_all(&backends_dst)); - build.cp_r(&backends_src, &backends_dst); + builder.cp_r(&backends_src, &backends_dst); // Copy over lld if it's there if builder.config.lld_enabled { @@ -505,22 +500,22 @@ impl Step for Rustc { .join("bin") .join(&exe); t!(fs::create_dir_all(&dst.parent().unwrap())); - build.copy(&src, &dst); + builder.copy(&src, &dst); } // Man pages t!(fs::create_dir_all(image.join("share/man/man1"))); - let man_src = build.src.join("src/doc/man"); + let man_src = builder.src.join("src/doc/man"); let man_dst = image.join("share/man/man1"); let month_year = t!(time::strftime("%B %Y", &time::now())); // don't use our `bootstrap::util::{copy, cp_r}`, because those try // to hardlink, and we don't want to edit the source templates - for file_entry in build.read_dir(&man_src) { + for file_entry in builder.read_dir(&man_src) { let page_src = file_entry.path(); let page_dst = man_dst.join(file_entry.file_name()); t!(fs::copy(&page_src, &page_dst)); // template in month/year and version number - build.replace_in_file(&page_dst, + builder.replace_in_file(&page_dst, &[("", &month_year), ("", channel::CFG_RELEASE_NUM)]); } @@ -533,7 +528,7 @@ impl Step for Rustc { // Misc license info let cp = |file: &str| { - build.install(&build.src.join(file), &image.join("share/doc/rust"), 0o644); + builder.install(&builder.src.join(file), &image.join("share/doc/rust"), 0o644); }; cp("COPYRIGHT"); cp("LICENSE-APACHE"); @@ -565,17 +560,16 @@ impl Step for DebuggerScripts { /// Copies debugger scripts for `target` into the `sysroot` specified. fn run(self, builder: &Builder) { - let build = builder.build; let host = self.host; let sysroot = self.sysroot; let dst = sysroot.join("lib/rustlib/etc"); t!(fs::create_dir_all(&dst)); let cp_debugger_script = |file: &str| { - build.install(&build.src.join("src/etc/").join(file), &dst, 0o644); + builder.install(&builder.src.join("src/etc/").join(file), &dst, 0o644); }; if host.contains("windows-msvc") { // windbg debugger scripts - build.install(&build.src.join("src/etc/rust-windbg.cmd"), &sysroot.join("bin"), + builder.install(&builder.src.join("src/etc/rust-windbg.cmd"), &sysroot.join("bin"), 0o755); cp_debugger_script("natvis/intrinsic.natvis"); @@ -585,14 +579,14 @@ impl Step for DebuggerScripts { cp_debugger_script("debugger_pretty_printers_common.py"); // gdb debugger scripts - build.install(&build.src.join("src/etc/rust-gdb"), &sysroot.join("bin"), + builder.install(&builder.src.join("src/etc/rust-gdb"), &sysroot.join("bin"), 0o755); cp_debugger_script("gdb_load_rust_pretty_printers.py"); cp_debugger_script("gdb_rust_pretty_printing.py"); // lldb debugger scripts - build.install(&build.src.join("src/etc/rust-lldb"), &sysroot.join("bin"), + builder.install(&builder.src.join("src/etc/rust-lldb"), &sysroot.join("bin"), 0o755); cp_debugger_script("lldb_rust_formatters.py"); @@ -616,33 +610,33 @@ impl Step for Std { fn make_run(run: RunConfig) { run.builder.ensure(Std { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let compiler = self.compiler; let target = self.target; - let name = pkgname(build, "rust-std"); - build.info(&format!("Dist std stage{} ({} -> {})", compiler.stage, &compiler.host, target)); + let name = pkgname(builder, "rust-std"); + builder.info(&format!("Dist std stage{} ({} -> {})", + compiler.stage, &compiler.host, target)); // The only true set of target libraries came from the build triple, so // let's reduce redundant work by only producing archives from that host. - if compiler.host != build.build { - build.info(&format!("\tskipping, not a build host")); - return distdir(build).join(format!("{}-{}.tar.gz", name, target)); + if compiler.host != builder.config.build { + builder.info(&format!("\tskipping, not a build host")); + return distdir(builder).join(format!("{}-{}.tar.gz", name, target)); } // We want to package up as many target libraries as possible // for the `rust-std` package, so if this is a host target we // depend on librustc and otherwise we just depend on libtest. - if build.hosts.iter().any(|t| t == target) { + if builder.hosts.iter().any(|t| t == target) { builder.ensure(compile::Rustc { compiler, target }); } else { - if build.no_std(target) == Some(true) { + if builder.no_std(target) == Some(true) { // the `test` doesn't compile for no-std targets builder.ensure(compile::Std { compiler, target }); } else { @@ -650,16 +644,16 @@ impl Step for Std { } } - let image = tmpdir(build).join(format!("{}-{}-image", name, target)); + let image = tmpdir(builder).join(format!("{}-{}-image", name, target)); let _ = fs::remove_dir_all(&image); let dst = image.join("lib/rustlib").join(target); t!(fs::create_dir_all(&dst)); let mut src = builder.sysroot_libdir(compiler, target).to_path_buf(); src.pop(); // Remove the trailing /lib folder from the sysroot_libdir - build.cp_filtered(&src, &dst, &|path| { + builder.cp_filtered(&src, &dst, &|path| { let name = path.file_name().and_then(|s| s.to_str()); - name != Some(build.config.rust_codegen_backends_dir.as_str()) && + name != Some(builder.config.rust_codegen_backends_dir.as_str()) && name != Some("bin") }); @@ -670,14 +664,14 @@ impl Step for Std { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=std-is-standing-at-the-ready.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg(format!("--package-name={}-{}", name, target)) .arg(format!("--component-name=rust-std-{}", target)) .arg("--legacy-manifest-dirs=rustlib,cargo"); - build.run(&mut cmd); - build.remove_dir(&image); - distdir(build).join(format!("{}-{}.tar.gz", name, target)) + builder.run(&mut cmd); + builder.remove_dir(&image); + distdir(builder).join(format!("{}-{}.tar.gz", name, target)) } } @@ -693,50 +687,49 @@ impl Step for Analysis { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("analysis").default_condition(builder.build.config.extended) + run.path("analysis").default_condition(builder.config.extended) } fn make_run(run: RunConfig) { run.builder.ensure(Analysis { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } /// Creates a tarball of save-analysis metadata, if available. fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let compiler = self.compiler; let target = self.target; - assert!(build.config.extended); - build.info(&format!("Dist analysis")); - let name = pkgname(build, "rust-analysis"); + assert!(builder.config.extended); + builder.info(&format!("Dist analysis")); + let name = pkgname(builder, "rust-analysis"); - if &compiler.host != build.build { - build.info(&format!("\tskipping, not a build host")); - return distdir(build).join(format!("{}-{}.tar.gz", name, target)); + if &compiler.host != builder.config.build { + builder.info(&format!("\tskipping, not a build host")); + return distdir(builder).join(format!("{}-{}.tar.gz", name, target)); } builder.ensure(Std { compiler, target }); // Package save-analysis from stage1 if not doing a full bootstrap, as the // stage2 artifacts is simply copied from stage1 in that case. - let compiler = if build.force_use_stage1(compiler, target) { + let compiler = if builder.force_use_stage1(compiler, target) { builder.compiler(1, compiler.host) } else { compiler.clone() }; - let image = tmpdir(build).join(format!("{}-{}-image", name, target)); + let image = tmpdir(builder).join(format!("{}-{}-image", name, target)); - let src = build.stage_out(compiler, Mode::Libstd) - .join(target).join(build.cargo_dir()).join("deps"); + let src = builder.stage_out(compiler, Mode::Libstd) + .join(target).join(builder.cargo_dir()).join("deps"); let image_src = src.join("save-analysis"); let dst = image.join("lib/rustlib").join(target).join("analysis"); t!(fs::create_dir_all(&dst)); - build.info(&format!("image_src: {:?}, dst: {:?}", image_src, dst)); - build.cp_r(&image_src, &dst); + builder.info(&format!("image_src: {:?}, dst: {:?}", image_src, dst)); + builder.cp_r(&image_src, &dst); let mut cmd = rust_installer(builder); cmd.arg("generate") @@ -744,18 +737,18 @@ impl Step for Analysis { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=save-analysis-saved.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg(format!("--package-name={}-{}", name, target)) .arg(format!("--component-name=rust-analysis-{}", target)) .arg("--legacy-manifest-dirs=rustlib,cargo"); - build.run(&mut cmd); - build.remove_dir(&image); - distdir(build).join(format!("{}-{}.tar.gz", name, target)) + builder.run(&mut cmd); + builder.remove_dir(&image); + distdir(builder).join(format!("{}-{}.tar.gz", name, target)) } } -fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_dir: &Path) { +fn copy_src_dirs(builder: &Builder, src_dirs: &[&str], exclude_dirs: &[&str], dst_dir: &Path) { fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool { let spath = match path.to_str() { Some(path) => path, @@ -794,7 +787,8 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_di for item in src_dirs { let dst = &dst_dir.join(item); t!(fs::create_dir_all(dst)); - build.cp_filtered(&build.src.join(item), dst, &|path| filter_fn(exclude_dirs, item, path)); + builder.cp_filtered( + &builder.src.join(item), dst, &|path| filter_fn(exclude_dirs, item, path)); } } @@ -817,11 +811,10 @@ impl Step for Src { /// Creates the `rust-src` installer component fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; - build.info(&format!("Dist src")); + builder.info(&format!("Dist src")); - let name = pkgname(build, "rust-src"); - let image = tmpdir(build).join(format!("{}-image", name)); + let name = pkgname(builder, "rust-src"); + let image = tmpdir(builder).join(format!("{}-image", name)); let _ = fs::remove_dir_all(&image); let dst = image.join("lib/rustlib/src"); @@ -866,9 +859,9 @@ impl Step for Src { "src/jemalloc/test/unit", ]; - copy_src_dirs(build, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src); + copy_src_dirs(builder, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src); for file in src_files.iter() { - build.copy(&build.src.join(file), &dst_src.join(file)); + builder.copy(&builder.src.join(file), &dst_src.join(file)); } // Create source tarball in rust-installer format @@ -878,15 +871,15 @@ impl Step for Src { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Awesome-Source.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg(format!("--package-name={}", name)) .arg("--component-name=rust-src") .arg("--legacy-manifest-dirs=rustlib,cargo"); - build.run(&mut cmd); + builder.run(&mut cmd); - build.remove_dir(&image); - distdir(build).join(&format!("{}.tar.gz", name)) + builder.remove_dir(&image); + distdir(builder).join(&format!("{}.tar.gz", name)) } } @@ -912,12 +905,11 @@ impl Step for PlainSourceTarball { /// Creates the plain source tarball fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; - build.info(&format!("Create plain source tarball")); + builder.info(&format!("Create plain source tarball")); // Make sure that the root folder of tarball has the correct name - let plain_name = format!("{}-src", pkgname(build, "rustc")); - let plain_dst_src = tmpdir(build).join(&plain_name); + let plain_name = format!("{}-src", pkgname(builder, "rustc")); + let plain_dst_src = tmpdir(builder).join(&plain_name); let _ = fs::remove_dir_all(&plain_dst_src); t!(fs::create_dir_all(&plain_dst_src)); @@ -937,68 +929,68 @@ impl Step for PlainSourceTarball { "src", ]; - copy_src_dirs(build, &src_dirs[..], &[], &plain_dst_src); + copy_src_dirs(builder, &src_dirs[..], &[], &plain_dst_src); // Copy the files normally for item in &src_files { - build.copy(&build.src.join(item), &plain_dst_src.join(item)); + builder.copy(&builder.src.join(item), &plain_dst_src.join(item)); } // Create the version file - build.create(&plain_dst_src.join("version"), &build.rust_version()); - if let Some(sha) = build.rust_sha() { - build.create(&plain_dst_src.join("git-commit-hash"), &sha); + builder.create(&plain_dst_src.join("version"), &builder.rust_version()); + if let Some(sha) = builder.rust_sha() { + builder.create(&plain_dst_src.join("git-commit-hash"), &sha); } // If we're building from git sources, we need to vendor a complete distribution. - if build.rust_info.is_git() { + if builder.rust_info.is_git() { // Get cargo-vendor installed, if it isn't already. let mut has_cargo_vendor = false; - let mut cmd = Command::new(&build.initial_cargo); + let mut cmd = Command::new(&builder.initial_cargo); for line in output(cmd.arg("install").arg("--list")).lines() { has_cargo_vendor |= line.starts_with("cargo-vendor "); } if !has_cargo_vendor { - let mut cmd = Command::new(&build.initial_cargo); + let mut cmd = Command::new(&builder.initial_cargo); cmd.arg("install") .arg("--force") .arg("--debug") .arg("--vers").arg(CARGO_VENDOR_VERSION) .arg("cargo-vendor") - .env("RUSTC", &build.initial_rustc); - if let Some(dir) = build.openssl_install_dir(build.config.build) { + .env("RUSTC", &builder.initial_rustc); + if let Some(dir) = builder.openssl_install_dir(builder.config.build) { builder.ensure(native::Openssl { - target: build.config.build, + target: builder.config.build, }); cmd.env("OPENSSL_DIR", dir); } - build.run(&mut cmd); + builder.run(&mut cmd); } // Vendor all Cargo dependencies - let mut cmd = Command::new(&build.initial_cargo); + let mut cmd = Command::new(&builder.initial_cargo); cmd.arg("vendor") .current_dir(&plain_dst_src.join("src")); - build.run(&mut cmd); + builder.run(&mut cmd); } // Create plain source tarball - let plain_name = format!("rustc-{}-src", build.rust_package_vers()); - let mut tarball = distdir(build).join(&format!("{}.tar.gz", plain_name)); + let plain_name = format!("rustc-{}-src", builder.rust_package_vers()); + let mut tarball = distdir(builder).join(&format!("{}.tar.gz", plain_name)); tarball.set_extension(""); // strip .gz tarball.set_extension(""); // strip .tar if let Some(dir) = tarball.parent() { - build.create_dir(&dir); + builder.create_dir(&dir); } - build.info(&format!("running installer")); + builder.info(&format!("running installer")); let mut cmd = rust_installer(builder); cmd.arg("tarball") .arg("--input").arg(&plain_name) .arg("--output").arg(&tarball) .arg("--work-dir=.") - .current_dir(tmpdir(build)); - build.run(&mut cmd); - distdir(build).join(&format!("{}.tar.gz", plain_name)) + .current_dir(tmpdir(builder)); + builder.run(&mut cmd); + distdir(builder).join(&format!("{}.tar.gz", plain_name)) } } @@ -1043,52 +1035,51 @@ impl Step for Cargo { } fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let stage = self.stage; let target = self.target; - build.info(&format!("Dist cargo stage{} ({})", stage, target)); - let src = build.src.join("src/tools/cargo"); + builder.info(&format!("Dist cargo stage{} ({})", stage, target)); + let src = builder.src.join("src/tools/cargo"); let etc = src.join("src/etc"); - let release_num = build.release_num("cargo"); - let name = pkgname(build, "cargo"); - let version = builder.cargo_info.version(build, &release_num); + let release_num = builder.release_num("cargo"); + let name = pkgname(builder, "cargo"); + let version = builder.cargo_info.version(builder, &release_num); - let tmp = tmpdir(build); + let tmp = tmpdir(builder); let image = tmp.join("cargo-image"); drop(fs::remove_dir_all(&image)); - build.create_dir(&image); + builder.create_dir(&image); // Prepare the image directory - build.create_dir(&image.join("share/zsh/site-functions")); - build.create_dir(&image.join("etc/bash_completion.d")); + builder.create_dir(&image.join("share/zsh/site-functions")); + builder.create_dir(&image.join("etc/bash_completion.d")); let cargo = builder.ensure(tool::Cargo { - compiler: builder.compiler(stage, build.build), + compiler: builder.compiler(stage, builder.config.build), target }); - build.install(&cargo, &image.join("bin"), 0o755); + builder.install(&cargo, &image.join("bin"), 0o755); for man in t!(etc.join("man").read_dir()) { let man = t!(man); - build.install(&man.path(), &image.join("share/man/man1"), 0o644); + builder.install(&man.path(), &image.join("share/man/man1"), 0o644); } - build.install(&etc.join("_cargo"), &image.join("share/zsh/site-functions"), 0o644); - build.copy(&etc.join("cargo.bashcomp.sh"), + builder.install(&etc.join("_cargo"), &image.join("share/zsh/site-functions"), 0o644); + builder.copy(&etc.join("cargo.bashcomp.sh"), &image.join("etc/bash_completion.d/cargo")); let doc = image.join("share/doc/cargo"); - build.install(&src.join("README.md"), &doc, 0o644); - build.install(&src.join("LICENSE-MIT"), &doc, 0o644); - build.install(&src.join("LICENSE-APACHE"), &doc, 0o644); - build.install(&src.join("LICENSE-THIRD-PARTY"), &doc, 0o644); + builder.install(&src.join("README.md"), &doc, 0o644); + builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); + builder.install(&src.join("LICENSE-THIRD-PARTY"), &doc, 0o644); // Prepare the overlay let overlay = tmp.join("cargo-overlay"); drop(fs::remove_dir_all(&overlay)); - build.create_dir(&overlay); - build.install(&src.join("README.md"), &overlay, 0o644); - build.install(&src.join("LICENSE-MIT"), &overlay, 0o644); - build.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); - build.install(&src.join("LICENSE-THIRD-PARTY"), &overlay, 0o644); - build.create(&overlay.join("version"), &version); + builder.create_dir(&overlay); + builder.install(&src.join("README.md"), &overlay, 0o644); + builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); + builder.install(&src.join("LICENSE-THIRD-PARTY"), &overlay, 0o644); + builder.create(&overlay.join("version"), &version); // Generate the installer tarball let mut cmd = rust_installer(builder); @@ -1097,14 +1088,14 @@ impl Step for Cargo { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-is-ready-to-roll.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, target)) .arg("--component-name=cargo") .arg("--legacy-manifest-dirs=rustlib,cargo"); - build.run(&mut cmd); - distdir(build).join(format!("{}-{}.tar.gz", name, target)) + builder.run(&mut cmd); + distdir(builder).join(format!("{}-{}.tar.gz", name, target)) } } @@ -1130,18 +1121,17 @@ impl Step for Rls { } fn run(self, builder: &Builder) -> Option { - let build = builder.build; let stage = self.stage; let target = self.target; - assert!(build.config.extended); + assert!(builder.config.extended); - build.info(&format!("Dist RLS stage{} ({})", stage, target)); - let src = build.src.join("src/tools/rls"); - let release_num = build.release_num("rls"); - let name = pkgname(build, "rls"); - let version = build.rls_info.version(build, &release_num); + builder.info(&format!("Dist RLS stage{} ({})", stage, target)); + let src = builder.src.join("src/tools/rls"); + let release_num = builder.release_num("rls"); + let name = pkgname(builder, "rls"); + let version = builder.rls_info.version(builder, &release_num); - let tmp = tmpdir(build); + let tmp = tmpdir(builder); let image = tmp.join("rls-image"); drop(fs::remove_dir_all(&image)); t!(fs::create_dir_all(&image)); @@ -1150,24 +1140,24 @@ impl Step for Rls { // We expect RLS to build, because we've exited this step above if tool // state for RLS isn't testing. let rls = builder.ensure(tool::Rls { - compiler: builder.compiler(stage, build.build), + compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() }).or_else(|| { println!("Unable to build RLS, skipping dist"); None })?; - build.install(&rls, &image.join("bin"), 0o755); + builder.install(&rls, &image.join("bin"), 0o755); let doc = image.join("share/doc/rls"); - build.install(&src.join("README.md"), &doc, 0o644); - build.install(&src.join("LICENSE-MIT"), &doc, 0o644); - build.install(&src.join("LICENSE-APACHE"), &doc, 0o644); + builder.install(&src.join("README.md"), &doc, 0o644); + builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); // Prepare the overlay let overlay = tmp.join("rls-overlay"); drop(fs::remove_dir_all(&overlay)); t!(fs::create_dir_all(&overlay)); - build.install(&src.join("README.md"), &overlay, 0o644); - build.install(&src.join("LICENSE-MIT"), &overlay, 0o644); - build.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); - build.create(&overlay.join("version"), &version); + builder.install(&src.join("README.md"), &overlay, 0o644); + builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); + builder.create(&overlay.join("version"), &version); // Generate the installer tarball let mut cmd = rust_installer(builder); @@ -1176,15 +1166,15 @@ impl Step for Rls { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=RLS-ready-to-serve.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, target)) .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--component-name=rls-preview"); - build.run(&mut cmd); - Some(distdir(build).join(format!("{}-{}.tar.gz", name, target))) + builder.run(&mut cmd); + Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target))) } } @@ -1211,46 +1201,45 @@ impl Step for Rustfmt { } fn run(self, builder: &Builder) -> Option { - let build = builder.build; let stage = self.stage; let target = self.target; - build.info(&format!("Dist Rustfmt stage{} ({})", stage, target)); - let src = build.src.join("src/tools/rustfmt"); - let release_num = build.release_num("rustfmt"); - let name = pkgname(build, "rustfmt"); - let version = build.rustfmt_info.version(build, &release_num); + builder.info(&format!("Dist Rustfmt stage{} ({})", stage, target)); + let src = builder.src.join("src/tools/rustfmt"); + let release_num = builder.release_num("rustfmt"); + let name = pkgname(builder, "rustfmt"); + let version = builder.rustfmt_info.version(builder, &release_num); - let tmp = tmpdir(build); + let tmp = tmpdir(builder); let image = tmp.join("rustfmt-image"); drop(fs::remove_dir_all(&image)); - build.create_dir(&image); + builder.create_dir(&image); // Prepare the image directory let rustfmt = builder.ensure(tool::Rustfmt { - compiler: builder.compiler(stage, build.build), + compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() }).or_else(|| { println!("Unable to build Rustfmt, skipping dist"); None })?; let cargofmt = builder.ensure(tool::Cargofmt { - compiler: builder.compiler(stage, build.build), + compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() }).or_else(|| { println!("Unable to build Cargofmt, skipping dist"); None })?; - build.install(&rustfmt, &image.join("bin"), 0o755); - build.install(&cargofmt, &image.join("bin"), 0o755); + builder.install(&rustfmt, &image.join("bin"), 0o755); + builder.install(&cargofmt, &image.join("bin"), 0o755); let doc = image.join("share/doc/rustfmt"); - build.install(&src.join("README.md"), &doc, 0o644); - build.install(&src.join("LICENSE-MIT"), &doc, 0o644); - build.install(&src.join("LICENSE-APACHE"), &doc, 0o644); + builder.install(&src.join("README.md"), &doc, 0o644); + builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); // Prepare the overlay let overlay = tmp.join("rustfmt-overlay"); drop(fs::remove_dir_all(&overlay)); - build.create_dir(&overlay); - build.install(&src.join("README.md"), &overlay, 0o644); - build.install(&src.join("LICENSE-MIT"), &overlay, 0o644); - build.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); - build.create(&overlay.join("version"), &version); + builder.create_dir(&overlay); + builder.install(&src.join("README.md"), &overlay, 0o644); + builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644); + builder.create(&overlay.join("version"), &version); // Generate the installer tarball let mut cmd = rust_installer(builder); @@ -1259,15 +1248,15 @@ impl Step for Rustfmt { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=rustfmt-ready-to-fmt.") .arg("--image-dir").arg(&image) - .arg("--work-dir").arg(&tmpdir(build)) - .arg("--output-dir").arg(&distdir(build)) + .arg("--work-dir").arg(&tmpdir(builder)) + .arg("--output-dir").arg(&distdir(builder)) .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, target)) .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--component-name=rustfmt-preview"); - build.run(&mut cmd); - Some(distdir(build).join(format!("{}-{}.tar.gz", name, target))) + builder.run(&mut cmd); + Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target))) } } @@ -1291,18 +1280,17 @@ impl Step for Extended { fn make_run(run: RunConfig) { run.builder.ensure(Extended { stage: run.builder.top_stage, - host: run.builder.build.build, + host: run.builder.config.build, target: run.target, }); } /// Creates a combined installer for the specified target in the provided stage. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let target = self.target; - build.info(&format!("Dist extended stage{} ({})", stage, target)); + builder.info(&format!("Dist extended stage{} ({})", stage, target)); let rustc_installer = builder.ensure(Rustc { compiler: builder.compiler(stage, target), @@ -1322,21 +1310,21 @@ impl Step for Extended { target, }); - let tmp = tmpdir(build); + let tmp = tmpdir(builder); let overlay = tmp.join("extended-overlay"); - let etc = build.src.join("src/etc/installer"); + let etc = builder.src.join("src/etc/installer"); let work = tmp.join("work"); let _ = fs::remove_dir_all(&overlay); - build.install(&build.src.join("COPYRIGHT"), &overlay, 0o644); - build.install(&build.src.join("LICENSE-APACHE"), &overlay, 0o644); - build.install(&build.src.join("LICENSE-MIT"), &overlay, 0o644); - let version = build.rust_version(); - build.create(&overlay.join("version"), &version); - if let Some(sha) = build.rust_sha() { - build.create(&overlay.join("git-commit-hash"), &sha); + builder.install(&builder.src.join("COPYRIGHT"), &overlay, 0o644); + builder.install(&builder.src.join("LICENSE-APACHE"), &overlay, 0o644); + builder.install(&builder.src.join("LICENSE-MIT"), &overlay, 0o644); + let version = builder.rust_version(); + builder.create(&overlay.join("version"), &version); + if let Some(sha) = builder.rust_sha() { + builder.create(&overlay.join("git-commit-hash"), &sha); } - build.install(&etc.join("README.md"), &overlay, 0o644); + builder.install(&etc.join("README.md"), &overlay, 0o644); // When rust-std package split from rustc, we needed to ensure that during // upgrades rustc was upgraded before rust-std. To avoid rustc clobbering @@ -1349,7 +1337,7 @@ impl Step for Extended { tarballs.extend(rustfmt_installer.clone()); tarballs.push(analysis_installer); tarballs.push(std_installer); - if build.config.docs { + if builder.config.docs { tarballs.push(docs_installer); } if target.contains("pc-windows-gnu") { @@ -1367,17 +1355,17 @@ impl Step for Extended { .arg("--rel-manifest-dir=rustlib") .arg("--success-message=Rust-is-ready-to-roll.") .arg("--work-dir").arg(&work) - .arg("--output-dir").arg(&distdir(build)) - .arg(format!("--package-name={}-{}", pkgname(build, "rust"), target)) + .arg("--output-dir").arg(&distdir(builder)) + .arg(format!("--package-name={}-{}", pkgname(builder, "rust"), target)) .arg("--legacy-manifest-dirs=rustlib,cargo") .arg("--input-tarballs").arg(input_tarballs) .arg("--non-installed-overlay").arg(&overlay); - build.run(&mut cmd); + builder.run(&mut cmd); let mut license = String::new(); - license += &build.read(&build.src.join("COPYRIGHT")); - license += &build.read(&build.src.join("LICENSE-APACHE")); - license += &build.read(&build.src.join("LICENSE-MIT")); + license += &builder.read(&builder.src.join("COPYRIGHT")); + license += &builder.read(&builder.src.join("LICENSE-APACHE")); + license += &builder.read(&builder.src.join("LICENSE-MIT")); license.push_str("\n"); license.push_str("\n"); @@ -1432,14 +1420,14 @@ impl Step for Extended { .arg("--scripts").arg(pkg.join(component)) .arg("--nopayload") .arg(pkg.join(component).with_extension("pkg")); - build.run(&mut cmd); + builder.run(&mut cmd); }; let prepare = |name: &str| { - build.create_dir(&pkg.join(name)); - build.cp_r(&work.join(&format!("{}-{}", pkgname(build, name), target)), + builder.create_dir(&pkg.join(name)); + builder.cp_r(&work.join(&format!("{}-{}", pkgname(builder, name), target)), &pkg.join(name)); - build.install(&etc.join("pkg/postinstall"), &pkg.join(name), 0o755); + builder.install(&etc.join("pkg/postinstall"), &pkg.join(name), 0o755); pkgbuild(name); }; prepare("rustc"); @@ -1453,20 +1441,20 @@ impl Step for Extended { } // create an 'uninstall' package - build.install(&etc.join("pkg/postinstall"), &pkg.join("uninstall"), 0o755); + builder.install(&etc.join("pkg/postinstall"), &pkg.join("uninstall"), 0o755); pkgbuild("uninstall"); - build.create_dir(&pkg.join("res")); - build.create(&pkg.join("res/LICENSE.txt"), &license); - build.install(&etc.join("gfx/rust-logo.png"), &pkg.join("res"), 0o644); + builder.create_dir(&pkg.join("res")); + builder.create(&pkg.join("res/LICENSE.txt"), &license); + builder.install(&etc.join("gfx/rust-logo.png"), &pkg.join("res"), 0o644); let mut cmd = Command::new("productbuild"); cmd.arg("--distribution").arg(xform(&etc.join("pkg/Distribution.xml"))) .arg("--resources").arg(pkg.join("res")) - .arg(distdir(build).join(format!("{}-{}.pkg", - pkgname(build, "rust"), + .arg(distdir(builder).join(format!("{}-{}.pkg", + pkgname(builder, "rust"), target))) .arg("--package-path").arg(&pkg); - build.run(&mut cmd); + builder.run(&mut cmd); } if target.contains("windows") { @@ -1474,7 +1462,7 @@ impl Step for Extended { let _ = fs::remove_dir_all(&exe); let prepare = |name: &str| { - build.create_dir(&exe.join(name)); + builder.create_dir(&exe.join(name)); let dir = if name == "rust-std" || name == "rust-analysis" { format!("{}-{}", name, target) } else if name == "rls" { @@ -1482,10 +1470,10 @@ impl Step for Extended { } else { name.to_string() }; - build.cp_r(&work.join(&format!("{}-{}", pkgname(build, name), target)) + builder.cp_r(&work.join(&format!("{}-{}", pkgname(builder, name), target)) .join(dir), &exe.join(name)); - build.remove(&exe.join(name).join("manifest.in")); + builder.remove(&exe.join(name).join("manifest.in")); }; prepare("rustc"); prepare("cargo"); @@ -1499,11 +1487,11 @@ impl Step for Extended { prepare("rust-mingw"); } - build.install(&xform(&etc.join("exe/rust.iss")), &exe, 0o644); - build.install(&etc.join("exe/modpath.iss"), &exe, 0o644); - build.install(&etc.join("exe/upgrade.iss"), &exe, 0o644); - build.install(&etc.join("gfx/rust-logo.ico"), &exe, 0o644); - build.create(&exe.join("LICENSE.txt"), &license); + builder.install(&xform(&etc.join("exe/rust.iss")), &exe, 0o644); + builder.install(&etc.join("exe/modpath.iss"), &exe, 0o644); + builder.install(&etc.join("exe/upgrade.iss"), &exe, 0o644); + builder.install(&etc.join("gfx/rust-logo.ico"), &exe, 0o644); + builder.create(&exe.join("LICENSE.txt"), &license); // Generate exe installer let mut cmd = Command::new("iscc"); @@ -1512,10 +1500,10 @@ impl Step for Extended { if target.contains("windows-gnu") { cmd.arg("/dMINGW"); } - add_env(build, &mut cmd, target); - build.run(&mut cmd); - build.install(&exe.join(format!("{}-{}.exe", pkgname(build, "rust"), target)), - &distdir(build), + add_env(builder, &mut cmd, target); + builder.run(&mut cmd); + builder.install(&exe.join(format!("{}-{}.exe", pkgname(builder, "rust"), target)), + &distdir(builder), 0o755); // Generate msi installer @@ -1525,7 +1513,7 @@ impl Step for Extended { let light = wix.join("bin/light.exe"); let heat_flags = ["-nologo", "-gg", "-sfrag", "-srd", "-sreg"]; - build.run(Command::new(&heat) + builder.run(Command::new(&heat) .current_dir(&exe) .arg("dir") .arg("rustc") @@ -1534,7 +1522,7 @@ impl Step for Extended { .arg("-dr").arg("Rustc") .arg("-var").arg("var.RustcDir") .arg("-out").arg(exe.join("RustcGroup.wxs"))); - build.run(Command::new(&heat) + builder.run(Command::new(&heat) .current_dir(&exe) .arg("dir") .arg("rust-docs") @@ -1544,7 +1532,7 @@ impl Step for Extended { .arg("-var").arg("var.DocsDir") .arg("-out").arg(exe.join("DocsGroup.wxs")) .arg("-t").arg(etc.join("msi/squash-components.xsl"))); - build.run(Command::new(&heat) + builder.run(Command::new(&heat) .current_dir(&exe) .arg("dir") .arg("cargo") @@ -1554,7 +1542,7 @@ impl Step for Extended { .arg("-var").arg("var.CargoDir") .arg("-out").arg(exe.join("CargoGroup.wxs")) .arg("-t").arg(etc.join("msi/remove-duplicates.xsl"))); - build.run(Command::new(&heat) + builder.run(Command::new(&heat) .current_dir(&exe) .arg("dir") .arg("rust-std") @@ -1564,7 +1552,7 @@ impl Step for Extended { .arg("-var").arg("var.StdDir") .arg("-out").arg(exe.join("StdGroup.wxs"))); if rls_installer.is_some() { - build.run(Command::new(&heat) + builder.run(Command::new(&heat) .current_dir(&exe) .arg("dir") .arg("rls") @@ -1575,7 +1563,7 @@ impl Step for Extended { .arg("-out").arg(exe.join("RlsGroup.wxs")) .arg("-t").arg(etc.join("msi/remove-duplicates.xsl"))); } - build.run(Command::new(&heat) + builder.run(Command::new(&heat) .current_dir(&exe) .arg("dir") .arg("rust-analysis") @@ -1586,7 +1574,7 @@ impl Step for Extended { .arg("-out").arg(exe.join("AnalysisGroup.wxs")) .arg("-t").arg(etc.join("msi/remove-duplicates.xsl"))); if target.contains("windows-gnu") { - build.run(Command::new(&heat) + builder.run(Command::new(&heat) .current_dir(&exe) .arg("dir") .arg("rust-mingw") @@ -1612,7 +1600,7 @@ impl Step for Extended { .arg("-arch").arg(&arch) .arg("-out").arg(&output) .arg(&input); - add_env(build, &mut cmd, target); + add_env(builder, &mut cmd, target); if rls_installer.is_some() { cmd.arg("-dRlsDir=rls"); @@ -1620,7 +1608,7 @@ impl Step for Extended { if target.contains("windows-gnu") { cmd.arg("-dGccDir=rust-mingw"); } - build.run(&mut cmd); + builder.run(&mut cmd); }; candle(&xform(&etc.join("msi/rust.wxs"))); candle(&etc.join("msi/ui.wxs")); @@ -1638,11 +1626,11 @@ impl Step for Extended { candle("GccGroup.wxs".as_ref()); } - build.create(&exe.join("LICENSE.rtf"), &rtf); - build.install(&etc.join("gfx/banner.bmp"), &exe, 0o644); - build.install(&etc.join("gfx/dialogbg.bmp"), &exe, 0o644); + builder.create(&exe.join("LICENSE.rtf"), &rtf); + builder.install(&etc.join("gfx/banner.bmp"), &exe, 0o644); + builder.install(&etc.join("gfx/dialogbg.bmp"), &exe, 0o644); - let filename = format!("{}-{}.msi", pkgname(build, "rust"), target); + let filename = format!("{}-{}.msi", pkgname(builder, "rust"), target); let mut cmd = Command::new(&light); cmd.arg("-nologo") .arg("-ext").arg("WixUIExtension") @@ -1668,28 +1656,28 @@ impl Step for Extended { // ICE57 wrongly complains about the shortcuts cmd.arg("-sice:ICE57"); - build.run(&mut cmd); + builder.run(&mut cmd); - if !build.config.dry_run { - t!(fs::rename(exe.join(&filename), distdir(build).join(&filename))); + if !builder.config.dry_run { + t!(fs::rename(exe.join(&filename), distdir(builder).join(&filename))); } } } } -fn add_env(build: &Build, cmd: &mut Command, target: Interned) { +fn add_env(builder: &Builder, cmd: &mut Command, target: Interned) { let mut parts = channel::CFG_RELEASE_NUM.split('.'); - cmd.env("CFG_RELEASE_INFO", build.rust_version()) + cmd.env("CFG_RELEASE_INFO", builder.rust_version()) .env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM) - .env("CFG_RELEASE", build.rust_release()) + .env("CFG_RELEASE", builder.rust_release()) .env("CFG_VER_MAJOR", parts.next().unwrap()) .env("CFG_VER_MINOR", parts.next().unwrap()) .env("CFG_VER_PATCH", parts.next().unwrap()) .env("CFG_VER_BUILD", "0") // just needed to build - .env("CFG_PACKAGE_VERS", build.rust_package_vers()) - .env("CFG_PACKAGE_NAME", pkgname(build, "rust")) + .env("CFG_PACKAGE_VERS", builder.rust_package_vers()) + .env("CFG_PACKAGE_NAME", pkgname(builder, "rust")) .env("CFG_BUILD", target) - .env("CFG_CHANNEL", &build.config.channel); + .env("CFG_CHANNEL", &builder.config.channel); if target.contains("windows-gnu") { cmd.env("CFG_MINGW", "1") @@ -1722,18 +1710,17 @@ impl Step for HashSign { } fn run(self, builder: &Builder) { - let build = builder.build; let mut cmd = builder.tool_cmd(Tool::BuildManifest); - if build.config.dry_run { + if builder.config.dry_run { return; } - let sign = build.config.dist_sign_folder.as_ref().unwrap_or_else(|| { + let sign = builder.config.dist_sign_folder.as_ref().unwrap_or_else(|| { panic!("\n\nfailed to specify `dist.sign-folder` in `config.toml`\n\n") }); - let addr = build.config.dist_upload_addr.as_ref().unwrap_or_else(|| { + let addr = builder.config.dist_upload_addr.as_ref().unwrap_or_else(|| { panic!("\n\nfailed to specify `dist.upload-addr` in `config.toml`\n\n") }); - let file = build.config.dist_gpg_password_file.as_ref().unwrap_or_else(|| { + let file = builder.config.dist_gpg_password_file.as_ref().unwrap_or_else(|| { panic!("\n\nfailed to specify `dist.gpg-password-file` in `config.toml`\n\n") }); let mut pass = String::new(); @@ -1742,15 +1729,15 @@ impl Step for HashSign { let today = output(Command::new("date").arg("+%Y-%m-%d")); cmd.arg(sign); - cmd.arg(distdir(build)); + cmd.arg(distdir(builder)); cmd.arg(today.trim()); - cmd.arg(build.rust_package_vers()); - cmd.arg(build.package_vers(&build.release_num("cargo"))); - cmd.arg(build.package_vers(&build.release_num("rls"))); - cmd.arg(build.package_vers(&build.release_num("rustfmt"))); + cmd.arg(builder.rust_package_vers()); + cmd.arg(builder.package_vers(&builder.release_num("cargo"))); + cmd.arg(builder.package_vers(&builder.release_num("rls"))); + cmd.arg(builder.package_vers(&builder.release_num("rustfmt"))); cmd.arg(addr); - build.create_dir(&distdir(build)); + builder.create_dir(&distdir(builder)); let mut child = t!(cmd.stdin(Stdio::piped()).spawn()); t!(child.stdin.take().unwrap().write_all(pass.as_bytes())); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 620e125a43da1..ae22260c564ed 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Documentation generation for rustbuild. +//! Documentation generation for rustbuilder. //! //! This module implements generation for all bits and pieces of documentation //! for the Rust project. This notably includes suites like the rust book, the @@ -23,7 +23,7 @@ use std::io::prelude::*; use std::io; use std::path::{PathBuf, Path}; -use {Build, Mode}; +use Mode; use build_helper::up_to_date; use util::symlink_dir; @@ -47,7 +47,7 @@ macro_rules! book { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path($path).default_condition(builder.build.config.docs) + run.path($path).default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -94,7 +94,7 @@ impl Step for Rustbook { /// This will not actually generate any documentation if the documentation has /// already been generated. fn run(self, builder: &Builder) { - let src = builder.build.src.join("src/doc"); + let src = builder.src.join("src/doc"); builder.ensure(RustbookSrc { target: self.target, name: self.name, @@ -114,7 +114,7 @@ impl Step for UnstableBook { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("src/doc/unstable-book").default_condition(builder.build.config.docs) + run.path("src/doc/unstable-book").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -130,7 +130,7 @@ impl Step for UnstableBook { builder.ensure(RustbookSrc { target: self.target, name: INTERNER.intern_str("unstable-book"), - src: builder.build.md_doc_out(self.target), + src: builder.md_doc_out(self.target), }) } } @@ -147,7 +147,7 @@ impl Step for CargoBook { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("src/tools/cargo/src/doc/book").default_condition(builder.build.config.docs) + run.path("src/tools/cargo/src/doc/book").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -158,22 +158,20 @@ impl Step for CargoBook { } fn run(self, builder: &Builder) { - let build = builder.build; - let target = self.target; let name = self.name; - let src = build.src.join("src/tools/cargo/src/doc"); + let src = builder.src.join("src/tools/cargo/src/doc"); - let out = build.doc_out(target); + let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); let out = out.join(name); - build.info(&format!("Cargo Book ({}) - {}", target, name)); + builder.info(&format!("Cargo Book ({}) - {}", target, name)); let _ = fs::remove_dir_all(&out); - build.run(builder.tool_cmd(Tool::Rustbook) + builder.run(builder.tool_cmd(Tool::Rustbook) .arg("build") .arg(&src) .arg("-d") @@ -200,11 +198,10 @@ impl Step for RustbookSrc { /// This will not actually generate any documentation if the documentation has /// already been generated. fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; let name = self.name; let src = self.src; - let out = build.doc_out(target); + let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); let out = out.join(name); @@ -215,9 +212,9 @@ impl Step for RustbookSrc { if up_to_date(&src, &index) && up_to_date(&rustbook, &index) { return } - build.info(&format!("Rustbook ({}) - {}", target, name)); + builder.info(&format!("Rustbook ({}) - {}", target, name)); let _ = fs::remove_dir_all(&out); - build.run(rustbook_cmd + builder.run(rustbook_cmd .arg("build") .arg(&src) .arg("-d") @@ -238,12 +235,12 @@ impl Step for TheBook { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("src/doc/book").default_condition(builder.build.config.docs) + run.path("src/doc/book").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { run.builder.ensure(TheBook { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, name: "book", }); @@ -259,7 +256,6 @@ impl Step for TheBook { /// * Index page /// * Redirect pages fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target = self.target; let name = self.name; @@ -283,12 +279,12 @@ impl Step for TheBook { // build the index page let index = format!("{}/index.md", name); - build.info(&format!("Documenting book index ({})", target)); + builder.info(&format!("Documenting book index ({})", target)); invoke_rustdoc(builder, compiler, target, &index); // build the redirect pages - build.info(&format!("Documenting book redirect pages ({})", target)); - for file in t!(fs::read_dir(build.src.join("src/doc/book/redirects"))) { + builder.info(&format!("Documenting book redirect pages ({})", target)); + for file in t!(fs::read_dir(builder.src.join("src/doc/book/redirects"))) { let file = t!(file); let path = file.path(); let path = path.to_str().unwrap(); @@ -299,13 +295,12 @@ impl Step for TheBook { } fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned, markdown: &str) { - let build = builder.build; - let out = build.doc_out(target); + let out = builder.doc_out(target); - let path = build.src.join("src/doc").join(markdown); + let path = builder.src.join("src/doc").join(markdown); - let favicon = build.src.join("src/doc/favicon.inc"); - let footer = build.src.join("src/doc/footer.inc"); + let favicon = builder.src.join("src/doc/favicon.inc"); + let footer = builder.src.join("src/doc/footer.inc"); let version_info = out.join("version_info.html"); let mut cmd = builder.rustdoc_cmd(compiler.host); @@ -323,7 +318,7 @@ fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned ShouldRun { let builder = run.builder; - run.path("src/doc").default_condition(builder.build.config.docs) + run.path("src/doc").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { run.builder.ensure(Standalone { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } @@ -357,31 +352,30 @@ impl Step for Standalone { /// /// In the end, this is just a glorified wrapper around rustdoc! fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; let compiler = self.compiler; - build.info(&format!("Documenting standalone ({})", target)); - let out = build.doc_out(target); + builder.info(&format!("Documenting standalone ({})", target)); + let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); - let favicon = build.src.join("src/doc/favicon.inc"); - let footer = build.src.join("src/doc/footer.inc"); - let full_toc = build.src.join("src/doc/full-toc.inc"); - t!(fs::copy(build.src.join("src/doc/rust.css"), out.join("rust.css"))); + let favicon = builder.src.join("src/doc/favicon.inc"); + let footer = builder.src.join("src/doc/footer.inc"); + let full_toc = builder.src.join("src/doc/full-toc.inc"); + t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css"))); - let version_input = build.src.join("src/doc/version_info.html.template"); + let version_input = builder.src.join("src/doc/version_info.html.template"); let version_info = out.join("version_info.html"); - if !build.config.dry_run && !up_to_date(&version_input, &version_info) { + if !builder.config.dry_run && !up_to_date(&version_input, &version_info) { let mut info = String::new(); t!(t!(File::open(&version_input)).read_to_string(&mut info)); - let info = info.replace("VERSION", &build.rust_release()) - .replace("SHORT_HASH", build.rust_info.sha_short().unwrap_or("")) - .replace("STAMP", build.rust_info.sha().unwrap_or("")); + let info = info.replace("VERSION", &builder.rust_release()) + .replace("SHORT_HASH", builder.rust_info.sha_short().unwrap_or("")) + .replace("STAMP", builder.rust_info.sha().unwrap_or("")); t!(t!(File::create(&version_info)).write_all(info.as_bytes())); } - for file in t!(fs::read_dir(build.src.join("src/doc"))) { + for file in t!(fs::read_dir(builder.src.join("src/doc"))) { let file = t!(file); let path = file.path(); let filename = path.file_name().unwrap().to_str().unwrap(); @@ -396,7 +390,7 @@ impl Step for Standalone { up_to_date(&favicon, &html) && up_to_date(&full_toc, &html) && up_to_date(&version_info, &html) && - (build.config.dry_run || up_to_date(&rustdoc, &html)) { + (builder.config.dry_run || up_to_date(&rustdoc, &html)) { continue } @@ -416,7 +410,7 @@ impl Step for Standalone { } else { cmd.arg("--markdown-css").arg("rust.css"); } - build.run(&mut cmd); + builder.run(&mut cmd); } } } @@ -433,7 +427,7 @@ impl Step for Std { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.all_krates("std").default_condition(builder.build.config.docs) + run.all_krates("std").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -448,22 +442,21 @@ impl Step for Std { /// This will generate all documentation for the standard library and its /// dependencies. This is largely just a wrapper around `cargo doc`. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let target = self.target; - build.info(&format!("Documenting stage{} std ({})", stage, target)); - let out = build.doc_out(target); + builder.info(&format!("Documenting stage{} std ({})", stage, target)); + let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); - let compiler = builder.compiler(stage, build.build); + let compiler = builder.compiler(stage, builder.config.build); let rustdoc = builder.rustdoc(compiler.host); - let compiler = if build.force_use_stage1(compiler, target) { + let compiler = if builder.force_use_stage1(compiler, target) { builder.compiler(1, compiler.host) } else { compiler }; builder.ensure(compile::Std { compiler, target }); - let out_dir = build.stage_out(compiler, Mode::Libstd) + let out_dir = builder.stage_out(compiler, Mode::Libstd) .join(target).join("doc"); // Here what we're doing is creating a *symlink* (directory junction on @@ -479,9 +472,9 @@ impl Step for Std { // // This way rustdoc generates output directly into the output, and rustdoc // will also directly handle merging. - let my_out = build.crate_doc_out(target); - build.clear_if_dirty(&my_out, &rustdoc); - t!(symlink_dir_force(&build.config, &my_out, &out_dir)); + let my_out = builder.crate_doc_out(target); + builder.clear_if_dirty(&my_out, &rustdoc); + t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "doc"); compile::std_cargo(builder, &compiler, target, &mut cargo); @@ -497,8 +490,8 @@ impl Step for Std { t!(fs::create_dir_all(out_dir.join(krate))); } - build.run(&mut cargo); - build.cp_r(&my_out, &out); + builder.run(&mut cargo); + builder.cp_r(&my_out, &out); } } @@ -514,7 +507,7 @@ impl Step for Test { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.krate("test").default_condition(builder.build.config.docs) + run.krate("test").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -529,15 +522,14 @@ impl Step for Test { /// This will generate all documentation for libtest and its dependencies. This /// is largely just a wrapper around `cargo doc`. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let target = self.target; - build.info(&format!("Documenting stage{} test ({})", stage, target)); - let out = build.doc_out(target); + builder.info(&format!("Documenting stage{} test ({})", stage, target)); + let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); - let compiler = builder.compiler(stage, build.build); + let compiler = builder.compiler(stage, builder.config.build); let rustdoc = builder.rustdoc(compiler.host); - let compiler = if build.force_use_stage1(compiler, target) { + let compiler = if builder.force_use_stage1(compiler, target) { builder.compiler(1, compiler.host) } else { compiler @@ -547,21 +539,21 @@ impl Step for Test { builder.ensure(Std { stage, target }); builder.ensure(compile::Test { compiler, target }); - let out_dir = build.stage_out(compiler, Mode::Libtest) + let out_dir = builder.stage_out(compiler, Mode::Libtest) .join(target).join("doc"); // See docs in std above for why we symlink - let my_out = build.crate_doc_out(target); - build.clear_if_dirty(&my_out, &rustdoc); + let my_out = builder.crate_doc_out(target); + builder.clear_if_dirty(&my_out, &rustdoc); t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc"); - compile::test_cargo(build, &compiler, target, &mut cargo); + compile::test_cargo(builder, &compiler, target, &mut cargo); cargo.arg("--no-deps").arg("-p").arg("test"); - build.run(&mut cargo); - build.cp_r(&my_out, &out); + builder.run(&mut cargo); + builder.cp_r(&my_out, &out); } } @@ -578,7 +570,7 @@ impl Step for WhitelistedRustc { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.krate("rustc-main").default_condition(builder.build.config.docs) + run.krate("rustc-main").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -598,15 +590,14 @@ impl Step for WhitelistedRustc { /// here as we want to be able to keep it separate from the standard /// documentation. This is largely just a wrapper around `cargo doc`. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let target = self.target; - build.info(&format!("Documenting stage{} whitelisted compiler ({})", stage, target)); - let out = build.doc_out(target); + builder.info(&format!("Documenting stage{} whitelisted compiler ({})", stage, target)); + let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); - let compiler = builder.compiler(stage, build.build); + let compiler = builder.compiler(stage, builder.config.build); let rustdoc = builder.rustdoc(compiler.host); - let compiler = if build.force_use_stage1(compiler, target) { + let compiler = if builder.force_use_stage1(compiler, target) { builder.compiler(1, compiler.host) } else { compiler @@ -616,16 +607,16 @@ impl Step for WhitelistedRustc { builder.ensure(Std { stage, target }); builder.ensure(compile::Rustc { compiler, target }); - let out_dir = build.stage_out(compiler, Mode::Librustc) + let out_dir = builder.stage_out(compiler, Mode::Librustc) .join(target).join("doc"); // See docs in std above for why we symlink - let my_out = build.crate_doc_out(target); - build.clear_if_dirty(&my_out, &rustdoc); + let my_out = builder.crate_doc_out(target); + builder.clear_if_dirty(&my_out, &rustdoc); t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc"); - compile::rustc_cargo(build, &mut cargo); + compile::rustc_cargo(builder, &mut cargo); // We don't want to build docs for internal compiler dependencies in this // step (there is another step for that). Therefore, we whitelist the crates @@ -635,8 +626,8 @@ impl Step for WhitelistedRustc { cargo.arg("-p").arg(krate); } - build.run(&mut cargo); - build.cp_r(&my_out, &out); + builder.run(&mut cargo); + builder.cp_r(&my_out, &out); } } @@ -653,7 +644,7 @@ impl Step for Rustc { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.krate("rustc-main").default_condition(builder.build.config.docs) + run.krate("rustc-main").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -670,22 +661,21 @@ impl Step for Rustc { /// we do not merge it with the other documentation from std, test and /// proc_macros. This is largely just a wrapper around `cargo doc`. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let target = self.target; - build.info(&format!("Documenting stage{} compiler ({})", stage, target)); - let out = build.compiler_doc_out(target); + builder.info(&format!("Documenting stage{} compiler ({})", stage, target)); + let out = builder.compiler_doc_out(target); t!(fs::create_dir_all(&out)); - let compiler = builder.compiler(stage, build.build); + let compiler = builder.compiler(stage, builder.config.build); let rustdoc = builder.rustdoc(compiler.host); - let compiler = if build.force_use_stage1(compiler, target) { + let compiler = if builder.force_use_stage1(compiler, target) { builder.compiler(1, compiler.host) } else { compiler }; - if !build.config.compiler_docs { - build.info(&format!("\tskipping - compiler docs disabled")); + if !builder.config.compiler_docs { + builder.info(&format!("\tskipping - compiler docs disabled")); return; } @@ -693,16 +683,16 @@ impl Step for Rustc { builder.ensure(Std { stage, target }); builder.ensure(compile::Rustc { compiler, target }); - let out_dir = build.stage_out(compiler, Mode::Librustc) + let out_dir = builder.stage_out(compiler, Mode::Librustc) .join(target).join("doc"); // We do not symlink to the same shared folder that already contains std library // documentation from previous steps as we do not want to include that. - build.clear_if_dirty(&out, &rustdoc); + builder.clear_if_dirty(&out, &rustdoc); t!(symlink_dir_force(&builder.config, &out, &out_dir)); let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc"); cargo.env("RUSTDOCFLAGS", "--document-private-items"); - compile::rustc_cargo(build, &mut cargo); + compile::rustc_cargo(builder, &mut cargo); // Only include compiler crates, no dependencies of those, such as `libc`. cargo.arg("--no-deps"); @@ -711,19 +701,19 @@ impl Step for Rustc { let mut compiler_crates = HashSet::new(); for root_crate in &["rustc", "rustc_driver"] { let interned_root_crate = INTERNER.intern_str(root_crate); - find_compiler_crates(&build, &interned_root_crate, &mut compiler_crates); + find_compiler_crates(builder, &interned_root_crate, &mut compiler_crates); } for krate in &compiler_crates { cargo.arg("-p").arg(krate); } - build.run(&mut cargo); + builder.run(&mut cargo); } } fn find_compiler_crates( - build: &Build, + builder: &Builder, name: &Interned, crates: &mut HashSet> ) { @@ -731,9 +721,9 @@ fn find_compiler_crates( crates.insert(*name); // Look for dependencies. - for dep in build.crates.get(name).unwrap().deps.iter() { - if build.crates.get(dep).unwrap().is_local(build) { - find_compiler_crates(build, dep, crates); + for dep in builder.crates.get(name).unwrap().deps.iter() { + if builder.crates.get(dep).unwrap().is_local(builder) { + find_compiler_crates(builder, dep, crates); } } } @@ -750,7 +740,7 @@ impl Step for ErrorIndex { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("src/tools/error_index_generator").default_condition(builder.build.config.docs) + run.path("src/tools/error_index_generator").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -762,21 +752,20 @@ impl Step for ErrorIndex { /// Generates the HTML rendered error-index by running the /// `error_index_generator` tool. fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; - build.info(&format!("Documenting error index ({})", target)); - let out = build.doc_out(target); + builder.info(&format!("Documenting error index ({})", target)); + let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); let mut index = builder.tool_cmd(Tool::ErrorIndex); index.arg("html"); index.arg(out.join("error-index.html")); // FIXME: shouldn't have to pass this env var - index.env("CFG_BUILD", &build.build) - .env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()); + index.env("CFG_BUILD", &builder.config.build) + .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir()); - build.run(&mut index); + builder.run(&mut index); } } @@ -792,7 +781,7 @@ impl Step for UnstableBookGen { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("src/tools/unstable-book-gen").default_condition(builder.build.config.docs) + run.path("src/tools/unstable-book-gen").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -802,23 +791,22 @@ impl Step for UnstableBookGen { } fn run(self, builder: &Builder) { - let build = builder.build; let target = self.target; builder.ensure(compile::Std { - compiler: builder.compiler(builder.top_stage, build.build), + compiler: builder.compiler(builder.top_stage, builder.config.build), target, }); - build.info(&format!("Generating unstable book md files ({})", target)); - let out = build.md_doc_out(target).join("unstable-book"); - build.create_dir(&out); - build.remove_dir(&out); + builder.info(&format!("Generating unstable book md files ({})", target)); + let out = builder.md_doc_out(target).join("unstable-book"); + builder.create_dir(&out); + builder.remove_dir(&out); let mut cmd = builder.tool_cmd(Tool::UnstableBookGen); - cmd.arg(build.src.join("src")); + cmd.arg(builder.src.join("src")); cmd.arg(out); - build.run(&mut cmd); + builder.run(&mut cmd); } } diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index d71fdb8a30c70..b37a007e86390 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -62,8 +62,7 @@ fn install_sh( stage: u32, host: Option> ) { - let build = builder.build; - build.info(&format!("Install {} stage{} ({:?})", package, stage, host)); + builder.info(&format!("Install {} stage{} ({:?})", package, stage, host)); let prefix_default = PathBuf::from("/usr/local"); let sysconfdir_default = PathBuf::from("/etc"); @@ -72,15 +71,15 @@ fn install_sh( let bindir_default = PathBuf::from("bin"); let libdir_default = PathBuf::from("lib"); let mandir_default = datadir_default.join("man"); - let prefix = build.config.prefix.as_ref().map_or(prefix_default, |p| { + let prefix = builder.config.prefix.as_ref().map_or(prefix_default, |p| { fs::canonicalize(p).expect(&format!("could not canonicalize {}", p.display())) }); - let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default); - let datadir = build.config.datadir.as_ref().unwrap_or(&datadir_default); - let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default); - let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default); - let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default); - let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default); + let sysconfdir = builder.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default); + let datadir = builder.config.datadir.as_ref().unwrap_or(&datadir_default); + let docdir = builder.config.docdir.as_ref().unwrap_or(&docdir_default); + let bindir = builder.config.bindir.as_ref().unwrap_or(&bindir_default); + let libdir = builder.config.libdir.as_ref().unwrap_or(&libdir_default); + let mandir = builder.config.mandir.as_ref().unwrap_or(&mandir_default); let sysconfdir = prefix.join(sysconfdir); let datadir = prefix.join(datadir); @@ -99,18 +98,18 @@ fn install_sh( let libdir = add_destdir(&libdir, &destdir); let mandir = add_destdir(&mandir, &destdir); - let empty_dir = build.out.join("tmp/empty_dir"); + let empty_dir = builder.out.join("tmp/empty_dir"); t!(fs::create_dir_all(&empty_dir)); let package_name = if let Some(host) = host { - format!("{}-{}", pkgname(build, name), host) + format!("{}-{}", pkgname(builder, name), host) } else { - pkgname(build, name) + pkgname(builder, name) }; let mut cmd = Command::new("sh"); cmd.current_dir(&empty_dir) - .arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh"))) + .arg(sanitize_sh(&tmpdir(builder).join(&package_name).join("install.sh"))) .arg(format!("--prefix={}", sanitize_sh(&prefix))) .arg(format!("--sysconfdir={}", sanitize_sh(&sysconfdir))) .arg(format!("--datadir={}", sanitize_sh(&datadir))) @@ -119,7 +118,7 @@ fn install_sh( .arg(format!("--libdir={}", sanitize_sh(&libdir))) .arg(format!("--mandir={}", sanitize_sh(&mandir))) .arg("--disable-ldconfig"); - build.run(&mut cmd); + builder.run(&mut cmd); t!(fs::remove_dir_all(&empty_dir)); } @@ -180,7 +179,7 @@ macro_rules! install { run.builder.ensure($name { stage: run.builder.top_stage, target: run.target, - host: run.builder.build.build, + host: run.builder.config.build, }); } @@ -197,7 +196,7 @@ install!((self, builder, _config), install_docs(builder, self.stage, self.target); }; Std, "src/libstd", true, only_hosts: true, { - for target in &builder.build.targets { + for target in &builder.targets { builder.ensure(dist::Std { compiler: builder.compiler(self.stage, self.host), target: *target diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index db5891afd6b1f..2c2cf74d9790f 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -29,7 +29,6 @@ use build_helper::output; use cmake; use cc; -use Build; use util::{self, exe}; use build_helper::up_to_date; use builder::{Builder, RunConfig, ShouldRun, Step}; @@ -60,39 +59,38 @@ impl Step for Llvm { /// Compile LLVM for `target`. fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let target = self.target; let emscripten = self.emscripten; // If we're using a custom LLVM bail out here, but we can only use a // custom LLVM for the build triple. if !self.emscripten { - if let Some(config) = build.config.target_config.get(&target) { + if let Some(config) = builder.config.target_config.get(&target) { if let Some(ref s) = config.llvm_config { - check_llvm_version(build, s); + check_llvm_version(builder, s); return s.to_path_buf() } } } - let rebuild_trigger = build.src.join("src/rustllvm/llvm-rebuild-trigger"); + let rebuild_trigger = builder.src.join("src/rustllvm/llvm-rebuild-trigger"); let mut rebuild_trigger_contents = String::new(); t!(t!(File::open(&rebuild_trigger)).read_to_string(&mut rebuild_trigger_contents)); let (out_dir, llvm_config_ret_dir) = if emscripten { - let dir = build.emscripten_llvm_out(target); + let dir = builder.emscripten_llvm_out(target); let config_dir = dir.join("bin"); (dir, config_dir) } else { - let mut dir = build.llvm_out(build.config.build); - if !build.config.build.contains("msvc") || build.config.ninja { + let mut dir = builder.llvm_out(builder.config.build); + if !builder.config.build.contains("msvc") || builder.config.ninja { dir.push("build"); } - (build.llvm_out(target), dir.join("bin")) + (builder.llvm_out(target), dir.join("bin")) }; let done_stamp = out_dir.join("llvm-finished-building"); let build_llvm_config = llvm_config_ret_dir - .join(exe("llvm-config", &*build.config.build)); + .join(exe("llvm-config", &*builder.config.build)); if done_stamp.exists() { let mut done_contents = String::new(); t!(t!(File::open(&done_stamp)).read_to_string(&mut done_contents)); @@ -104,17 +102,17 @@ impl Step for Llvm { } } - let _folder = build.fold_output(|| "llvm"); + let _folder = builder.fold_output(|| "llvm"); let descriptor = if emscripten { "Emscripten " } else { "" }; - build.info(&format!("Building {}LLVM for {}", descriptor, target)); - let _time = util::timeit(&build); + builder.info(&format!("Building {}LLVM for {}", descriptor, target)); + let _time = util::timeit(&builder); t!(fs::create_dir_all(&out_dir)); // http://llvm.org/docs/CMake.html let root = if self.emscripten { "src/llvm-emscripten" } else { "src/llvm" }; - let mut cfg = cmake::Config::new(build.src.join(root)); + let mut cfg = cmake::Config::new(builder.src.join(root)); - let profile = match (build.config.llvm_optimize, build.config.llvm_release_debuginfo) { + let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) { (false, _) => "Debug", (true, false) => "Release", (true, true) => "RelWithDebInfo", @@ -125,7 +123,7 @@ impl Step for Llvm { let llvm_targets = if self.emscripten { "JSBackend" } else { - match build.config.llvm_targets { + match builder.config.llvm_targets { Some(ref s) => s, None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;MSP430;Sparc;NVPTX;Hexagon", } @@ -134,10 +132,10 @@ impl Step for Llvm { let llvm_exp_targets = if self.emscripten { "" } else { - &build.config.llvm_experimental_targets[..] + &builder.config.llvm_experimental_targets[..] }; - let assertions = if build.config.llvm_assertions {"ON"} else {"OFF"}; + let assertions = if builder.config.llvm_assertions {"ON"} else {"OFF"}; cfg.out_dir(&out_dir) .profile(profile) @@ -151,7 +149,7 @@ impl Step for Llvm { .define("WITH_POLLY", "OFF") .define("LLVM_ENABLE_TERMINFO", "OFF") .define("LLVM_ENABLE_LIBEDIT", "OFF") - .define("LLVM_PARALLEL_COMPILE_JOBS", build.jobs().to_string()) + .define("LLVM_PARALLEL_COMPILE_JOBS", builder.jobs().to_string()) .define("LLVM_TARGET_ARCH", target.split('-').next().unwrap()) .define("LLVM_DEFAULT_TARGET_TRIPLE", target); @@ -183,22 +181,22 @@ impl Step for Llvm { cfg.define("LLVM_BUILD_32_BITS", "ON"); } - if let Some(num_linkers) = build.config.llvm_link_jobs { + if let Some(num_linkers) = builder.config.llvm_link_jobs { if num_linkers > 0 { cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string()); } } // http://llvm.org/docs/HowToCrossCompileLLVM.html - if target != build.build && !emscripten { + if target != builder.config.build && !emscripten { builder.ensure(Llvm { - target: build.build, + target: builder.config.build, emscripten: false, }); // FIXME: if the llvm root for the build triple is overridden then we // should use llvm-tblgen from there, also should verify that it // actually exists most of the time in normal installs of LLVM. - let host = build.llvm_out(build.build).join("bin/llvm-tblgen"); + let host = builder.llvm_out(builder.config.build).join("bin/llvm-tblgen"); cfg.define("CMAKE_CROSSCOMPILING", "True") .define("LLVM_TABLEGEN", &host); @@ -208,10 +206,10 @@ impl Step for Llvm { cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD"); } - cfg.define("LLVM_NATIVE_BUILD", build.llvm_out(build.build).join("build")); + cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build")); } - configure_cmake(build, target, &mut cfg, false); + configure_cmake(builder, target, &mut cfg, false); // FIXME: we don't actually need to build all LLVM tools and all LLVM // libraries here, e.g. we just want a few components and a few @@ -230,12 +228,12 @@ impl Step for Llvm { } } -fn check_llvm_version(build: &Build, llvm_config: &Path) { - if !build.config.llvm_version_check { +fn check_llvm_version(builder: &Builder, llvm_config: &Path) { + if !builder.config.llvm_version_check { return } - if build.config.dry_run { + if builder.config.dry_run { return; } @@ -251,15 +249,15 @@ fn check_llvm_version(build: &Build, llvm_config: &Path) { panic!("\n\nbad LLVM version: {}, need >=3.9\n\n", version) } -fn configure_cmake(build: &Build, +fn configure_cmake(builder: &Builder, target: Interned, cfg: &mut cmake::Config, building_dist_binaries: bool) { - if build.config.ninja { + if builder.config.ninja { cfg.generator("Ninja"); } cfg.target(&target) - .host(&build.config.build); + .host(&builder.config.build); let sanitize_cc = |cc: &Path| { if target.contains("msvc") { @@ -272,29 +270,29 @@ fn configure_cmake(build: &Build, // MSVC with CMake uses msbuild by default which doesn't respect these // vars that we'd otherwise configure. In that case we just skip this // entirely. - if target.contains("msvc") && !build.config.ninja { + if target.contains("msvc") && !builder.config.ninja { return } - let cc = build.cc(target); - let cxx = build.cxx(target).unwrap(); + let cc = builder.cc(target); + let cxx = builder.cxx(target).unwrap(); // Handle msvc + ninja + ccache specially (this is what the bots use) if target.contains("msvc") && - build.config.ninja && - build.config.ccache.is_some() { + builder.config.ninja && + builder.config.ccache.is_some() { let mut cc = env::current_exe().expect("failed to get cwd"); cc.set_file_name("sccache-plus-cl.exe"); cfg.define("CMAKE_C_COMPILER", sanitize_cc(&cc)) .define("CMAKE_CXX_COMPILER", sanitize_cc(&cc)); cfg.env("SCCACHE_PATH", - build.config.ccache.as_ref().unwrap()) + builder.config.ccache.as_ref().unwrap()) .env("SCCACHE_TARGET", target); // If ccache is configured we inform the build a little differently hwo // to invoke ccache while also invoking our compilers. - } else if let Some(ref ccache) = build.config.ccache { + } else if let Some(ref ccache) = builder.config.ccache { cfg.define("CMAKE_C_COMPILER", ccache) .define("CMAKE_C_COMPILER_ARG1", sanitize_cc(cc)) .define("CMAKE_CXX_COMPILER", ccache) @@ -304,16 +302,16 @@ fn configure_cmake(build: &Build, .define("CMAKE_CXX_COMPILER", sanitize_cc(cxx)); } - cfg.build_arg("-j").build_arg(build.jobs().to_string()); - cfg.define("CMAKE_C_FLAGS", build.cflags(target).join(" ")); - let mut cxxflags = build.cflags(target).join(" "); + cfg.build_arg("-j").build_arg(builder.jobs().to_string()); + cfg.define("CMAKE_C_FLAGS", builder.cflags(target).join(" ")); + let mut cxxflags = builder.cflags(target).join(" "); if building_dist_binaries { - if build.config.llvm_static_stdcpp && !target.contains("windows") { + if builder.config.llvm_static_stdcpp && !target.contains("windows") { cxxflags.push_str(" -static-libstdc++"); } } cfg.define("CMAKE_CXX_FLAGS", cxxflags); - if let Some(ar) = build.ar(target) { + if let Some(ar) = builder.ar(target) { if ar.is_absolute() { // LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it // tries to resolve this path in the LLVM build directory. @@ -349,26 +347,25 @@ impl Step for Lld { return PathBuf::from("lld-out-dir-test-gen"); } let target = self.target; - let build = builder.build; let llvm_config = builder.ensure(Llvm { target: self.target, emscripten: false, }); - let out_dir = build.lld_out(target); + let out_dir = builder.lld_out(target); let done_stamp = out_dir.join("lld-finished-building"); if done_stamp.exists() { return out_dir } - let _folder = build.fold_output(|| "lld"); - build.info(&format!("Building LLD for {}", target)); - let _time = util::timeit(&build); + let _folder = builder.fold_output(|| "lld"); + builder.info(&format!("Building LLD for {}", target)); + let _time = util::timeit(&builder); t!(fs::create_dir_all(&out_dir)); - let mut cfg = cmake::Config::new(build.src.join("src/tools/lld")); - configure_cmake(build, target, &mut cfg, true); + let mut cfg = cmake::Config::new(builder.src.join("src/tools/lld")); + configure_cmake(builder, target, &mut cfg, true); cfg.out_dir(&out_dir) .profile("Release") @@ -404,16 +401,15 @@ impl Step for TestHelpers { if builder.config.dry_run { return; } - let build = builder.build; let target = self.target; - let dst = build.test_helpers_out(target); - let src = build.src.join("src/test/auxiliary/rust_test_helpers.c"); + let dst = builder.test_helpers_out(target); + let src = builder.src.join("src/test/auxiliary/rust_test_helpers.c"); if up_to_date(&src, &dst.join("librust_test_helpers.a")) { return } - let _folder = build.fold_output(|| "build_test_helpers"); - build.info(&format!("Building test helpers")); + let _folder = builder.fold_output(|| "build_test_helpers"); + builder.info(&format!("Building test helpers")); t!(fs::create_dir_all(&dst)); let mut cfg = cc::Build::new(); @@ -421,20 +417,20 @@ impl Step for TestHelpers { // extra configuration, so inform gcc of these compilers. Note, though, that // on MSVC we still need gcc's detection of env vars (ugh). if !target.contains("msvc") { - if let Some(ar) = build.ar(target) { + if let Some(ar) = builder.ar(target) { cfg.archiver(ar); } - cfg.compiler(build.cc(target)); + cfg.compiler(builder.cc(target)); } cfg.cargo_metadata(false) .out_dir(&dst) .target(&target) - .host(&build.build) + .host(&builder.config.build) .opt_level(0) .warnings(false) .debug(false) - .file(build.src.join("src/test/auxiliary/rust_test_helpers.c")) + .file(builder.src.join("src/test/auxiliary/rust_test_helpers.c")) .compile("rust_test_helpers"); } } @@ -459,9 +455,8 @@ impl Step for Openssl { if builder.config.dry_run { return; } - let build = builder.build; let target = self.target; - let out = match build.openssl_dir(target) { + let out = match builder.openssl_dir(target) { Some(dir) => dir, None => return, }; @@ -497,7 +492,8 @@ impl Step for Openssl { } // Ensure the hash is correct. - let mut shasum = if target.contains("apple") || build.build.contains("netbsd") { + let mut shasum = if target.contains("apple") || + builder.config.build.contains("netbsd") { let mut cmd = Command::new("shasum"); cmd.arg("-a").arg("256"); cmd @@ -530,10 +526,10 @@ impl Step for Openssl { t!(fs::rename(&tmp, &tarball)); } let obj = out.join(format!("openssl-{}", OPENSSL_VERS)); - let dst = build.openssl_install_dir(target).unwrap(); + let dst = builder.openssl_install_dir(target).unwrap(); drop(fs::remove_dir_all(&obj)); drop(fs::remove_dir_all(&dst)); - build.run(Command::new("tar").arg("zxf").arg(&tarball).current_dir(&out)); + builder.run(Command::new("tar").arg("zxf").arg(&tarball).current_dir(&out)); let mut configure = Command::new("perl"); configure.arg(obj.join("Configure")); @@ -583,8 +579,8 @@ impl Step for Openssl { _ => panic!("don't know how to configure OpenSSL for {}", target), }; configure.arg(os); - configure.env("CC", build.cc(target)); - for flag in build.cflags(target) { + configure.env("CC", builder.cc(target)); + for flag in builder.cflags(target) { configure.arg(flag); } // There is no specific os target for android aarch64 or x86_64, @@ -596,7 +592,7 @@ impl Step for Openssl { if target == "sparc64-unknown-netbsd" { // Need -m64 to get assembly generated correctly for sparc64. configure.arg("-m64"); - if build.build.contains("netbsd") { + if builder.config.build.contains("netbsd") { // Disable sparc64 asm on NetBSD builders, it uses // m4(1)'s -B flag, which NetBSD m4 does not support. configure.arg("no-asm"); @@ -609,12 +605,12 @@ impl Step for Openssl { configure.arg("no-asm"); } configure.current_dir(&obj); - build.info(&format!("Configuring openssl for {}", target)); - build.run_quiet(&mut configure); - build.info(&format!("Building openssl for {}", target)); - build.run_quiet(Command::new("make").arg("-j1").current_dir(&obj)); - build.info(&format!("Installing openssl for {}", target)); - build.run_quiet(Command::new("make").arg("install").arg("-j1").current_dir(&obj)); + builder.info(&format!("Configuring openssl for {}", target)); + builder.run_quiet(&mut configure); + builder.info(&format!("Building openssl for {}", target)); + builder.run_quiet(Command::new("make").arg("-j1").current_dir(&obj)); + builder.info(&format!("Installing openssl for {}", target)); + builder.run_quiet(Command::new("make").arg("install").arg("-j1").current_dir(&obj)); let mut f = t!(File::create(&stamp)); t!(f.write_all(OPENSSL_VERS.as_bytes())); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e6af4202c19c6..3d954cd5d848c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -32,7 +32,7 @@ use dist; use native; use tool::{self, Tool}; use util::{self, dylib_path, dylib_path_var}; -use {Build, Mode}; +use Mode; use toolstate::ToolState; const ADB_TEST_DIR: &str = "/data/tmp/work"; @@ -65,28 +65,28 @@ impl fmt::Display for TestKind { } } -fn try_run(build: &Build, cmd: &mut Command) -> bool { - if !build.fail_fast { - if !build.try_run(cmd) { - let mut failures = build.delayed_failures.borrow_mut(); +fn try_run(builder: &Builder, cmd: &mut Command) -> bool { + if !builder.fail_fast { + if !builder.try_run(cmd) { + let mut failures = builder.delayed_failures.borrow_mut(); failures.push(format!("{:?}", cmd)); return false; } } else { - build.run(cmd); + builder.run(cmd); } true } -fn try_run_quiet(build: &Build, cmd: &mut Command) -> bool { - if !build.fail_fast { - if !build.try_run_quiet(cmd) { - let mut failures = build.delayed_failures.borrow_mut(); +fn try_run_quiet(builder: &Builder, cmd: &mut Command) -> bool { + if !builder.fail_fast { + if !builder.try_run_quiet(cmd) { + let mut failures = builder.delayed_failures.borrow_mut(); failures.push(format!("{:?}", cmd)); return false; } } else { - build.run_quiet(cmd); + builder.run_quiet(cmd); } true } @@ -106,21 +106,20 @@ impl Step for Linkcheck { /// This tool in `src/tools` will verify the validity of all our links in the /// documentation to ensure we don't have a bunch of dead ones. fn run(self, builder: &Builder) { - let build = builder.build; let host = self.host; - build.info(&format!("Linkcheck ({})", host)); + builder.info(&format!("Linkcheck ({})", host)); builder.default_doc(None); - let _time = util::timeit(&build); - try_run(build, builder.tool_cmd(Tool::Linkchecker) - .arg(build.out.join(host).join("doc"))); + let _time = util::timeit(&builder); + try_run(builder, builder.tool_cmd(Tool::Linkchecker) + .arg(builder.out.join(host).join("doc"))); } fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("src/tools/linkchecker").default_condition(builder.build.config.docs) + run.path("src/tools/linkchecker").default_condition(builder.config.docs) } fn make_run(run: RunConfig) { @@ -154,19 +153,18 @@ impl Step for Cargotest { /// This tool in `src/tools` will check out a few Rust projects and run `cargo /// test` to ensure that we don't regress the test suites there. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = builder.compiler(self.stage, self.host); builder.ensure(compile::Rustc { compiler, target: compiler.host }); // Note that this is a short, cryptic, and not scoped directory name. This // is currently to minimize the length of path on Windows where we otherwise // quickly run into path name limit constraints. - let out_dir = build.out.join("ct"); + let out_dir = builder.out.join("ct"); t!(fs::create_dir_all(&out_dir)); - let _time = util::timeit(&build); + let _time = util::timeit(&builder); let mut cmd = builder.tool_cmd(Tool::CargoTest); - try_run(build, cmd.arg(&build.initial_cargo) + try_run(builder, cmd.arg(&builder.initial_cargo) .arg(&out_dir) .env("RUSTC", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler.host))); @@ -196,13 +194,12 @@ impl Step for Cargo { /// Runs `cargo test` for `cargo` packaged with Rust. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = builder.compiler(self.stage, self.host); builder.ensure(tool::Cargo { compiler, target: self.host }); let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test"); - cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml")); - if !build.fail_fast { + cargo.arg("--manifest-path").arg(builder.src.join("src/tools/cargo/Cargo.toml")); + if !builder.fail_fast { cargo.arg("--no-fail-fast"); } @@ -213,7 +210,7 @@ impl Step for Cargo { // available. cargo.env("CFG_DISABLE_CROSS_TESTS", "1"); - try_run(build, cargo.env("PATH", &path_for_cargo(builder, compiler))); + try_run(builder, cargo.env("PATH", &path_for_cargo(builder, compiler))); } } @@ -240,7 +237,6 @@ impl Step for Rls { /// Runs `cargo test` for the rls. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -257,8 +253,8 @@ impl Step for Rls { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run(build, &mut cargo) { - build.save_toolstate("rls", ToolState::TestPass); + if try_run(builder, &mut cargo) { + builder.save_toolstate("rls", ToolState::TestPass); } } } @@ -286,7 +282,6 @@ impl Step for Rustfmt { /// Runs `cargo test` for rustfmt. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -303,8 +298,8 @@ impl Step for Rustfmt { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run(build, &mut cargo) { - build.save_toolstate("rustfmt", ToolState::TestPass); + if try_run(builder, &mut cargo) { + builder.save_toolstate("rustfmt", ToolState::TestPass); } } } @@ -321,7 +316,7 @@ impl Step for Miri { const DEFAULT: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { - let test_miri = run.builder.build.config.test_miri; + let test_miri = run.builder.config.test_miri; run.path("src/tools/miri").default_condition(test_miri) } @@ -334,7 +329,6 @@ impl Step for Miri { /// Runs `cargo test` for miri. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -346,7 +340,7 @@ impl Step for Miri { }); if let Some(miri) = miri { let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); - cargo.arg("--manifest-path").arg(build.src.join("src/tools/miri/Cargo.toml")); + cargo.arg("--manifest-path").arg(builder.src.join("src/tools/miri/Cargo.toml")); // Don't build tests dynamically, just a pain to work with cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); @@ -358,8 +352,8 @@ impl Step for Miri { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run(build, &mut cargo) { - build.save_toolstate("miri", ToolState::TestPass); + if try_run(builder, &mut cargo) { + builder.save_toolstate("miri", ToolState::TestPass); } } else { eprintln!("failed to test miri: could not build"); @@ -391,7 +385,6 @@ impl Step for Clippy { /// Runs `cargo test` for clippy. fn run(self, builder: &Builder) { - let build = builder.build; let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -403,7 +396,7 @@ impl Step for Clippy { }); if let Some(clippy) = clippy { let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); - cargo.arg("--manifest-path").arg(build.src.join("src/tools/clippy/Cargo.toml")); + cargo.arg("--manifest-path").arg(builder.src.join("src/tools/clippy/Cargo.toml")); // Don't build tests dynamically, just a pain to work with cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); @@ -418,8 +411,8 @@ impl Step for Clippy { builder.add_rustc_lib_path(compiler, &mut cargo); - if try_run(build, &mut cargo) { - build.save_toolstate("clippy-driver", ToolState::TestPass); + if try_run(builder, &mut cargo) { + builder.save_toolstate("clippy-driver", ToolState::TestPass); } } else { eprintln!("failed to test clippy: could not build"); @@ -466,14 +459,14 @@ impl Step for RustdocTheme { .env("RUSTC_STAGE", self.compiler.stage.to_string()) .env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) - .env("CFG_RELEASE_CHANNEL", &builder.build.config.channel) + .env("CFG_RELEASE_CHANNEL", &builder.config.channel) .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host)) - .env("RUSTDOC_CRATE_VERSION", builder.build.rust_version()) + .env("RUSTDOC_CRATE_VERSION", builder.rust_version()) .env("RUSTC_BOOTSTRAP", "1"); - if let Some(linker) = builder.build.linker(self.compiler.host) { + if let Some(linker) = builder.linker(self.compiler.host) { cmd.env("RUSTC_TARGET_LINKER", linker); } - try_run(builder.build, &mut cmd); + try_run(builder, &mut cmd); } } @@ -563,21 +556,19 @@ impl Step for Tidy { /// otherwise just implements a few lint-like checks that are specific to the /// compiler itself. fn run(self, builder: &Builder) { - let build = builder.build; - let mut cmd = builder.tool_cmd(Tool::Tidy); - cmd.arg(build.src.join("src")); - cmd.arg(&build.initial_cargo); - if !build.config.vendor { + cmd.arg(builder.src.join("src")); + cmd.arg(&builder.initial_cargo); + if !builder.config.vendor { cmd.arg("--no-vendor"); } - if build.config.quiet_tests { + if builder.config.quiet_tests { cmd.arg("--quiet"); } - let _folder = build.fold_output(|| "tidy"); + let _folder = builder.fold_output(|| "tidy"); builder.info(&format!("tidy check")); - try_run(build, &mut cmd); + try_run(builder, &mut cmd); } fn should_run(run: ShouldRun) -> ShouldRun { @@ -589,8 +580,8 @@ impl Step for Tidy { } } -fn testdir(build: &Build, host: Interned) -> PathBuf { - build.out.join(host).join("test") +fn testdir(builder: &Builder, host: Interned) -> PathBuf { + builder.out.join(host).join("test") } macro_rules! default_test { @@ -828,25 +819,24 @@ impl Step for Compiletest { /// compiletest `mode` and `suite` arguments. For example `mode` can be /// "run-pass" or `suite` can be something like `debuginfo`. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target = self.target; let mode = self.mode; let suite = self.suite; // Skip codegen tests if they aren't enabled in configuration. - if !build.config.codegen_tests && suite == "codegen" { + if !builder.config.codegen_tests && suite == "codegen" { return; } if suite == "debuginfo" { // Skip debuginfo tests on MSVC - if build.build.contains("msvc") { + if builder.config.build.contains("msvc") { return; } if mode == "debuginfo-XXX" { - return if build.build.contains("apple") { + return if builder.config.build.contains("apple") { builder.ensure(Compiletest { mode: "debuginfo-lldb", ..self @@ -895,15 +885,15 @@ impl Step for Compiletest { cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host)); } - cmd.arg("--src-base").arg(build.src.join("src/test").join(suite)); - cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite)); + cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite)); + cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite)); cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target)); cmd.arg("--mode").arg(mode); cmd.arg("--target").arg(target); cmd.arg("--host").arg(&*compiler.host); - cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(build.build)); + cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); - if let Some(ref nodejs) = build.config.nodejs { + if let Some(ref nodejs) = builder.config.nodejs { cmd.arg("--nodejs").arg(nodejs); } @@ -913,17 +903,17 @@ impl Step for Compiletest { vec!["-Crpath".to_string()] }; if !is_rustdoc_ui { - if build.config.rust_optimize_tests { + if builder.config.rust_optimize_tests { flags.push("-O".to_string()); } - if build.config.rust_debuginfo_tests { + if builder.config.rust_debuginfo_tests { flags.push("-g".to_string()); } } flags.push("-Zunstable-options".to_string()); - flags.push(build.config.cmd.rustc_args().join(" ")); + flags.push(builder.config.cmd.rustc_args().join(" ")); - if let Some(linker) = build.linker(target) { + if let Some(linker) = builder.linker(target) { cmd.arg("--linker").arg(linker); } @@ -932,69 +922,69 @@ impl Step for Compiletest { let mut targetflags = flags.clone(); targetflags.push(format!("-Lnative={}", - build.test_helpers_out(target).display())); + builder.test_helpers_out(target).display())); cmd.arg("--target-rustcflags").arg(targetflags.join(" ")); - cmd.arg("--docck-python").arg(build.python()); + cmd.arg("--docck-python").arg(builder.python()); - if build.build.ends_with("apple-darwin") { + if builder.config.build.ends_with("apple-darwin") { // Force /usr/bin/python on macOS for LLDB tests because we're loading the // LLDB plugin's compiled module which only works with the system python // (namely not Homebrew-installed python) cmd.arg("--lldb-python").arg("/usr/bin/python"); } else { - cmd.arg("--lldb-python").arg(build.python()); + cmd.arg("--lldb-python").arg(builder.python()); } - if let Some(ref gdb) = build.config.gdb { + if let Some(ref gdb) = builder.config.gdb { cmd.arg("--gdb").arg(gdb); } - if let Some(ref vers) = build.lldb_version { + if let Some(ref vers) = builder.lldb_version { cmd.arg("--lldb-version").arg(vers); } - if let Some(ref dir) = build.lldb_python_dir { + if let Some(ref dir) = builder.lldb_python_dir { cmd.arg("--lldb-python-dir").arg(dir); } - cmd.args(&build.config.cmd.test_args()); + cmd.args(&builder.config.cmd.test_args()); - if build.is_verbose() { + if builder.is_verbose() { cmd.arg("--verbose"); } - if build.config.quiet_tests { + if builder.config.quiet_tests { cmd.arg("--quiet"); } - if build.config.llvm_enabled { + if builder.config.llvm_enabled { let llvm_config = builder.ensure(native::Llvm { - target: build.config.build, + target: builder.config.build, emscripten: false, }); - if !build.config.dry_run { + if !builder.config.dry_run { let llvm_version = output(Command::new(&llvm_config).arg("--version")); cmd.arg("--llvm-version").arg(llvm_version); } - if !build.is_rust_llvm(target) { + if !builder.is_rust_llvm(target) { cmd.arg("--system-llvm"); } // 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 !build.config.dry_run && suite == "run-make-fulldeps" { + if !builder.config.dry_run && suite == "run-make-fulldeps" { let llvm_components = output(Command::new(&llvm_config).arg("--components")); let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags")); - cmd.arg("--cc").arg(build.cc(target)) - .arg("--cxx").arg(build.cxx(target).unwrap()) - .arg("--cflags").arg(build.cflags(target).join(" ")) + cmd.arg("--cc").arg(builder.cc(target)) + .arg("--cxx").arg(builder.cxx(target).unwrap()) + .arg("--cflags").arg(builder.cflags(target).join(" ")) .arg("--llvm-components").arg(llvm_components.trim()) .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim()); - if let Some(ar) = build.ar(target) { + if let Some(ar) = builder.ar(target) { cmd.arg("--ar").arg(ar); } } } - if suite == "run-make-fulldeps" && !build.config.llvm_enabled { + if suite == "run-make-fulldeps" && !builder.config.llvm_enabled { builder.info( &format!("Ignoring run-make test suite as they generally don't work without LLVM")); return; @@ -1008,7 +998,7 @@ impl Step for Compiletest { .arg("--llvm-cxxflags").arg(""); } - if build.remote_tested(target) { + if builder.remote_tested(target) { cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient)); } @@ -1018,42 +1008,42 @@ impl Step for Compiletest { // Note that if we encounter `PATH` we make sure to append to our own `PATH` // rather than stomp over it. if target.contains("msvc") { - for &(ref k, ref v) in build.cc[&target].env() { + for &(ref k, ref v) in builder.cc[&target].env() { if k != "PATH" { cmd.env(k, v); } } } cmd.env("RUSTC_BOOTSTRAP", "1"); - build.add_rust_test_threads(&mut cmd); + builder.add_rust_test_threads(&mut cmd); - if build.config.sanitizers { + if builder.config.sanitizers { cmd.env("SANITIZER_SUPPORT", "1"); } - if build.config.profiler { + if builder.config.profiler { cmd.env("PROFILER_SUPPORT", "1"); } - cmd.env("RUST_TEST_TMPDIR", build.out.join("tmp")); + cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp")); cmd.arg("--adb-path").arg("adb"); cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR); if target.contains("android") { // Assume that cc for this target comes from the android sysroot cmd.arg("--android-cross-path") - .arg(build.cc(target).parent().unwrap().parent().unwrap()); + .arg(builder.cc(target).parent().unwrap().parent().unwrap()); } else { cmd.arg("--android-cross-path").arg(""); } - build.ci_env.force_coloring_in_ci(&mut cmd); + builder.ci_env.force_coloring_in_ci(&mut cmd); - let _folder = build.fold_output(|| format!("test_{}", suite)); + let _folder = builder.fold_output(|| format!("test_{}", suite)); builder.info(&format!("Check compiletest suite={} mode={} ({} -> {})", suite, mode, &compiler.host, target)); - let _time = util::timeit(&build); - try_run(build, &mut cmd); + let _time = util::timeit(&builder); + try_run(builder, &mut cmd); } } @@ -1079,16 +1069,15 @@ impl Step for DocTest { /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to /// `compiler`. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; builder.ensure(compile::Test { compiler, target: compiler.host }); // Do a breadth-first traversal of the `src/doc` directory and just run // tests for all files that end in `*.md` - let mut stack = vec![build.src.join(self.path)]; - let _time = util::timeit(&build); - let _folder = build.fold_output(|| format!("test_{}", self.name)); + let mut stack = vec![builder.src.join(self.path)]; + let _time = util::timeit(&builder); + let _folder = builder.fold_output(|| format!("test_{}", self.name)); let mut files = Vec::new(); while let Some(p) = stack.pop() { @@ -1102,7 +1091,7 @@ impl Step for DocTest { } // The nostarch directory in the book is for no starch, and so isn't - // guaranteed to build. We don't care if it doesn't build, so skip it. + // guaranteed to builder. We don't care if it doesn't build, so skip it. if p.to_str().map_or(false, |p| p.contains("nostarch")) { continue; } @@ -1120,7 +1109,7 @@ impl Step for DocTest { } else { ToolState::TestFail }; - build.save_toolstate(self.name, toolstate); + builder.save_toolstate(self.name, toolstate); } } } @@ -1198,32 +1187,30 @@ impl Step for ErrorIndex { /// generate a markdown file from the error indexes of the code base which is /// then passed to `rustdoc --test`. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; builder.ensure(compile::Std { compiler, target: compiler.host }); - let dir = testdir(build, compiler.host); + let dir = testdir(builder, compiler.host); t!(fs::create_dir_all(&dir)); let output = dir.join("error-index.md"); let mut tool = builder.tool_cmd(Tool::ErrorIndex); tool.arg("markdown") .arg(&output) - .env("CFG_BUILD", &build.build) - .env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()); + .env("CFG_BUILD", &builder.config.build) + .env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir()); - let _folder = build.fold_output(|| "test_error_index"); - build.info(&format!("Testing error-index stage{}", compiler.stage)); - let _time = util::timeit(&build); - build.run(&mut tool); + let _folder = builder.fold_output(|| "test_error_index"); + builder.info(&format!("Testing error-index stage{}", compiler.stage)); + let _time = util::timeit(&builder); + builder.run(&mut tool); markdown_test(builder, compiler, &output); } } fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool { - let build = builder.build; match File::open(markdown) { Ok(mut file) => { let mut contents = String::new(); @@ -1235,20 +1222,20 @@ fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool Err(_) => {}, } - build.info(&format!("doc tests for: {}", markdown.display())); + builder.info(&format!("doc tests for: {}", markdown.display())); let mut cmd = builder.rustdoc_cmd(compiler.host); - build.add_rust_test_threads(&mut cmd); + builder.add_rust_test_threads(&mut cmd); cmd.arg("--test"); cmd.arg(markdown); cmd.env("RUSTC_BOOTSTRAP", "1"); - let test_args = build.config.cmd.test_args().join(" "); + let test_args = builder.config.cmd.test_args().join(" "); cmd.arg("--test-args").arg(test_args); - if build.config.quiet_tests { - try_run_quiet(build, &mut cmd) + if builder.config.quiet_tests { + try_run_quiet(builder, &mut cmd) } else { - try_run(build, &mut cmd) + try_run(builder, &mut cmd) } } @@ -1432,7 +1419,6 @@ impl Step for Crate { /// Currently this runs all tests for a DAG by passing a bunch of `-p foo` /// arguments, and those arguments are discovered from `cargo metadata`. fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target = self.target; let mode = self.mode; @@ -1446,7 +1432,7 @@ impl Step for Crate { // libstd, then what we're actually testing is the libstd produced in // stage1. Reflect that here by updating the compiler that we're working // with automatically. - let compiler = if build.force_use_stage1(compiler, target) { + let compiler = if builder.force_use_stage1(compiler, target) { builder.compiler(1, compiler.host) } else { compiler.clone() @@ -1458,11 +1444,11 @@ impl Step for Crate { compile::std_cargo(builder, &compiler, target, &mut cargo); } Mode::Libtest => { - compile::test_cargo(build, &compiler, target, &mut cargo); + compile::test_cargo(builder, &compiler, target, &mut cargo); } Mode::Librustc => { builder.ensure(compile::Rustc { compiler, target }); - compile::rustc_cargo(build, &mut cargo); + compile::rustc_cargo(builder, &mut cargo); } _ => panic!("can only test libraries"), }; @@ -1472,10 +1458,10 @@ impl Step for Crate { // Pass in some standard flags then iterate over the graph we've discovered // in `cargo metadata` with the maps above and figure out what `-p` // arguments need to get passed. - if test_kind.subcommand() == "test" && !build.fail_fast { + if test_kind.subcommand() == "test" && !builder.fail_fast { cargo.arg("--no-fail-fast"); } - if build.doc_tests { + if builder.doc_tests { cargo.arg("--doc"); } @@ -1491,21 +1477,21 @@ impl Step for Crate { cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); cargo.arg("--"); - cargo.args(&build.config.cmd.test_args()); + cargo.args(&builder.config.cmd.test_args()); - if build.config.quiet_tests { + if builder.config.quiet_tests { cargo.arg("--quiet"); } if target.contains("emscripten") { cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), - build.config.nodejs.as_ref().expect("nodejs not configured")); + builder.config.nodejs.as_ref().expect("nodejs not configured")); } else if target.starts_with("wasm32") { // Warn about running tests without the `wasm_syscall` feature enabled. // The javascript shim implements the syscall interface so that test // output can be correctly reported. - if !build.config.wasm_syscall { - build.info(&format!("Libstd was built without `wasm_syscall` feature enabled: \ + if !builder.config.wasm_syscall { + builder.info(&format!("Libstd was built without `wasm_syscall` feature enabled: \ test output may not be visible.")); } @@ -1513,25 +1499,25 @@ impl Step for Crate { // incompatible with `-C prefer-dynamic`, so disable that here cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); - let node = build.config.nodejs.as_ref() + let node = builder.config.nodejs.as_ref() .expect("nodejs not configured"); let runner = format!("{} {}/src/etc/wasm32-shim.js", node.display(), - build.src.display()); + builder.src.display()); cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), &runner); - } else if build.remote_tested(target) { + } else if builder.remote_tested(target) { cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), format!("{} run", builder.tool_exe(Tool::RemoteTestClient).display())); } - let _folder = build.fold_output(|| { + let _folder = builder.fold_output(|| { format!("{}_stage{}-{}", test_kind.subcommand(), compiler.stage, krate) }); - build.info(&format!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage, + builder.info(&format!("{} {} stage{} ({} -> {})", test_kind, krate, compiler.stage, &compiler.host, target)); - let _time = util::timeit(&build); - try_run(build, &mut cargo); + let _time = util::timeit(&builder); + try_run(builder, &mut cargo); } } @@ -1568,7 +1554,6 @@ impl Step for CrateRustdoc { } fn run(self, builder: &Builder) { - let build = builder.build; let test_kind = self.test_kind; let compiler = builder.compiler(builder.top_stage, self.host); @@ -1579,27 +1564,27 @@ impl Step for CrateRustdoc { target, test_kind.subcommand(), "src/tools/rustdoc"); - if test_kind.subcommand() == "test" && !build.fail_fast { + if test_kind.subcommand() == "test" && !builder.fail_fast { cargo.arg("--no-fail-fast"); } cargo.arg("-p").arg("rustdoc:0.0.0"); cargo.arg("--"); - cargo.args(&build.config.cmd.test_args()); + cargo.args(&builder.config.cmd.test_args()); - if build.config.quiet_tests { + if builder.config.quiet_tests { cargo.arg("--quiet"); } - let _folder = build.fold_output(|| { + let _folder = builder.fold_output(|| { format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage) }); - build.info(&format!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage, + builder.info(&format!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage, &compiler.host, target)); - let _time = util::timeit(&build); + let _time = util::timeit(&builder); - try_run(build, &mut cargo); + try_run(builder, &mut cargo); } } @@ -1635,17 +1620,16 @@ impl Step for RemoteCopyLibs { } fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target = self.target; - if !build.remote_tested(target) { + if !builder.remote_tested(target) { return } builder.ensure(compile::Test { compiler, target }); - build.info(&format!("REMOTE copy libs to emulator ({})", target)); - t!(fs::create_dir_all(build.out.join("tmp"))); + builder.info(&format!("REMOTE copy libs to emulator ({})", target)); + t!(fs::create_dir_all(builder.out.join("tmp"))); let server = builder.ensure(tool::RemoteTestServer { compiler, target }); @@ -1655,18 +1639,18 @@ impl Step for RemoteCopyLibs { cmd.arg("spawn-emulator") .arg(target) .arg(&server) - .arg(build.out.join("tmp")); - if let Some(rootfs) = build.qemu_rootfs(target) { + .arg(builder.out.join("tmp")); + if let Some(rootfs) = builder.qemu_rootfs(target) { cmd.arg(rootfs); } - build.run(&mut cmd); + builder.run(&mut cmd); // Push all our dylibs to the emulator for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) { let f = t!(f); let name = f.file_name().into_string().unwrap(); if util::is_dylib(&name) { - build.run(Command::new(&tool) + builder.run(Command::new(&tool) .arg("push") .arg(f.path())); } @@ -1690,10 +1674,8 @@ impl Step for Distcheck { /// Run "distcheck", a 'make check' from a tarball fn run(self, builder: &Builder) { - let build = builder.build; - - build.info(&format!("Distcheck")); - let dir = build.out.join("tmp").join("distcheck"); + builder.info(&format!("Distcheck")); + let dir = builder.out.join("tmp").join("distcheck"); let _ = fs::remove_dir_all(&dir); t!(fs::create_dir_all(&dir)); @@ -1706,18 +1688,18 @@ impl Step for Distcheck { .arg(builder.ensure(dist::PlainSourceTarball)) .arg("--strip-components=1") .current_dir(&dir); - build.run(&mut cmd); - build.run(Command::new("./configure") - .args(&build.config.configure_args) + builder.run(&mut cmd); + builder.run(Command::new("./configure") + .args(&builder.config.configure_args) .arg("--enable-vendor") .current_dir(&dir)); - build.run(Command::new(build_helper::make(&build.build)) + builder.run(Command::new(build_helper::make(&builder.config.build)) .arg("check") .current_dir(&dir)); // Now make sure that rust-src has all of libstd's dependencies - build.info(&format!("Distcheck rust-src")); - let dir = build.out.join("tmp").join("distcheck-src"); + builder.info(&format!("Distcheck rust-src")); + let dir = builder.out.join("tmp").join("distcheck-src"); let _ = fs::remove_dir_all(&dir); t!(fs::create_dir_all(&dir)); @@ -1726,10 +1708,10 @@ impl Step for Distcheck { .arg(builder.ensure(dist::Src)) .arg("--strip-components=1") .current_dir(&dir); - build.run(&mut cmd); + builder.run(&mut cmd); let toml = dir.join("rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml"); - build.run(Command::new(&build.initial_cargo) + builder.run(Command::new(&builder.initial_cargo) .arg("generate-lockfile") .arg("--manifest-path") .arg(&toml) @@ -1747,25 +1729,24 @@ impl Step for Bootstrap { /// Test the build system itself fn run(self, builder: &Builder) { - let build = builder.build; - let mut cmd = Command::new(&build.initial_cargo); + let mut cmd = Command::new(&builder.initial_cargo); cmd.arg("test") - .current_dir(build.src.join("src/bootstrap")) + .current_dir(builder.src.join("src/bootstrap")) .env("RUSTFLAGS", "-Cdebuginfo=2") - .env("CARGO_TARGET_DIR", build.out.join("bootstrap")) + .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) .env("RUSTC_BOOTSTRAP", "1") - .env("RUSTC", &build.initial_rustc); + .env("RUSTC", &builder.initial_rustc); if let Some(flags) = option_env!("RUSTFLAGS") { // Use the same rustc flags for testing as for "normal" compilation, // so that Cargo doesn’t recompile the entire dependency graph every time: // https://github.com/rust-lang/rust/issues/49215 cmd.env("RUSTFLAGS", flags); } - if !build.fail_fast { + if !builder.fail_fast { cmd.arg("--no-fail-fast"); } - cmd.arg("--").args(&build.config.cmd.test_args()); - try_run(build, &mut cmd); + cmd.arg("--").args(&builder.config.cmd.test_args()); + try_run(builder, &mut cmd); } fn should_run(run: ShouldRun) -> ShouldRun { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 97507bc08698a..6c29bd84fe467 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -38,7 +38,6 @@ impl Step for CleanTools { } fn run(self, builder: &Builder) { - let build = builder.build; let compiler = self.compiler; let target = self.target; let mode = self.mode; @@ -46,7 +45,7 @@ impl Step for CleanTools { // This is for the original compiler, but if we're forced to use stage 1, then // std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since // we copy the libs forward. - let tools_dir = build.stage_out(compiler, Mode::Tool); + let tools_dir = builder.stage_out(compiler, Mode::Tool); let compiler = if builder.force_use_stage1(compiler, target) { builder.compiler(1, compiler.host) } else { @@ -55,13 +54,13 @@ impl Step for CleanTools { for &cur_mode in &[Mode::Libstd, Mode::Libtest, Mode::Librustc] { let stamp = match cur_mode { - Mode::Libstd => libstd_stamp(build, compiler, target), - Mode::Libtest => libtest_stamp(build, compiler, target), - Mode::Librustc => librustc_stamp(build, compiler, target), + Mode::Libstd => libstd_stamp(builder, compiler, target), + Mode::Libtest => libtest_stamp(builder, compiler, target), + Mode::Librustc => librustc_stamp(builder, compiler, target), _ => panic!(), }; - if build.clear_if_dirty(&tools_dir, &stamp) { + if builder.clear_if_dirty(&tools_dir, &stamp) { break; } @@ -97,7 +96,6 @@ impl Step for ToolBuild { /// This will build the specified tool with the specified `host` compiler in /// `stage` into the normal cargo output directory. fn run(self, builder: &Builder) -> Option { - let build = builder.build; let compiler = self.compiler; let target = self.target; let tool = self.tool; @@ -114,10 +112,10 @@ impl Step for ToolBuild { let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path); cargo.arg("--features").arg(self.extra_features.join(" ")); - let _folder = build.fold_output(|| format!("stage{}-{}", compiler.stage, tool)); - build.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target)); + let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool)); + builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target)); let mut duplicates = Vec::new(); - let is_expected = compile::stream_cargo(build, &mut cargo, &mut |msg| { + let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| { // Only care about big things like the RLS/Cargo for now if tool != "rls" && tool != "cargo" { return @@ -156,7 +154,7 @@ impl Step for ToolBuild { } } - let mut artifacts = build.tool_artifacts.borrow_mut(); + let mut artifacts = builder.tool_artifacts.borrow_mut(); let prev_artifacts = artifacts .entry(target) .or_insert_with(Default::default); @@ -190,7 +188,7 @@ impl Step for ToolBuild { panic!("tools should not compile multiple copies of the same crate"); } - build.save_toolstate(tool, if is_expected { + builder.save_toolstate(tool, if is_expected { ToolState::TestFail } else { ToolState::BuildFail @@ -203,10 +201,10 @@ impl Step for ToolBuild { return None; } } else { - let cargo_out = build.cargo_out(compiler, Mode::Tool, target) + let cargo_out = builder.cargo_out(compiler, Mode::Tool, target) .join(exe(tool, &compiler.host)); - let bin = build.tools_dir(compiler).join(exe(tool, &compiler.host)); - build.copy(&cargo_out, &bin); + let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host)); + builder.copy(&cargo_out, &bin); Some(bin) } } @@ -219,16 +217,15 @@ pub fn prepare_tool_cargo( command: &'static str, path: &'static str, ) -> Command { - let build = builder.build; let mut cargo = builder.cargo(compiler, Mode::Tool, target, command); - let dir = build.src.join(path); + let dir = builder.src.join(path); cargo.arg("--manifest-path").arg(dir.join("Cargo.toml")); // We don't want to build tools dynamically as they'll be running across // stages and such and it's just easier if they're not dynamically linked. cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); - if let Some(dir) = build.openssl_install_dir(target) { + if let Some(dir) = builder.openssl_install_dir(target) { cargo.env("OPENSSL_STATIC", "1"); cargo.env("OPENSSL_DIR", dir); cargo.env("LIBZ_SYS_STATIC", "1"); @@ -238,10 +235,10 @@ pub fn prepare_tool_cargo( // own copy cargo.env("LZMA_API_STATIC", "1"); - cargo.env("CFG_RELEASE_CHANNEL", &build.config.channel); - cargo.env("CFG_VERSION", build.rust_version()); + cargo.env("CFG_RELEASE_CHANNEL", &builder.config.channel); + cargo.env("CFG_VERSION", builder.rust_version()); - let info = GitInfo::new(&build.config, &dir); + let info = GitInfo::new(&builder.config, &dir); if let Some(sha) = info.sha() { cargo.env("CFG_COMMIT_HASH", sha); } @@ -269,8 +266,8 @@ macro_rules! tool { match tool { $(Tool::$name => self.ensure($name { - compiler: self.compiler(stage, self.build.build), - target: self.build.build, + compiler: self.compiler(stage, self.config.build), + target: self.config.build, }), )+ } @@ -304,7 +301,7 @@ macro_rules! tool { fn make_run(run: RunConfig) { run.builder.ensure($name { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } @@ -354,7 +351,7 @@ impl Step for RemoteTestServer { fn make_run(run: RunConfig) { run.builder.ensure(RemoteTestServer { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } @@ -393,26 +390,25 @@ impl Step for Rustdoc { } fn run(self, builder: &Builder) -> PathBuf { - let build = builder.build; let target_compiler = builder.compiler(builder.top_stage, self.host); let target = target_compiler.host; let build_compiler = if target_compiler.stage == 0 { - builder.compiler(0, builder.build.build) + builder.compiler(0, builder.config.build) } else if target_compiler.stage >= 2 { // Past stage 2, we consider the compiler to be ABI-compatible and hence capable of // building rustdoc itself. - builder.compiler(target_compiler.stage, builder.build.build) + builder.compiler(target_compiler.stage, builder.config.build) } else { // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage // compilers, which isn't what we want. - builder.compiler(target_compiler.stage - 1, builder.build.build) + builder.compiler(target_compiler.stage - 1, builder.config.build) }; builder.ensure(compile::Rustc { compiler: build_compiler, target }); builder.ensure(compile::Rustc { compiler: build_compiler, - target: builder.build.build, + target: builder.config.build, }); let mut cargo = prepare_tool_cargo(builder, @@ -425,15 +421,15 @@ impl Step for Rustdoc { cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string()) .env("RUSTC_DEBUGINFO_LINES", builder.config.rust_debuginfo_lines.to_string()); - let _folder = build.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage)); - build.info(&format!("Building rustdoc for stage{} ({})", + let _folder = builder.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage)); + builder.info(&format!("Building rustdoc for stage{} ({})", target_compiler.stage, target_compiler.host)); - build.run(&mut cargo); + builder.run(&mut cargo); // Cargo adds a number of paths to the dylib search path on windows, which results in // the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool" // rustdoc a different name. - let tool_rustdoc = build.cargo_out(build_compiler, Mode::Tool, target) + let tool_rustdoc = builder.cargo_out(build_compiler, Mode::Tool, target) .join(exe("rustdoc-tool-binary", &target_compiler.host)); // don't create a stage0-sysroot/bin directory. @@ -443,7 +439,7 @@ impl Step for Rustdoc { t!(fs::create_dir_all(&bindir)); let bin_rustdoc = bindir.join(exe("rustdoc", &*target_compiler.host)); let _ = fs::remove_file(&bin_rustdoc); - build.copy(&tool_rustdoc, &bin_rustdoc); + builder.copy(&tool_rustdoc, &bin_rustdoc); bin_rustdoc } else { tool_rustdoc @@ -464,12 +460,12 @@ impl Step for Cargo { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path("src/tools/cargo").default_condition(builder.build.config.extended) + run.path("src/tools/cargo").default_condition(builder.config.extended) } fn make_run(run: RunConfig) { run.builder.ensure(Cargo { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } @@ -482,7 +478,7 @@ impl Step for Cargo { // compiler to be available, so we need to depend on that. builder.ensure(compile::Rustc { compiler: self.compiler, - target: builder.build.build, + target: builder.config.build, }); builder.ensure(ToolBuild { compiler: self.compiler, @@ -518,12 +514,12 @@ macro_rules! tool_extended { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.path($path).default_condition(builder.build.config.extended) + run.path($path).default_condition(builder.config.extended) } fn make_run(run: RunConfig) { run.builder.ensure($name { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, extra_features: Vec::new(), }); @@ -554,7 +550,7 @@ tool_extended!((self, builder), // compiler to be available, so we need to depend on that. builder.ensure(compile::Rustc { compiler: self.compiler, - target: builder.build.build, + target: builder.config.build, }); }; Miri, miri, "src/tools/miri", "miri", {}; @@ -575,7 +571,7 @@ tool_extended!((self, builder), // compiler to be available, so we need to depend on that. builder.ensure(compile::Rustc { compiler: self.compiler, - target: builder.build.build, + target: builder.config.build, }); }; Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", {}; @@ -586,7 +582,7 @@ impl<'a> Builder<'a> { /// `host`. pub fn tool_cmd(&self, tool: Tool) -> Command { let mut cmd = Command::new(self.tool_exe(tool)); - let compiler = self.compiler(self.tool_default_stage(tool), self.build.build); + let compiler = self.compiler(self.tool_default_stage(tool), self.config.build); self.prepare_tool_cmd(compiler, &mut cmd); cmd } diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index f8c7032369890..9a2b9e90440e5 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -22,7 +22,7 @@ use std::process::Command; use std::time::{SystemTime, Instant}; use config::Config; -use Build; +use builder::Builder; /// Returns the `name` as the filename of a static library for `target`. pub fn staticlib(name: &str, target: &str) -> String { @@ -104,8 +104,8 @@ pub fn push_exe_path(mut buf: PathBuf, components: &[&str]) -> PathBuf { pub struct TimeIt(bool, Instant); /// Returns an RAII structure that prints out how long it took to drop. -pub fn timeit(build: &Build) -> TimeIt { - TimeIt(build.config.dry_run, Instant::now()) +pub fn timeit(builder: &Builder) -> TimeIt { + TimeIt(builder.config.dry_run, Instant::now()) } impl Drop for TimeIt {