Refactor is_external_tool into source_type

This commit is contained in:
Tatsuyuki Ishi 2018-07-26 12:36:58 +09:00
parent a89f8e1340
commit 62f73dc87c
4 changed files with 32 additions and 22 deletions

View File

@ -12,7 +12,7 @@
use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot}; use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
use builder::{RunConfig, Builder, ShouldRun, Step}; use builder::{RunConfig, Builder, ShouldRun, Step};
use tool::{self, prepare_tool_cargo}; use tool::{self, prepare_tool_cargo, SourceType};
use {Compiler, Mode}; use {Compiler, Mode};
use cache::{INTERNER, Interned}; use cache::{INTERNER, Interned};
use std::path::PathBuf; use std::path::PathBuf;
@ -223,7 +223,7 @@ impl Step for Rustdoc {
target, target,
"check", "check",
"src/tools/rustdoc", "src/tools/rustdoc",
false); SourceType::InTree);
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target); println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);

View File

@ -28,7 +28,7 @@ use build_helper::up_to_date;
use util::symlink_dir; use util::symlink_dir;
use builder::{Builder, Compiler, RunConfig, ShouldRun, Step}; 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 compile;
use cache::{INTERNER, Interned}; use cache::{INTERNER, Interned};
use config::Config; use config::Config;
@ -814,7 +814,7 @@ impl Step for Rustdoc {
target, target,
"doc", "doc",
"src/tools/rustdoc", "src/tools/rustdoc",
false SourceType::InTree,
); );
cargo.env("RUSTDOCFLAGS", "--document-private-items"); cargo.env("RUSTDOCFLAGS", "--document-private-items");

View File

@ -30,7 +30,7 @@ use compile;
use dist; use dist;
use flags::Subcommand; use flags::Subcommand;
use native; use native;
use tool::{self, Tool}; use tool::{self, Tool, SourceType};
use toolstate::ToolState; use toolstate::ToolState;
use util::{self, dylib_path, dylib_path_var}; use util::{self, dylib_path, dylib_path_var};
use Crate as CargoCrate; use Crate as CargoCrate;
@ -228,7 +228,7 @@ impl Step for Cargo {
self.host, self.host,
"test", "test",
"src/tools/cargo", "src/tools/cargo",
true); SourceType::Submodule);
if !builder.fail_fast { if !builder.fail_fast {
cargo.arg("--no-fail-fast"); cargo.arg("--no-fail-fast");
@ -288,7 +288,7 @@ impl Step for Rls {
host, host,
"test", "test",
"src/tools/rls", "src/tools/rls",
true); SourceType::Submodule);
builder.add_rustc_lib_path(compiler, &mut cargo); builder.add_rustc_lib_path(compiler, &mut cargo);
@ -341,7 +341,7 @@ impl Step for Rustfmt {
host, host,
"test", "test",
"src/tools/rustfmt", "src/tools/rustfmt",
true); SourceType::Submodule);
let dir = testdir(builder, compiler.host); let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir)); t!(fs::create_dir_all(&dir));
@ -396,7 +396,7 @@ impl Step for Miri {
host, host,
"test", "test",
"src/tools/miri", "src/tools/miri",
true); SourceType::Submodule);
// miri tests need to know about the stage sysroot // miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler)); cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
@ -455,7 +455,7 @@ impl Step for Clippy {
host, host,
"test", "test",
"src/tools/clippy", "src/tools/clippy",
true); SourceType::Submodule);
// clippy tests need to know about the stage sysroot // clippy tests need to know about the stage sysroot
cargo.env("SYSROOT", builder.sysroot(compiler)); cargo.env("SYSROOT", builder.sysroot(compiler));
@ -1740,7 +1740,7 @@ impl Step for CrateRustdoc {
target, target,
test_kind.subcommand(), test_kind.subcommand(),
"src/tools/rustdoc", "src/tools/rustdoc",
false); SourceType::InTree);
if test_kind.subcommand() == "test" && !builder.fail_fast { if test_kind.subcommand() == "test" && !builder.fail_fast {
cargo.arg("--no-fail-fast"); cargo.arg("--no-fail-fast");
} }

View File

@ -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)] #[derive(Debug, Clone, Hash, PartialEq, Eq)]
struct ToolBuild { struct ToolBuild {
compiler: Compiler, compiler: Compiler,
@ -83,7 +89,7 @@ struct ToolBuild {
path: &'static str, path: &'static str,
mode: Mode, mode: Mode,
is_optional_tool: bool, is_optional_tool: bool,
is_external_tool: bool, source_type: SourceType,
extra_features: Vec<String>, extra_features: Vec<String>,
} }
@ -123,7 +129,7 @@ impl Step for ToolBuild {
target, target,
"build", "build",
path, path,
self.is_external_tool, self.source_type,
); );
cargo.arg("--features").arg(self.extra_features.join(" ")); cargo.arg("--features").arg(self.extra_features.join(" "));
@ -247,7 +253,7 @@ pub fn prepare_tool_cargo(
target: Interned<String>, target: Interned<String>,
command: &'static str, command: &'static str,
path: &'static str, path: &'static str,
is_external_tool: bool, source_type: SourceType,
) -> Command { ) -> Command {
let mut cargo = builder.cargo(compiler, mode, target, command); let mut cargo = builder.cargo(compiler, mode, target, command);
let dir = builder.src.join(path); 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. // stages and such and it's just easier if they're not dynamically linked.
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
if is_external_tool { if source_type == SourceType::Submodule {
cargo.env("RUSTC_EXTERNAL_TOOL", "1"); cargo.env("RUSTC_EXTERNAL_TOOL", "1");
} }
@ -289,7 +295,7 @@ pub fn prepare_tool_cargo(
macro_rules! tool { macro_rules! tool {
($($name:ident, $path:expr, $tool_name:expr, $mode:expr ($($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)] #[derive(Copy, PartialEq, Eq, Clone)]
pub enum Tool { pub enum Tool {
$( $(
@ -367,7 +373,11 @@ macro_rules! tool {
mode: $mode, mode: $mode,
path: $path, path: $path,
is_optional_tool: false, is_optional_tool: false,
is_external_tool: false $(|| $external)*, source_type: if false $(|| $external)* {
SourceType::Submodule
} else {
SourceType::InTree
},
extra_features: Vec::new(), extra_features: Vec::new(),
}).expect("expected to build -- essential tool") }).expect("expected to build -- essential tool")
} }
@ -387,7 +397,7 @@ tool!(
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap; BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
RustInstaller, "src/tools/rust-installer", "fabricate", 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; RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
); );
@ -419,7 +429,7 @@ impl Step for RemoteTestServer {
mode: Mode::ToolStd, mode: Mode::ToolStd,
path: "src/tools/remote-test-server", path: "src/tools/remote-test-server",
is_optional_tool: false, is_optional_tool: false,
is_external_tool: false, source_type: SourceType::InTree,
extra_features: Vec::new(), extra_features: Vec::new(),
}).expect("expected to build -- essential tool") }).expect("expected to build -- essential tool")
} }
@ -474,7 +484,7 @@ impl Step for Rustdoc {
target, target,
"build", "build",
"src/tools/rustdoc", "src/tools/rustdoc",
false, SourceType::InTree,
); );
// Most tools don't get debuginfo, but rustdoc should. // Most tools don't get debuginfo, but rustdoc should.
@ -547,7 +557,7 @@ impl Step for Cargo {
mode: Mode::ToolRustc, mode: Mode::ToolRustc,
path: "src/tools/cargo", path: "src/tools/cargo",
is_optional_tool: false, is_optional_tool: false,
is_external_tool: true, source_type: SourceType::Submodule,
extra_features: Vec::new(), extra_features: Vec::new(),
}).expect("expected to build -- essential tool") }).expect("expected to build -- essential tool")
} }
@ -597,7 +607,7 @@ macro_rules! tool_extended {
path: $path, path: $path,
extra_features: $sel.extra_features, extra_features: $sel.extra_features,
is_optional_tool: true, is_optional_tool: true,
is_external_tool: true, source_type: SourceType::Submodule,
}) })
} }
} }