thread tool modes through

This commit is contained in:
Collins Abitekaniza 2018-05-28 01:09:43 +03:00
parent ce10910b69
commit fb949b5336
3 changed files with 36 additions and 16 deletions

View File

@ -219,6 +219,7 @@ fn run(self, builder: &Builder) {
let mut cargo = prepare_tool_cargo(builder,
compiler,
Mode::Rustc,
target,
"check",
"src/tools/rustdoc");

View File

@ -281,7 +281,12 @@ fn run(self, builder: &Builder) {
return;
}
let mut cargo = tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rls");
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
Mode::Rustc,
host,
"test",
"src/tools/rls");
// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@ -331,8 +336,12 @@ fn run(self, builder: &Builder) {
return;
}
let mut cargo =
tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rustfmt");
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
Mode::Rustc,
host,
"test",
"src/tools/rustfmt");
// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@ -1718,13 +1727,12 @@ fn run(self, builder: &Builder) {
let compiler = builder.compiler(builder.top_stage, self.host);
let target = compiler.host;
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
target,
test_kind.subcommand(),
"src/tools/rustdoc",
);
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
Mode::Rustc,
target,
test_kind.subcommand(),
"src/tools/rustdoc");
if test_kind.subcommand() == "test" && !builder.fail_fast {
cargo.arg("--no-fail-fast");
}

View File

@ -110,7 +110,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
_ => 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, self.mode, target, "build", path);
cargo.arg("--features").arg(self.extra_features.join(" "));
let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
@ -202,7 +202,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
return None;
}
} else {
let cargo_out = builder.cargo_out(compiler, Mode::ToolRustc, target)
let cargo_out = builder.cargo_out(compiler, self.mode, target)
.join(exe(tool, &compiler.host));
let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host));
builder.copy(&cargo_out, &bin);
@ -214,11 +214,12 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
pub fn prepare_tool_cargo(
builder: &Builder,
compiler: Compiler,
mode: Mode,
target: Interned<String>,
command: &'static str,
path: &'static str,
) -> Command {
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, target, command);
let mut cargo = builder.cargo(compiler, mode, target, command);
let dir = builder.src.join(path);
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
@ -261,6 +262,15 @@ pub enum Tool {
)+
}
impl Tool {
pub fn get_mode(&self) -> Mode {
let mode = match self {
$(Tool::$name => $mode,)+
};
mode
}
}
impl<'a> Builder<'a> {
pub fn tool_exe(&self, tool: Tool) -> PathBuf {
let stage = self.tool_default_stage(tool);
@ -414,6 +424,7 @@ fn run(self, builder: &Builder) -> PathBuf {
let mut cargo = prepare_tool_cargo(builder,
build_compiler,
Mode::ToolRustc,
target,
"build",
"src/tools/rustdoc");
@ -575,7 +586,7 @@ impl<'a> Builder<'a> {
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.config.build);
self.prepare_tool_cmd(compiler, &mut cmd);
self.prepare_tool_cmd(compiler, tool.get_mode(), &mut cmd);
cmd
}
@ -583,11 +594,11 @@ pub fn tool_cmd(&self, tool: Tool) -> Command {
///
/// Notably this munges the dynamic library lookup path to point to the
/// right location to run `compiler`.
fn prepare_tool_cmd(&self, compiler: Compiler, cmd: &mut Command) {
fn prepare_tool_cmd(&self, compiler: Compiler, mode: Mode, cmd: &mut Command) {
let host = &compiler.host;
let mut lib_paths: Vec<PathBuf> = vec![
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)),
self.cargo_out(compiler, Mode::ToolRustc, *host).join("deps"),
self.cargo_out(compiler, mode, *host).join("deps"),
];
// On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make