Skip to content

Commit 62f73dc

Browse files
committed
Refactor is_external_tool into source_type
1 parent a89f8e1 commit 62f73dc

File tree

4 files changed

+32
-22
lines changed

4 files changed

+32
-22
lines changed

src/bootstrap/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
1414
use builder::{RunConfig, Builder, ShouldRun, Step};
15-
use tool::{self, prepare_tool_cargo};
15+
use tool::{self, prepare_tool_cargo, SourceType};
1616
use {Compiler, Mode};
1717
use cache::{INTERNER, Interned};
1818
use std::path::PathBuf;
@@ -223,7 +223,7 @@ impl Step for Rustdoc {
223223
target,
224224
"check",
225225
"src/tools/rustdoc",
226-
false);
226+
SourceType::InTree);
227227

228228
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
229229
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);

src/bootstrap/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use build_helper::up_to_date;
2828

2929
use util::symlink_dir;
3030
use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
31-
use tool::{self, prepare_tool_cargo, Tool};
31+
use tool::{self, prepare_tool_cargo, Tool, SourceType};
3232
use compile;
3333
use cache::{INTERNER, Interned};
3434
use config::Config;
@@ -814,7 +814,7 @@ impl Step for Rustdoc {
814814
target,
815815
"doc",
816816
"src/tools/rustdoc",
817-
false
817+
SourceType::InTree,
818818
);
819819

820820
cargo.env("RUSTDOCFLAGS", "--document-private-items");

src/bootstrap/test.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use compile;
3030
use dist;
3131
use flags::Subcommand;
3232
use native;
33-
use tool::{self, Tool};
33+
use tool::{self, Tool, SourceType};
3434
use toolstate::ToolState;
3535
use util::{self, dylib_path, dylib_path_var};
3636
use Crate as CargoCrate;
@@ -228,7 +228,7 @@ impl Step for Cargo {
228228
self.host,
229229
"test",
230230
"src/tools/cargo",
231-
true);
231+
SourceType::Submodule);
232232

233233
if !builder.fail_fast {
234234
cargo.arg("--no-fail-fast");
@@ -288,7 +288,7 @@ impl Step for Rls {
288288
host,
289289
"test",
290290
"src/tools/rls",
291-
true);
291+
SourceType::Submodule);
292292

293293
builder.add_rustc_lib_path(compiler, &mut cargo);
294294

@@ -341,7 +341,7 @@ impl Step for Rustfmt {
341341
host,
342342
"test",
343343
"src/tools/rustfmt",
344-
true);
344+
SourceType::Submodule);
345345

346346
let dir = testdir(builder, compiler.host);
347347
t!(fs::create_dir_all(&dir));
@@ -396,7 +396,7 @@ impl Step for Miri {
396396
host,
397397
"test",
398398
"src/tools/miri",
399-
true);
399+
SourceType::Submodule);
400400

401401
// miri tests need to know about the stage sysroot
402402
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
@@ -455,7 +455,7 @@ impl Step for Clippy {
455455
host,
456456
"test",
457457
"src/tools/clippy",
458-
true);
458+
SourceType::Submodule);
459459

460460
// clippy tests need to know about the stage sysroot
461461
cargo.env("SYSROOT", builder.sysroot(compiler));
@@ -1740,7 +1740,7 @@ impl Step for CrateRustdoc {
17401740
target,
17411741
test_kind.subcommand(),
17421742
"src/tools/rustdoc",
1743-
false);
1743+
SourceType::InTree);
17441744
if test_kind.subcommand() == "test" && !builder.fail_fast {
17451745
cargo.arg("--no-fail-fast");
17461746
}

src/bootstrap/tool.rs

+21-11
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ impl Step for CleanTools {
7575
}
7676
}
7777

78+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
79+
pub enum SourceType {
80+
InTree,
81+
Submodule,
82+
}
83+
7884
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
7985
struct ToolBuild {
8086
compiler: Compiler,
@@ -83,7 +89,7 @@ struct ToolBuild {
8389
path: &'static str,
8490
mode: Mode,
8591
is_optional_tool: bool,
86-
is_external_tool: bool,
92+
source_type: SourceType,
8793
extra_features: Vec<String>,
8894
}
8995

@@ -123,7 +129,7 @@ impl Step for ToolBuild {
123129
target,
124130
"build",
125131
path,
126-
self.is_external_tool,
132+
self.source_type,
127133
);
128134
cargo.arg("--features").arg(self.extra_features.join(" "));
129135

@@ -247,7 +253,7 @@ pub fn prepare_tool_cargo(
247253
target: Interned<String>,
248254
command: &'static str,
249255
path: &'static str,
250-
is_external_tool: bool,
256+
source_type: SourceType,
251257
) -> Command {
252258
let mut cargo = builder.cargo(compiler, mode, target, command);
253259
let dir = builder.src.join(path);
@@ -257,7 +263,7 @@ pub fn prepare_tool_cargo(
257263
// stages and such and it's just easier if they're not dynamically linked.
258264
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
259265

260-
if is_external_tool {
266+
if source_type == SourceType::Submodule {
261267
cargo.env("RUSTC_EXTERNAL_TOOL", "1");
262268
}
263269

@@ -289,7 +295,7 @@ pub fn prepare_tool_cargo(
289295

290296
macro_rules! tool {
291297
($($name:ident, $path:expr, $tool_name:expr, $mode:expr
292-
$(,llvm_tools = $llvm:expr)* $(,external_tool = $external:expr)*;)+) => {
298+
$(,llvm_tools = $llvm:expr)* $(,is_external_tool = $external:expr)*;)+) => {
293299
#[derive(Copy, PartialEq, Eq, Clone)]
294300
pub enum Tool {
295301
$(
@@ -367,7 +373,11 @@ macro_rules! tool {
367373
mode: $mode,
368374
path: $path,
369375
is_optional_tool: false,
370-
is_external_tool: false $(|| $external)*,
376+
source_type: if false $(|| $external)* {
377+
SourceType::Submodule
378+
} else {
379+
SourceType::InTree
380+
},
371381
extra_features: Vec::new(),
372382
}).expect("expected to build -- essential tool")
373383
}
@@ -387,7 +397,7 @@ tool!(
387397
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
388398
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
389399
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
390-
external_tool = true;
400+
is_external_tool = true;
391401
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
392402
);
393403

@@ -419,7 +429,7 @@ impl Step for RemoteTestServer {
419429
mode: Mode::ToolStd,
420430
path: "src/tools/remote-test-server",
421431
is_optional_tool: false,
422-
is_external_tool: false,
432+
source_type: SourceType::InTree,
423433
extra_features: Vec::new(),
424434
}).expect("expected to build -- essential tool")
425435
}
@@ -474,7 +484,7 @@ impl Step for Rustdoc {
474484
target,
475485
"build",
476486
"src/tools/rustdoc",
477-
false,
487+
SourceType::InTree,
478488
);
479489

480490
// Most tools don't get debuginfo, but rustdoc should.
@@ -547,7 +557,7 @@ impl Step for Cargo {
547557
mode: Mode::ToolRustc,
548558
path: "src/tools/cargo",
549559
is_optional_tool: false,
550-
is_external_tool: true,
560+
source_type: SourceType::Submodule,
551561
extra_features: Vec::new(),
552562
}).expect("expected to build -- essential tool")
553563
}
@@ -597,7 +607,7 @@ macro_rules! tool_extended {
597607
path: $path,
598608
extra_features: $sel.extra_features,
599609
is_optional_tool: true,
600-
is_external_tool: true,
610+
source_type: SourceType::Submodule,
601611
})
602612
}
603613
}

0 commit comments

Comments
 (0)