1
Fork 0

refactor Mode enum

This commit is contained in:
Collins Abitekaniza 2018-05-19 23:04:41 +03:00
parent 3515dab431
commit 42ee6d5fd5
8 changed files with 99 additions and 92 deletions

View file

@ -806,7 +806,7 @@ impl<'a> Builder<'a> {
); );
} }
if mode == Mode::Tool { if [Mode::ToolRustc, Mode::ToolStd, Mode::ToolTest].iter().any(|m| &mode == m) {
// Tools like cargo and rls don't get debuginfo by default right now, but this can be // Tools like cargo and rls don't get debuginfo by default right now, but this can be
// enabled in the config. Adding debuginfo makes them several times larger. // enabled in the config. Adding debuginfo makes them several times larger.
if self.config.rust_debuginfo_tools { if self.config.rust_debuginfo_tools {
@ -871,7 +871,7 @@ impl<'a> Builder<'a> {
// //
// If LLVM support is disabled we need to use the snapshot compiler to compile // If LLVM support is disabled we need to use the snapshot compiler to compile
// build scripts, as the new compiler doesn't support executables. // build scripts, as the new compiler doesn't support executables.
if mode == Mode::Libstd || !self.config.llvm_enabled { if mode == Mode::Std || !self.config.llvm_enabled {
cargo cargo
.env("RUSTC_SNAPSHOT", &self.initial_rustc) .env("RUSTC_SNAPSHOT", &self.initial_rustc)
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir()); .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
@ -903,7 +903,7 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity)); cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));
// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful. // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
if self.config.deny_warnings && !(mode == Mode::Libstd && stage == 0) { if self.config.deny_warnings && !(mode == Mode::Std && stage == 0) {
cargo.env("RUSTC_DENY_WARNINGS", "1"); cargo.env("RUSTC_DENY_WARNINGS", "1");
} }
@ -963,7 +963,7 @@ impl<'a> Builder<'a> {
} }
if cmd == "build" if cmd == "build"
&& mode == Mode::Libstd && mode == Mode::Std
&& self.config.extended && self.config.extended
&& compiler.is_final_stage(self) && compiler.is_final_stage(self)
{ {
@ -1012,7 +1012,7 @@ impl<'a> Builder<'a> {
// be resolved because MinGW has the import library. The downside is we // be resolved because MinGW has the import library. The downside is we
// don't get newer functions from Windows, but we don't use any of them // don't get newer functions from Windows, but we don't use any of them
// anyway. // anyway.
if mode != Mode::Tool { if ![Mode::ToolRustc, Mode::ToolStd, Mode::ToolTest].iter().any(|m| &mode == m) {
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1"); cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
} }
@ -1751,7 +1751,7 @@ mod __test {
&[test::Crate { &[test::Crate {
compiler: Compiler { host, stage: 0 }, compiler: Compiler { host, stage: 0 },
target: host, target: host,
mode: Mode::Libstd, mode: Mode::Std,
test_kind: test::TestKind::Test, test_kind: test::TestKind::Test,
krate: INTERNER.intern_str("std"), krate: INTERNER.intern_str("std"),
},] },]

View file

@ -40,10 +40,10 @@ impl Step for Std {
let target = self.target; let target = self.target;
let compiler = builder.compiler(0, builder.config.build); let compiler = builder.compiler(0, builder.config.build);
let out_dir = builder.stage_out(compiler, Mode::Libstd); let out_dir = builder.stage_out(compiler, Mode::Std);
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler)); builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check"); let mut cargo = builder.cargo(compiler, Mode::Std, target, "check");
std_cargo(builder, &compiler, target, &mut cargo); std_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
@ -87,11 +87,11 @@ impl Step for Rustc {
let compiler = builder.compiler(0, builder.config.build); let compiler = builder.compiler(0, builder.config.build);
let target = self.target; let target = self.target;
let stage_out = builder.stage_out(compiler, Mode::Librustc); let stage_out = builder.stage_out(compiler, Mode::Rustc);
builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target)); builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target));
builder.clear_if_dirty(&stage_out, &libtest_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"); let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "check");
rustc_cargo(builder, &mut cargo); rustc_cargo(builder, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
@ -137,7 +137,7 @@ impl Step for CodegenBackend {
let target = self.target; let target = self.target;
let backend = self.backend; let backend = self.backend;
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check"); let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "check");
let features = builder.rustc_features().to_string(); let features = builder.rustc_features().to_string();
cargo.arg("--manifest-path").arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml")); cargo.arg("--manifest-path").arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml"));
rustc_cargo_env(builder, &mut cargo); rustc_cargo_env(builder, &mut cargo);
@ -175,10 +175,10 @@ impl Step for Test {
let compiler = builder.compiler(0, builder.config.build); let compiler = builder.compiler(0, builder.config.build);
let target = self.target; let target = self.target;
let out_dir = builder.stage_out(compiler, Mode::Libtest); let out_dir = builder.stage_out(compiler, Mode::Test);
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target)); builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check"); let mut cargo = builder.cargo(compiler, Mode::Test, target, "check");
test_cargo(builder, &compiler, target, &mut cargo); test_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
@ -236,7 +236,7 @@ impl Step for Rustdoc {
builder.ensure(tool::CleanTools { builder.ensure(tool::CleanTools {
compiler, compiler,
target, target,
mode: Mode::Tool, mode: Mode::ToolRustc,
}); });
} }
} }
@ -244,19 +244,19 @@ impl Step for Rustdoc {
/// Cargo's output path for the standard library in a given stage, compiled /// Cargo's output path for the standard library in a given stage, compiled
/// by a particular compiler for the specified target. /// by a particular compiler for the specified target.
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf { pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp") builder.cargo_out(compiler, Mode::Std, target).join(".libstd-check.stamp")
} }
/// Cargo's output path for libtest in a given stage, compiled by a particular /// Cargo's output path for libtest in a given stage, compiled by a particular
/// compiler for the specified target. /// compiler for the specified target.
pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf { pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp") builder.cargo_out(compiler, Mode::Test, target).join(".libtest-check.stamp")
} }
/// Cargo's output path for librustc in a given stage, compiled by a particular /// Cargo's output path for librustc in a given stage, compiled by a particular
/// compiler for the specified target. /// compiler for the specified target.
pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf { pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp") builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp")
} }
/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular /// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
@ -265,12 +265,12 @@ fn codegen_backend_stamp(builder: &Builder,
compiler: Compiler, compiler: Compiler,
target: Interned<String>, target: Interned<String>,
backend: Interned<String>) -> PathBuf { backend: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target) builder.cargo_out(compiler, Mode::Codegen, target)
.join(format!(".librustc_codegen_llvm-{}-check.stamp", backend)) .join(format!(".librustc_codegen_llvm-{}-check.stamp", backend))
} }
/// Cargo's output path for rustdoc in a given stage, compiled by a particular /// Cargo's output path for rustdoc in a given stage, compiled by a particular
/// compiler for the specified target. /// compiler for the specified target.
pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf { pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Tool, target).join(".rustdoc-check.stamp") builder.cargo_out(compiler, Mode::ToolRustc, target).join(".rustdoc-check.stamp")
} }

View file

@ -98,9 +98,9 @@ impl Step for Std {
copy_musl_third_party_objects(builder, target, &libdir); copy_musl_third_party_objects(builder, target, &libdir);
} }
let out_dir = builder.cargo_out(compiler, Mode::Libstd, target); let out_dir = builder.cargo_out(compiler, Mode::Std, target);
builder.clear_if_dirty(&out_dir, &builder.rustc(compiler)); builder.clear_if_dirty(&out_dir, &builder.rustc(compiler));
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Std, target, "build");
std_cargo(builder, &compiler, target, &mut cargo); std_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
@ -240,7 +240,7 @@ impl Step for StdLink {
builder.ensure(tool::CleanTools { builder.ensure(tool::CleanTools {
compiler: target_compiler, compiler: target_compiler,
target, target,
mode: Mode::Libstd, mode: Mode::Std,
}); });
} }
} }
@ -368,9 +368,9 @@ impl Step for Test {
return; return;
} }
let out_dir = builder.cargo_out(compiler, Mode::Libtest, target); let out_dir = builder.cargo_out(compiler, Mode::Test, target);
builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target)); builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target));
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Test, target, "build");
test_cargo(builder, &compiler, target, &mut cargo); test_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
@ -431,7 +431,7 @@ impl Step for TestLink {
builder.ensure(tool::CleanTools { builder.ensure(tool::CleanTools {
compiler: target_compiler, compiler: target_compiler,
target, target,
mode: Mode::Libtest, mode: Mode::Test,
}); });
} }
} }
@ -489,11 +489,11 @@ impl Step for Rustc {
compiler: builder.compiler(self.compiler.stage, builder.config.build), compiler: builder.compiler(self.compiler.stage, builder.config.build),
target: builder.config.build, target: builder.config.build,
}); });
let cargo_out = builder.cargo_out(compiler, Mode::Librustc, target); let cargo_out = builder.cargo_out(compiler, Mode::Rustc, target);
builder.clear_if_dirty(&cargo_out, &libstd_stamp(builder, compiler, target)); builder.clear_if_dirty(&cargo_out, &libstd_stamp(builder, compiler, target));
builder.clear_if_dirty(&cargo_out, &libtest_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"); let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "build");
rustc_cargo(builder, &mut cargo); rustc_cargo(builder, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
@ -585,7 +585,7 @@ impl Step for RustcLink {
builder.ensure(tool::CleanTools { builder.ensure(tool::CleanTools {
compiler: target_compiler, compiler: target_compiler,
target, target,
mode: Mode::Librustc, mode: Mode::Rustc,
}); });
} }
} }
@ -634,7 +634,7 @@ impl Step for CodegenBackend {
return; return;
} }
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "build");
let mut features = builder.rustc_features().to_string(); let mut features = builder.rustc_features().to_string();
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml")); .arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml"));
@ -642,7 +642,7 @@ impl Step for CodegenBackend {
features += &build_codegen_backend(&builder, &mut cargo, &compiler, target, backend); features += &build_codegen_backend(&builder, &mut cargo, &compiler, target, backend);
let tmp_stamp = builder.cargo_out(compiler, Mode::Librustc, target) let tmp_stamp = builder.cargo_out(compiler, Mode::Codegen, target)
.join(".tmp.stamp"); .join(".tmp.stamp");
let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage));
@ -793,19 +793,19 @@ fn copy_lld_to_sysroot(builder: &Builder,
/// Cargo's output path for the standard library in a given stage, compiled /// Cargo's output path for the standard library in a given stage, compiled
/// by a particular compiler for the specified target. /// by a particular compiler for the specified target.
pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf { pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libstd, target).join(".libstd.stamp") builder.cargo_out(compiler, Mode::Std, target).join(".libstd.stamp")
} }
/// Cargo's output path for libtest in a given stage, compiled by a particular /// Cargo's output path for libtest in a given stage, compiled by a particular
/// compiler for the specified target. /// compiler for the specified target.
pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf { pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Libtest, target).join(".libtest.stamp") builder.cargo_out(compiler, Mode::Test, target).join(".libtest.stamp")
} }
/// Cargo's output path for librustc in a given stage, compiled by a particular /// Cargo's output path for librustc in a given stage, compiled by a particular
/// compiler for the specified target. /// compiler for the specified target.
pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf { pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target).join(".librustc.stamp") builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc.stamp")
} }
/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular /// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
@ -814,7 +814,7 @@ fn codegen_backend_stamp(builder: &Builder,
compiler: Compiler, compiler: Compiler,
target: Interned<String>, target: Interned<String>,
backend: Interned<String>) -> PathBuf { backend: Interned<String>) -> PathBuf {
builder.cargo_out(compiler, Mode::Librustc, target) builder.cargo_out(compiler, Mode::Codegen, target)
.join(format!(".librustc_codegen_llvm-{}.stamp", backend)) .join(format!(".librustc_codegen_llvm-{}.stamp", backend))
} }
@ -971,7 +971,7 @@ impl Step for Assemble {
} }
// Link the compiler binary itself into place // Link the compiler binary itself into place
let out_dir = builder.cargo_out(build_compiler, Mode::Librustc, host); let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host);
let rustc = out_dir.join(exe("rustc_binary", &*host)); let rustc = out_dir.join(exe("rustc_binary", &*host));
let bindir = sysroot.join("bin"); let bindir = sysroot.join("bin");
t!(fs::create_dir_all(&bindir)); t!(fs::create_dir_all(&bindir));

View file

@ -722,7 +722,7 @@ impl Step for Analysis {
let image = tmpdir(builder).join(format!("{}-{}-image", name, target)); let image = tmpdir(builder).join(format!("{}-{}-image", name, target));
let src = builder.stage_out(compiler, Mode::Libstd) let src = builder.stage_out(compiler, Mode::Std)
.join(target).join(builder.cargo_dir()).join("deps"); .join(target).join(builder.cargo_dir()).join("deps");
let image_src = src.join("save-analysis"); let image_src = src.join("save-analysis");

View file

@ -463,7 +463,7 @@ impl Step for Std {
}; };
builder.ensure(compile::Std { compiler, target }); builder.ensure(compile::Std { compiler, target });
let out_dir = builder.stage_out(compiler, Mode::Libstd) let out_dir = builder.stage_out(compiler, Mode::Std)
.join(target).join("doc"); .join(target).join("doc");
// Here what we're doing is creating a *symlink* (directory junction on // Here what we're doing is creating a *symlink* (directory junction on
@ -483,7 +483,7 @@ impl Step for Std {
builder.clear_if_dirty(&my_out, &rustdoc); builder.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "doc"); let mut cargo = builder.cargo(compiler, Mode::Std, target, "doc");
compile::std_cargo(builder, &compiler, target, &mut cargo); compile::std_cargo(builder, &compiler, target, &mut cargo);
// Keep a whitelist so we do not build internal stdlib crates, these will be // Keep a whitelist so we do not build internal stdlib crates, these will be
@ -546,7 +546,7 @@ impl Step for Test {
builder.ensure(Std { stage, target }); builder.ensure(Std { stage, target });
builder.ensure(compile::Test { compiler, target }); builder.ensure(compile::Test { compiler, target });
let out_dir = builder.stage_out(compiler, Mode::Libtest) let out_dir = builder.stage_out(compiler, Mode::Test)
.join(target).join("doc"); .join(target).join("doc");
// See docs in std above for why we symlink // See docs in std above for why we symlink
@ -554,7 +554,7 @@ impl Step for Test {
builder.clear_if_dirty(&my_out, &rustdoc); builder.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc"); let mut cargo = builder.cargo(compiler, Mode::Test, target, "doc");
compile::test_cargo(builder, &compiler, target, &mut cargo); compile::test_cargo(builder, &compiler, target, &mut cargo);
cargo.arg("--no-deps").arg("-p").arg("test"); cargo.arg("--no-deps").arg("-p").arg("test");
@ -614,7 +614,7 @@ impl Step for WhitelistedRustc {
builder.ensure(Std { stage, target }); builder.ensure(Std { stage, target });
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc { compiler, target });
let out_dir = builder.stage_out(compiler, Mode::Librustc) let out_dir = builder.stage_out(compiler, Mode::Rustc)
.join(target).join("doc"); .join(target).join("doc");
// See docs in std above for why we symlink // See docs in std above for why we symlink
@ -622,7 +622,7 @@ impl Step for WhitelistedRustc {
builder.clear_if_dirty(&my_out, &rustdoc); builder.clear_if_dirty(&my_out, &rustdoc);
t!(symlink_dir_force(&builder.config, &my_out, &out_dir)); t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc"); let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
compile::rustc_cargo(builder, &mut cargo); compile::rustc_cargo(builder, &mut cargo);
// We don't want to build docs for internal compiler dependencies in this // We don't want to build docs for internal compiler dependencies in this
@ -698,12 +698,12 @@ impl Step for Rustc {
// We do not symlink to the same shared folder that already contains std library // 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. // documentation from previous steps as we do not want to include that.
let out_dir = builder.stage_out(compiler, Mode::Librustc).join(target).join("doc"); let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc");
builder.clear_if_dirty(&out, &rustdoc); builder.clear_if_dirty(&out, &rustdoc);
t!(symlink_dir_force(&builder.config, &out, &out_dir)); t!(symlink_dir_force(&builder.config, &out, &out_dir));
// Build cargo command. // Build cargo command.
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc"); let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
cargo.env("RUSTDOCFLAGS", "--document-private-items"); cargo.env("RUSTDOCFLAGS", "--document-private-items");
compile::rustc_cargo(builder, &mut cargo); compile::rustc_cargo(builder, &mut cargo);

View file

@ -307,16 +307,20 @@ impl Crate {
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Mode { pub enum Mode {
/// Build the standard library, placing output in the "stageN-std" directory. /// Build the standard library, placing output in the "stageN-std" directory.
Libstd, Std,
/// Build libtest, placing output in the "stageN-test" directory. /// Build libtest, placing output in the "stageN-test" directory.
Libtest, Test,
/// Build librustc and compiler libraries, placing output in the "stageN-rustc" directory. /// Build librustc, codegen and compiler libraries, placing output
Librustc, /// in the "stageN-rustc" directory.
Rustc,
Codegen,
/// Build some tool, placing output in the "stageN-tools" directory. /// Build some tools, placing output in the "stageN-tools" directory.
Tool, ToolStd,
ToolTest,
ToolRustc,
} }
impl Build { impl Build {
@ -517,10 +521,13 @@ impl Build {
/// The mode indicates what the root directory is for. /// The mode indicates what the root directory is for.
fn stage_out(&self, compiler: Compiler, mode: Mode) -> PathBuf { fn stage_out(&self, compiler: Compiler, mode: Mode) -> PathBuf {
let suffix = match mode { let suffix = match mode {
Mode::Libstd => "-std", Mode::Std => "-std",
Mode::Libtest => "-test", Mode::ToolStd => "-tools",
Mode::Tool => "-tools", Mode::Test => "-test",
Mode::Librustc => "-rustc", Mode::ToolTest => "-tools",
Mode::Codegen => "-rustc",
Mode::Rustc => "-rustc",
Mode::ToolRustc => "-tools",
}; };
self.out.join(&*compiler.host) self.out.join(&*compiler.host)
.join(format!("stage{}{}", compiler.stage, suffix)) .join(format!("stage{}{}", compiler.stage, suffix))

View file

@ -222,7 +222,7 @@ impl Step for Cargo {
compiler, compiler,
target: self.host, target: self.host,
}); });
let mut cargo = builder.cargo(compiler, Mode::Tool, self.host, "test"); let mut cargo = builder.cargo(compiler, Mode::ToolRustc, self.host, "test");
cargo cargo
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join("src/tools/cargo/Cargo.toml")); .arg(builder.src.join("src/tools/cargo/Cargo.toml"));
@ -383,7 +383,7 @@ impl Step for Miri {
extra_features: Vec::new(), extra_features: Vec::new(),
}); });
if let Some(miri) = miri { if let Some(miri) = miri {
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
cargo cargo
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join("src/tools/miri/Cargo.toml")); .arg(builder.src.join("src/tools/miri/Cargo.toml"));
@ -441,7 +441,7 @@ impl Step for Clippy {
extra_features: Vec::new(), extra_features: Vec::new(),
}); });
if let Some(clippy) = clippy { if let Some(clippy) = clippy {
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test"); let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
cargo cargo
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join("src/tools/clippy/Cargo.toml")); .arg(builder.src.join("src/tools/clippy/Cargo.toml"));
@ -453,7 +453,7 @@ impl Step for Clippy {
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler)); cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
let host_libs = builder let host_libs = builder
.stage_out(compiler, Mode::Tool) .stage_out(compiler, Mode::ToolRustc)
.join(builder.cargo_dir()); .join(builder.cargo_dir());
cargo.env("HOST_LIBS", host_libs); cargo.env("HOST_LIBS", host_libs);
// clippy tests need to find the driver // clippy tests need to find the driver
@ -1434,7 +1434,7 @@ impl Step for CrateLibrustc {
builder.ensure(Crate { builder.ensure(Crate {
compiler: self.compiler, compiler: self.compiler,
target: self.target, target: self.target,
mode: Mode::Librustc, mode: Mode::Rustc,
test_kind: self.test_kind, test_kind: self.test_kind,
krate: self.krate, krate: self.krate,
}); });
@ -1485,7 +1485,7 @@ impl Step for CrateNotDefault {
builder.ensure(Crate { builder.ensure(Crate {
compiler: self.compiler, compiler: self.compiler,
target: self.target, target: self.target,
mode: Mode::Libstd, mode: Mode::Std,
test_kind: self.test_kind, test_kind: self.test_kind,
krate: INTERNER.intern_str(self.krate), krate: INTERNER.intern_str(self.krate),
}); });
@ -1538,12 +1538,12 @@ impl Step for Crate {
for krate in builder.in_tree_crates("std") { for krate in builder.in_tree_crates("std") {
if run.path.ends_with(&krate.local_path(&builder)) { if run.path.ends_with(&krate.local_path(&builder)) {
make(Mode::Libstd, krate); make(Mode::Std, krate);
} }
} }
for krate in builder.in_tree_crates("test") { for krate in builder.in_tree_crates("test") {
if run.path.ends_with(&krate.local_path(&builder)) { if run.path.ends_with(&krate.local_path(&builder)) {
make(Mode::Libtest, krate); make(Mode::Test, krate);
} }
} }
} }
@ -1578,13 +1578,13 @@ impl Step for Crate {
let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand()); let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
match mode { match mode {
Mode::Libstd => { Mode::Std => {
compile::std_cargo(builder, &compiler, target, &mut cargo); compile::std_cargo(builder, &compiler, target, &mut cargo);
} }
Mode::Libtest => { Mode::Test => {
compile::test_cargo(builder, &compiler, target, &mut cargo); compile::test_cargo(builder, &compiler, target, &mut cargo);
} }
Mode::Librustc => { Mode::Rustc => {
builder.ensure(compile::Rustc { compiler, target }); builder.ensure(compile::Rustc { compiler, target });
compile::rustc_cargo(builder, &mut cargo); compile::rustc_cargo(builder, &mut cargo);
} }

View file

@ -46,18 +46,18 @@ impl Step for CleanTools {
// This is for the original compiler, but if we're forced to use stage 1, then // 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 // 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. // we copy the libs forward.
let tools_dir = builder.stage_out(compiler, Mode::Tool); let tools_dir = builder.stage_out(compiler, Mode::ToolRustc);
let compiler = if builder.force_use_stage1(compiler, target) { let compiler = if builder.force_use_stage1(compiler, target) {
builder.compiler(1, compiler.host) builder.compiler(1, compiler.host)
} else { } else {
compiler compiler
}; };
for &cur_mode in &[Mode::Libstd, Mode::Libtest, Mode::Librustc] { for &cur_mode in &[Mode::ToolStd, Mode::ToolTest, Mode::ToolRustc] {
let stamp = match cur_mode { let stamp = match cur_mode {
Mode::Libstd => libstd_stamp(builder, compiler, target), Mode::ToolStd => libstd_stamp(builder, compiler, target),
Mode::Libtest => libtest_stamp(builder, compiler, target), Mode::ToolTest => libtest_stamp(builder, compiler, target),
Mode::Librustc => librustc_stamp(builder, compiler, target), Mode::ToolRustc => librustc_stamp(builder, compiler, target),
_ => panic!(), _ => panic!(),
}; };
@ -104,10 +104,10 @@ impl Step for ToolBuild {
let is_ext_tool = self.is_ext_tool; let is_ext_tool = self.is_ext_tool;
match self.mode { match self.mode {
Mode::Libstd => builder.ensure(compile::Std { compiler, target }), Mode::ToolStd => builder.ensure(compile::Std { compiler, target }),
Mode::Libtest => builder.ensure(compile::Test { compiler, target }), Mode::ToolTest => builder.ensure(compile::Test { compiler, target }),
Mode::Librustc => builder.ensure(compile::Rustc { compiler, target }), Mode::ToolRustc => builder.ensure(compile::Rustc { compiler, target }),
Mode::Tool => panic!("unexpected Mode::Tool for tool build") _ => panic!("unexpected Mode for tool build")
} }
let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path); let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path);
@ -202,7 +202,7 @@ impl Step for ToolBuild {
return None; return None;
} }
} else { } else {
let cargo_out = builder.cargo_out(compiler, Mode::Tool, target) let cargo_out = builder.cargo_out(compiler, Mode::ToolRustc, target)
.join(exe(tool, &compiler.host)); .join(exe(tool, &compiler.host));
let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host)); let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host));
builder.copy(&cargo_out, &bin); builder.copy(&cargo_out, &bin);
@ -218,7 +218,7 @@ pub fn prepare_tool_cargo(
command: &'static str, command: &'static str,
path: &'static str, path: &'static str,
) -> Command { ) -> Command {
let mut cargo = builder.cargo(compiler, Mode::Tool, target, command); let mut cargo = builder.cargo(compiler, Mode::ToolRustc, target, command);
let dir = builder.src.join(path); let dir = builder.src.join(path);
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml")); cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
@ -324,17 +324,17 @@ macro_rules! tool {
} }
tool!( tool!(
Rustbook, "src/tools/rustbook", "rustbook", Mode::Librustc; Rustbook, "src/tools/rustbook", "rustbook", Mode::ToolRustc;
ErrorIndex, "src/tools/error_index_generator", "error_index_generator", Mode::Librustc; ErrorIndex, "src/tools/error_index_generator", "error_index_generator", Mode::ToolRustc;
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::Libstd; UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolStd;
Tidy, "src/tools/tidy", "tidy", Mode::Libstd; Tidy, "src/tools/tidy", "tidy", Mode::ToolStd;
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::Libstd; Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolStd;
CargoTest, "src/tools/cargotest", "cargotest", Mode::Libstd; CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolStd;
Compiletest, "src/tools/compiletest", "compiletest", Mode::Libtest; Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolTest;
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolStd;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolStd;
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolStd;
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::Libstd; RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolStd;
); );
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@ -362,7 +362,7 @@ impl Step for RemoteTestServer {
compiler: self.compiler, compiler: self.compiler,
target: self.target, target: self.target,
tool: "remote-test-server", tool: "remote-test-server",
mode: Mode::Libstd, mode: Mode::ToolStd,
path: "src/tools/remote-test-server", path: "src/tools/remote-test-server",
is_ext_tool: false, is_ext_tool: false,
extra_features: Vec::new(), extra_features: Vec::new(),
@ -430,7 +430,7 @@ impl Step for Rustdoc {
// Cargo adds a number of paths to the dylib search path on windows, which results in // 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" // the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
// rustdoc a different name. // rustdoc a different name.
let tool_rustdoc = builder.cargo_out(build_compiler, Mode::Tool, target) let tool_rustdoc = builder.cargo_out(build_compiler, Mode::ToolRustc, target)
.join(exe("rustdoc_tool_binary", &target_compiler.host)); .join(exe("rustdoc_tool_binary", &target_compiler.host));
// don't create a stage0-sysroot/bin directory. // don't create a stage0-sysroot/bin directory.
@ -485,7 +485,7 @@ impl Step for Cargo {
compiler: self.compiler, compiler: self.compiler,
target: self.target, target: self.target,
tool: "cargo", tool: "cargo",
mode: Mode::Librustc, mode: Mode::ToolRustc,
path: "src/tools/cargo", path: "src/tools/cargo",
is_ext_tool: false, is_ext_tool: false,
extra_features: Vec::new(), extra_features: Vec::new(),
@ -533,7 +533,7 @@ macro_rules! tool_extended {
compiler: $sel.compiler, compiler: $sel.compiler,
target: $sel.target, target: $sel.target,
tool: $tool_name, tool: $tool_name,
mode: Mode::Librustc, mode: Mode::ToolRustc,
path: $path, path: $path,
extra_features: $sel.extra_features, extra_features: $sel.extra_features,
is_ext_tool: true, is_ext_tool: true,
@ -587,7 +587,7 @@ impl<'a> Builder<'a> {
let host = &compiler.host; let host = &compiler.host;
let mut lib_paths: Vec<PathBuf> = vec![ let mut lib_paths: Vec<PathBuf> = vec![
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)), PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)),
self.cargo_out(compiler, Mode::Tool, *host).join("deps"), self.cargo_out(compiler, Mode::ToolRustc, *host).join("deps"),
]; ];
// On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make // On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make