diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index dd2a64402b46f..8838cdeed8687 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, rustc_cargo_env, add_to_sysroot}; use builder::{RunConfig, Builder, ShouldRun, Step}; -use tool::{self, prepare_tool_cargo}; +use tool::{self, prepare_tool_cargo, SourceType}; use {Compiler, Mode}; use cache::{INTERNER, Interned}; use std::path::PathBuf; @@ -223,7 +223,7 @@ impl Step for Rustdoc { target, "check", "src/tools/rustdoc", - false); + SourceType::InTree); let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage)); println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 913b8162a44bf..fd3730ffc78de 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -28,7 +28,7 @@ use build_helper::up_to_date; use util::symlink_dir; use builder::{Builder, Compiler, RunConfig, ShouldRun, Step}; -use tool::{self, prepare_tool_cargo, Tool}; +use tool::{self, prepare_tool_cargo, Tool, SourceType}; use compile; use cache::{INTERNER, Interned}; use config::Config; @@ -814,7 +814,7 @@ impl Step for Rustdoc { target, "doc", "src/tools/rustdoc", - false + SourceType::InTree, ); cargo.env("RUSTDOCFLAGS", "--document-private-items"); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 6cb70deb86c74..7c69197885cf2 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -30,7 +30,7 @@ use compile; use dist; use flags::Subcommand; use native; -use tool::{self, Tool}; +use tool::{self, Tool, SourceType}; use toolstate::ToolState; use util::{self, dylib_path, dylib_path_var}; use Crate as CargoCrate; @@ -228,7 +228,7 @@ impl Step for Cargo { self.host, "test", "src/tools/cargo", - true); + SourceType::Submodule); if !builder.fail_fast { cargo.arg("--no-fail-fast"); @@ -288,7 +288,7 @@ impl Step for Rls { host, "test", "src/tools/rls", - true); + SourceType::Submodule); builder.add_rustc_lib_path(compiler, &mut cargo); @@ -341,7 +341,7 @@ impl Step for Rustfmt { host, "test", "src/tools/rustfmt", - true); + SourceType::Submodule); let dir = testdir(builder, compiler.host); t!(fs::create_dir_all(&dir)); @@ -396,7 +396,7 @@ impl Step for Miri { host, "test", "src/tools/miri", - true); + SourceType::Submodule); // miri tests need to know about the stage sysroot cargo.env("MIRI_SYSROOT", builder.sysroot(compiler)); @@ -455,7 +455,7 @@ impl Step for Clippy { host, "test", "src/tools/clippy", - true); + SourceType::Submodule); // clippy tests need to know about the stage sysroot cargo.env("SYSROOT", builder.sysroot(compiler)); @@ -1740,7 +1740,7 @@ impl Step for CrateRustdoc { target, test_kind.subcommand(), "src/tools/rustdoc", - false); + SourceType::InTree); if test_kind.subcommand() == "test" && !builder.fail_fast { cargo.arg("--no-fail-fast"); } diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 7301c59b0fae1..5e68b797b3d54 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -75,6 +75,12 @@ impl Step for CleanTools { } } +#[derive(Debug, Clone, Hash, PartialEq, Eq)] +pub enum SourceType { + InTree, + Submodule, +} + #[derive(Debug, Clone, Hash, PartialEq, Eq)] struct ToolBuild { compiler: Compiler, @@ -83,7 +89,7 @@ struct ToolBuild { path: &'static str, mode: Mode, is_optional_tool: bool, - is_external_tool: bool, + source_type: SourceType, extra_features: Vec, } @@ -123,7 +129,7 @@ impl Step for ToolBuild { target, "build", path, - self.is_external_tool, + self.source_type, ); cargo.arg("--features").arg(self.extra_features.join(" ")); @@ -247,7 +253,7 @@ pub fn prepare_tool_cargo( target: Interned, command: &'static str, path: &'static str, - is_external_tool: bool, + source_type: SourceType, ) -> Command { let mut cargo = builder.cargo(compiler, mode, target, command); let dir = builder.src.join(path); @@ -257,7 +263,7 @@ pub fn prepare_tool_cargo( // stages and such and it's just easier if they're not dynamically linked. cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); - if is_external_tool { + if source_type == SourceType::Submodule { cargo.env("RUSTC_EXTERNAL_TOOL", "1"); } @@ -289,7 +295,7 @@ pub fn prepare_tool_cargo( macro_rules! tool { ($($name:ident, $path:expr, $tool_name:expr, $mode:expr - $(,llvm_tools = $llvm:expr)* $(,external_tool = $external:expr)*;)+) => { + $(,llvm_tools = $llvm:expr)* $(,is_external_tool = $external:expr)*;)+) => { #[derive(Copy, PartialEq, Eq, Clone)] pub enum Tool { $( @@ -367,7 +373,11 @@ macro_rules! tool { mode: $mode, path: $path, is_optional_tool: false, - is_external_tool: false $(|| $external)*, + source_type: if false $(|| $external)* { + SourceType::Submodule + } else { + SourceType::InTree + }, extra_features: Vec::new(), }).expect("expected to build -- essential tool") } @@ -387,7 +397,7 @@ tool!( BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap, - external_tool = true; + is_external_tool = true; RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap; ); @@ -419,7 +429,7 @@ impl Step for RemoteTestServer { mode: Mode::ToolStd, path: "src/tools/remote-test-server", is_optional_tool: false, - is_external_tool: false, + source_type: SourceType::InTree, extra_features: Vec::new(), }).expect("expected to build -- essential tool") } @@ -474,7 +484,7 @@ impl Step for Rustdoc { target, "build", "src/tools/rustdoc", - false, + SourceType::InTree, ); // Most tools don't get debuginfo, but rustdoc should. @@ -547,7 +557,7 @@ impl Step for Cargo { mode: Mode::ToolRustc, path: "src/tools/cargo", is_optional_tool: false, - is_external_tool: true, + source_type: SourceType::Submodule, extra_features: Vec::new(), }).expect("expected to build -- essential tool") } @@ -597,7 +607,7 @@ macro_rules! tool_extended { path: $path, extra_features: $sel.extra_features, is_optional_tool: true, - is_external_tool: true, + source_type: SourceType::Submodule, }) } }