Skip to content

Commit 7b863bb

Browse files
committed
Split out Step::is_really_default from Step::should_run
1 parent 54f4176 commit 7b863bb

File tree

8 files changed

+292
-165
lines changed

8 files changed

+292
-165
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 72 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ impl Step for Docs {
6666
const DEFAULT: bool = true;
6767

6868
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
69-
let default = run.builder.config.docs;
70-
run.alias("rust-docs").default_condition(default)
69+
run.alias("rust-docs")
70+
}
71+
72+
fn is_really_default(builder: &Builder<'_>) -> bool {
73+
builder.config.docs
7174
}
7275

7376
fn make_run(run: RunConfig<'_>) {
@@ -110,8 +113,11 @@ impl Step for JsonDocs {
110113
const DEFAULT: bool = true;
111114

112115
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
113-
let default = run.builder.config.docs;
114-
run.alias("rust-docs-json").default_condition(default)
116+
run.alias("rust-docs-json")
117+
}
118+
119+
fn is_really_default(builder: &Builder<'_>) -> bool {
120+
builder.config.docs
115121
}
116122

117123
fn make_run(run: RunConfig<'_>) {
@@ -161,8 +167,11 @@ impl Step for RustcDocs {
161167
const IS_HOST: bool = true;
162168

163169
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
164-
let builder = run.builder;
165-
run.alias("rustc-docs").default_condition(builder.config.compiler_docs)
170+
run.alias("rustc-docs")
171+
}
172+
173+
fn is_really_default(builder: &Builder<'_>) -> bool {
174+
builder.config.compiler_docs
166175
}
167176

168177
fn make_run(run: RunConfig<'_>) {
@@ -931,8 +940,11 @@ impl Step for Analysis {
931940
const DEFAULT: bool = true;
932941

933942
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
934-
let default = should_build_extended_tool(run.builder, "analysis");
935-
run.alias("rust-analysis").default_condition(default)
943+
run.alias("rust-analysis")
944+
}
945+
946+
fn is_really_default(builder: &Builder<'_>) -> bool {
947+
should_build_extended_tool(builder, "analysis")
936948
}
937949

938950
fn make_run(run: RunConfig<'_>) {
@@ -1165,8 +1177,11 @@ impl Step for PlainSourceTarball {
11651177
const IS_HOST: bool = true;
11661178

11671179
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1168-
let builder = run.builder;
1169-
run.alias("rustc-src").default_condition(builder.config.rust_dist_src)
1180+
run.alias("rustc-src")
1181+
}
1182+
1183+
fn is_really_default(builder: &Builder<'_>) -> bool {
1184+
builder.config.rust_dist_src
11701185
}
11711186

11721187
fn make_run(run: RunConfig<'_>) {
@@ -1313,8 +1328,11 @@ impl Step for Cargo {
13131328
const IS_HOST: bool = true;
13141329

13151330
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1316-
let default = should_build_extended_tool(run.builder, "cargo");
1317-
run.alias("cargo").default_condition(default)
1331+
run.alias("cargo")
1332+
}
1333+
1334+
fn is_really_default(builder: &Builder<'_>) -> bool {
1335+
should_build_extended_tool(builder, "cargo")
13181336
}
13191337

13201338
fn make_run(run: RunConfig<'_>) {
@@ -1371,8 +1389,11 @@ impl Step for RustAnalyzer {
13711389
const IS_HOST: bool = true;
13721390

13731391
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1374-
let default = should_build_extended_tool(run.builder, "rust-analyzer");
1375-
run.alias("rust-analyzer").default_condition(default)
1392+
run.alias("rust-analyzer")
1393+
}
1394+
1395+
fn is_really_default(builder: &Builder<'_>) -> bool {
1396+
should_build_extended_tool(builder, "rust-analyzer")
13761397
}
13771398

13781399
fn make_run(run: RunConfig<'_>) {
@@ -1414,8 +1435,11 @@ impl Step for Clippy {
14141435
const IS_HOST: bool = true;
14151436

14161437
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1417-
let default = should_build_extended_tool(run.builder, "clippy");
1418-
run.alias("clippy").default_condition(default)
1438+
run.alias("clippy")
1439+
}
1440+
1441+
fn is_really_default(builder: &Builder<'_>) -> bool {
1442+
should_build_extended_tool(builder, "clippy")
14191443
}
14201444

14211445
fn make_run(run: RunConfig<'_>) {
@@ -1460,8 +1484,11 @@ impl Step for Miri {
14601484
const IS_HOST: bool = true;
14611485

14621486
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1463-
let default = should_build_extended_tool(run.builder, "miri");
1464-
run.alias("miri").default_condition(default)
1487+
run.alias("miri")
1488+
}
1489+
1490+
fn is_really_default(builder: &Builder<'_>) -> bool {
1491+
should_build_extended_tool(builder, "miri")
14651492
}
14661493

14671494
fn make_run(run: RunConfig<'_>) {
@@ -1508,16 +1535,18 @@ impl Step for CraneliftCodegenBackend {
15081535
const IS_HOST: bool = true;
15091536

15101537
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1538+
run.alias("rustc_codegen_cranelift")
1539+
}
1540+
1541+
fn is_really_default(builder: &Builder<'_>) -> bool {
15111542
// We only want to build the cranelift backend in `x dist` if the backend was enabled
15121543
// in rust.codegen-backends.
15131544
// Sadly, we don't have access to the actual target for which we're disting clif here..
15141545
// So we just use the host target.
1515-
let clif_enabled_by_default = run
1516-
.builder
1546+
builder
15171547
.config
1518-
.enabled_codegen_backends(run.builder.host_target)
1519-
.contains(&CodegenBackendKind::Cranelift);
1520-
run.alias("rustc_codegen_cranelift").default_condition(clif_enabled_by_default)
1548+
.enabled_codegen_backends(builder.host_target)
1549+
.contains(&CodegenBackendKind::Cranelift)
15211550
}
15221551

15231552
fn make_run(run: RunConfig<'_>) {
@@ -1594,8 +1623,11 @@ impl Step for Rustfmt {
15941623
const IS_HOST: bool = true;
15951624

15961625
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1597-
let default = should_build_extended_tool(run.builder, "rustfmt");
1598-
run.alias("rustfmt").default_condition(default)
1626+
run.alias("rustfmt")
1627+
}
1628+
1629+
fn is_really_default(builder: &Builder<'_>) -> bool {
1630+
should_build_extended_tool(builder, "rustfmt")
15991631
}
16001632

16011633
fn make_run(run: RunConfig<'_>) {
@@ -1636,8 +1668,11 @@ impl Step for Extended {
16361668
const IS_HOST: bool = true;
16371669

16381670
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1639-
let builder = run.builder;
1640-
run.alias("extended").default_condition(builder.config.extended)
1671+
run.alias("extended")
1672+
}
1673+
1674+
fn is_really_default(builder: &Builder<'_>) -> bool {
1675+
builder.config.extended
16411676
}
16421677

16431678
fn make_run(run: RunConfig<'_>) {
@@ -2382,14 +2417,16 @@ impl Step for LlvmTools {
23822417
const DEFAULT: bool = true;
23832418

23842419
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2385-
let default = should_build_extended_tool(run.builder, "llvm-tools");
2386-
23872420
let mut run = run.alias("llvm-tools");
23882421
for tool in LLVM_TOOLS {
23892422
run = run.alias(tool);
23902423
}
23912424

2392-
run.default_condition(default)
2425+
run
2426+
}
2427+
2428+
fn is_really_default(builder: &Builder<'_>) -> bool {
2429+
should_build_extended_tool(builder, "llvm-tools")
23932430
}
23942431

23952432
fn make_run(run: RunConfig<'_>) {
@@ -2486,8 +2523,11 @@ impl Step for LlvmBitcodeLinker {
24862523
const IS_HOST: bool = true;
24872524

24882525
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2489-
let default = should_build_extended_tool(run.builder, "llvm-bitcode-linker");
2490-
run.alias("llvm-bitcode-linker").default_condition(default)
2526+
run.alias("llvm-bitcode-linker")
2527+
}
2528+
2529+
fn is_really_default(builder: &Builder<'_>) -> bool {
2530+
should_build_extended_tool(builder, "llvm-bitcode-linker")
24912531
}
24922532

24932533
fn make_run(run: RunConfig<'_>) {

src/bootstrap/src/core/build_steps/doc.rs

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ macro_rules! book {
3535
const DEFAULT: bool = true;
3636

3737
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
38-
let builder = run.builder;
39-
run.path($path).default_condition(builder.config.docs)
38+
run.path($path)
39+
}
40+
41+
fn is_really_default(builder: &Builder<'_>) -> bool {
42+
builder.config.docs
4043
}
4144

4245
fn make_run(run: RunConfig<'_>) {
@@ -88,8 +91,11 @@ impl Step for UnstableBook {
8891
const DEFAULT: bool = true;
8992

9093
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
91-
let builder = run.builder;
92-
run.path("src/doc/unstable-book").default_condition(builder.config.docs)
94+
run.path("src/doc/unstable-book")
95+
}
96+
97+
fn is_really_default(builder: &Builder<'_>) -> bool {
98+
builder.config.docs
9399
}
94100

95101
fn make_run(run: RunConfig<'_>) {
@@ -216,8 +222,11 @@ impl Step for TheBook {
216222
const DEFAULT: bool = true;
217223

218224
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
219-
let builder = run.builder;
220-
run.path("src/doc/book").default_condition(builder.config.docs)
225+
run.path("src/doc/book")
226+
}
227+
228+
fn is_really_default(builder: &Builder<'_>) -> bool {
229+
builder.config.docs
221230
}
222231

223232
fn make_run(run: RunConfig<'_>) {
@@ -340,8 +349,11 @@ impl Step for Standalone {
340349
const DEFAULT: bool = true;
341350

342351
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
343-
let builder = run.builder;
344-
run.path("src/doc").alias("standalone").default_condition(builder.config.docs)
352+
run.path("src/doc").alias("standalone")
353+
}
354+
355+
fn is_really_default(builder: &Builder<'_>) -> bool {
356+
builder.config.docs
345357
}
346358

347359
fn make_run(run: RunConfig<'_>) {
@@ -450,8 +462,11 @@ impl Step for Releases {
450462
const DEFAULT: bool = true;
451463

452464
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
453-
let builder = run.builder;
454-
run.path("RELEASES.md").alias("releases").default_condition(builder.config.docs)
465+
run.path("RELEASES.md").alias("releases")
466+
}
467+
468+
fn is_really_default(builder: &Builder<'_>) -> bool {
469+
builder.config.docs
455470
}
456471

457472
fn make_run(run: RunConfig<'_>) {
@@ -634,8 +649,11 @@ impl Step for Std {
634649
const DEFAULT: bool = true;
635650

636651
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
637-
let builder = run.builder;
638-
run.crate_or_deps("sysroot").path("library").default_condition(builder.config.docs)
652+
run.crate_or_deps("sysroot").path("library")
653+
}
654+
655+
fn is_really_default(builder: &Builder<'_>) -> bool {
656+
builder.config.docs
639657
}
640658

641659
fn make_run(run: RunConfig<'_>) {
@@ -862,10 +880,11 @@ impl Step for Rustc {
862880
const IS_HOST: bool = true;
863881

864882
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
865-
let builder = run.builder;
866-
run.crate_or_deps("rustc-main")
867-
.path("compiler")
868-
.default_condition(builder.config.compiler_docs)
883+
run.crate_or_deps("rustc-main").path("compiler")
884+
}
885+
886+
fn is_really_default(builder: &Builder<'_>) -> bool {
887+
builder.config.compiler_docs
869888
}
870889

871890
fn make_run(run: RunConfig<'_>) {
@@ -1009,8 +1028,11 @@ macro_rules! tool_doc {
10091028
const IS_HOST: bool = true;
10101029

10111030
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1012-
let builder = run.builder;
1013-
run.path($path).default_condition(builder.config.compiler_docs)
1031+
run.path($path)
1032+
}
1033+
1034+
fn is_really_default(builder: &Builder<'_>) -> bool {
1035+
builder.config.compiler_docs
10141036
}
10151037

10161038
fn make_run(run: RunConfig<'_>) {
@@ -1210,8 +1232,11 @@ impl Step for ErrorIndex {
12101232
const IS_HOST: bool = true;
12111233

12121234
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1213-
let builder = run.builder;
1214-
run.path("src/tools/error_index_generator").default_condition(builder.config.docs)
1235+
run.path("src/tools/error_index_generator")
1236+
}
1237+
1238+
fn is_really_default(builder: &Builder<'_>) -> bool {
1239+
builder.config.docs
12151240
}
12161241

12171242
fn make_run(run: RunConfig<'_>) {
@@ -1255,8 +1280,11 @@ impl Step for UnstableBookGen {
12551280
const IS_HOST: bool = true;
12561281

12571282
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1258-
let builder = run.builder;
1259-
run.path("src/tools/unstable-book-gen").default_condition(builder.config.docs)
1283+
run.path("src/tools/unstable-book-gen")
1284+
}
1285+
1286+
fn is_really_default(builder: &Builder<'_>) -> bool {
1287+
builder.config.docs
12601288
}
12611289

12621290
fn make_run(run: RunConfig<'_>) {
@@ -1322,8 +1350,11 @@ impl Step for RustcBook {
13221350
const IS_HOST: bool = true;
13231351

13241352
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1325-
let builder = run.builder;
1326-
run.path("src/doc/rustc").default_condition(builder.config.docs)
1353+
run.path("src/doc/rustc")
1354+
}
1355+
1356+
fn is_really_default(builder: &Builder<'_>) -> bool {
1357+
builder.config.docs
13271358
}
13281359

13291360
fn make_run(run: RunConfig<'_>) {
@@ -1418,8 +1449,11 @@ impl Step for Reference {
14181449
const DEFAULT: bool = true;
14191450

14201451
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1421-
let builder = run.builder;
1422-
run.path("src/doc/reference").default_condition(builder.config.docs)
1452+
run.path("src/doc/reference")
1453+
}
1454+
1455+
fn is_really_default(builder: &Builder<'_>) -> bool {
1456+
builder.config.docs
14231457
}
14241458

14251459
fn make_run(run: RunConfig<'_>) {

0 commit comments

Comments
 (0)