提交 62f73dc8 编写于 作者: T Tatsuyuki Ishi

Refactor is_external_tool into source_type

上级 a89f8e13
......@@ -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 @@ fn run(self, builder: &Builder) {
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);
......
......@@ -28,7 +28,7 @@
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 @@ fn run(self, builder: &Builder) {
target,
"doc",
"src/tools/rustdoc",
false
SourceType::InTree,
);
cargo.env("RUSTDOCFLAGS", "--document-private-items");
......
......@@ -30,7 +30,7 @@
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 @@ fn run(self, builder: &Builder) {
self.host,
"test",
"src/tools/cargo",
true);
SourceType::Submodule);
if !builder.fail_fast {
cargo.arg("--no-fail-fast");
......@@ -288,7 +288,7 @@ fn run(self, builder: &Builder) {
host,
"test",
"src/tools/rls",
true);
SourceType::Submodule);
builder.add_rustc_lib_path(compiler, &mut cargo);
......@@ -341,7 +341,7 @@ fn run(self, builder: &Builder) {
host,
"test",
"src/tools/rustfmt",
true);
SourceType::Submodule);
let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir));
......@@ -396,7 +396,7 @@ fn run(self, builder: &Builder) {
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 @@ fn run(self, builder: &Builder) {
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 @@ fn run(self, builder: &Builder) {
target,
test_kind.subcommand(),
"src/tools/rustdoc",
false);
SourceType::InTree);
if test_kind.subcommand() == "test" && !builder.fail_fast {
cargo.arg("--no-fail-fast");
}
......
......@@ -75,6 +75,12 @@ fn run(self, builder: &Builder) {
}
}
#[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<String>,
}
......@@ -123,7 +129,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
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<String>,
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 @@ fn run(self, builder: &Builder) -> PathBuf {
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 @@ fn run(self, builder: &Builder) -> PathBuf {
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 @@ fn run(self, builder: &Builder) -> PathBuf {
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 @@ fn run(self, builder: &Builder) -> PathBuf {
target,
"build",
"src/tools/rustdoc",
false,
SourceType::InTree,
);
// Most tools don't get debuginfo, but rustdoc should.
......@@ -547,7 +557,7 @@ fn run(self, builder: &Builder) -> PathBuf {
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 @@ fn run(mut $sel, $builder: &Builder) -> Option<PathBuf> {
path: $path,
extra_features: $sel.extra_features,
is_optional_tool: true,
is_external_tool: true,
source_type: SourceType::Submodule,
})
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册