Skip to content

Commit fb949b5

Browse files
author
Collins Abitekaniza
committed
thread tool modes through
1 parent ce10910 commit fb949b5

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

src/bootstrap/check.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ impl Step for Rustdoc {
219219

220220
let mut cargo = prepare_tool_cargo(builder,
221221
compiler,
222+
Mode::Rustc,
222223
target,
223224
"check",
224225
"src/tools/rustdoc");

src/bootstrap/test.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ impl Step for Rls {
281281
return;
282282
}
283283

284-
let mut cargo = tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rls");
284+
let mut cargo = tool::prepare_tool_cargo(builder,
285+
compiler,
286+
Mode::Rustc,
287+
host,
288+
"test",
289+
"src/tools/rls");
285290

286291
// Don't build tests dynamically, just a pain to work with
287292
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -331,8 +336,12 @@ impl Step for Rustfmt {
331336
return;
332337
}
333338

334-
let mut cargo =
335-
tool::prepare_tool_cargo(builder, compiler, host, "test", "src/tools/rustfmt");
339+
let mut cargo = tool::prepare_tool_cargo(builder,
340+
compiler,
341+
Mode::Rustc,
342+
host,
343+
"test",
344+
"src/tools/rustfmt");
336345

337346
// Don't build tests dynamically, just a pain to work with
338347
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -1718,13 +1727,12 @@ impl Step for CrateRustdoc {
17181727
let compiler = builder.compiler(builder.top_stage, self.host);
17191728
let target = compiler.host;
17201729

1721-
let mut cargo = tool::prepare_tool_cargo(
1722-
builder,
1723-
compiler,
1724-
target,
1725-
test_kind.subcommand(),
1726-
"src/tools/rustdoc",
1727-
);
1730+
let mut cargo = tool::prepare_tool_cargo(builder,
1731+
compiler,
1732+
Mode::Rustc,
1733+
target,
1734+
test_kind.subcommand(),
1735+
"src/tools/rustdoc");
17281736
if test_kind.subcommand() == "test" && !builder.fail_fast {
17291737
cargo.arg("--no-fail-fast");
17301738
}

src/bootstrap/tool.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl Step for ToolBuild {
110110
_ => panic!("unexpected Mode for tool build")
111111
}
112112

113-
let mut cargo = prepare_tool_cargo(builder, compiler, target, "build", path);
113+
let mut cargo = prepare_tool_cargo(builder, compiler, self.mode, target, "build", path);
114114
cargo.arg("--features").arg(self.extra_features.join(" "));
115115

116116
let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
@@ -202,7 +202,7 @@ impl Step for ToolBuild {
202202
return None;
203203
}
204204
} else {
205-
let cargo_out = builder.cargo_out(compiler, Mode::ToolRustc, target)
205+
let cargo_out = builder.cargo_out(compiler, self.mode, target)
206206
.join(exe(tool, &compiler.host));
207207
let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host));
208208
builder.copy(&cargo_out, &bin);
@@ -214,11 +214,12 @@ impl Step for ToolBuild {
214214
pub fn prepare_tool_cargo(
215215
builder: &Builder,
216216
compiler: Compiler,
217+
mode: Mode,
217218
target: Interned<String>,
218219
command: &'static str,
219220
path: &'static str,
220221
) -> Command {
221-
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, target, command);
222+
let mut cargo = builder.cargo(compiler, mode, target, command);
222223
let dir = builder.src.join(path);
223224
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
224225

@@ -261,6 +262,15 @@ macro_rules! tool {
261262
)+
262263
}
263264

265+
impl Tool {
266+
pub fn get_mode(&self) -> Mode {
267+
let mode = match self {
268+
$(Tool::$name => $mode,)+
269+
};
270+
mode
271+
}
272+
}
273+
264274
impl<'a> Builder<'a> {
265275
pub fn tool_exe(&self, tool: Tool) -> PathBuf {
266276
let stage = self.tool_default_stage(tool);
@@ -414,6 +424,7 @@ impl Step for Rustdoc {
414424

415425
let mut cargo = prepare_tool_cargo(builder,
416426
build_compiler,
427+
Mode::ToolRustc,
417428
target,
418429
"build",
419430
"src/tools/rustdoc");
@@ -575,19 +586,19 @@ impl<'a> Builder<'a> {
575586
pub fn tool_cmd(&self, tool: Tool) -> Command {
576587
let mut cmd = Command::new(self.tool_exe(tool));
577588
let compiler = self.compiler(self.tool_default_stage(tool), self.config.build);
578-
self.prepare_tool_cmd(compiler, &mut cmd);
589+
self.prepare_tool_cmd(compiler, tool.get_mode(), &mut cmd);
579590
cmd
580591
}
581592

582593
/// Prepares the `cmd` provided to be able to run the `compiler` provided.
583594
///
584595
/// Notably this munges the dynamic library lookup path to point to the
585596
/// right location to run `compiler`.
586-
fn prepare_tool_cmd(&self, compiler: Compiler, cmd: &mut Command) {
597+
fn prepare_tool_cmd(&self, compiler: Compiler, mode: Mode, cmd: &mut Command) {
587598
let host = &compiler.host;
588599
let mut lib_paths: Vec<PathBuf> = vec![
589600
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)),
590-
self.cargo_out(compiler, Mode::ToolRustc, *host).join("deps"),
601+
self.cargo_out(compiler, mode, *host).join("deps"),
591602
];
592603

593604
// On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make

0 commit comments

Comments
 (0)