Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6b3413d

Browse files
committedJul 20, 2017
Change code to work with the new system
1 parent 001e9f3 commit 6b3413d

File tree

7 files changed

+1394
-246
lines changed

7 files changed

+1394
-246
lines changed
 

‎src/bootstrap/check.rs

Lines changed: 342 additions & 47 deletions
Large diffs are not rendered by default.

‎src/bootstrap/compile.rs

Lines changed: 197 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ fn crate_rule<'a, 'b>(build: &'a Build,
129129
rule
130130
}
131131

132+
// rules.build("libstd", "src/libstd")
133+
// .dep(|s| s.name("rustc").target(s.host))
134+
// .dep(|s| s.name("libstd-link"));
132135
// for (krate, path, _default) in krates("std") {
133136
// rules.build(&krate.build_step, path)
134137
// .dep(|s| s.name("startup-objects"))
@@ -143,6 +146,21 @@ pub struct Std<'a> {
143146

144147
impl<'a> Step<'a> for Std<'a> {
145148
type Output = ();
149+
const DEFAULT: bool = true;
150+
151+
fn should_run(builder: &Builder, path: &Path) -> bool {
152+
path.ends_with("src/libstd") ||
153+
builder.crates("std").into_iter().any(|(_, krate_path)| {
154+
path.ends_with(krate_path)
155+
})
156+
}
157+
158+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, target: &str) {
159+
builder.ensure(Std {
160+
compiler: builder.compiler(builder.top_stage, host),
161+
target,
162+
})
163+
}
146164

147165
/// Build the standard library.
148166
///
@@ -153,16 +171,31 @@ impl<'a> Step<'a> for Std<'a> {
153171
let build = builder.build;
154172
let target = self.target;
155173
let compiler = self.compiler;
156-
let libdir = build.sysroot_libdir(compiler, target);
157-
t!(fs::create_dir_all(&libdir));
174+
175+
builder.ensure(StartupObjects { compiler, target });
176+
177+
if build.force_use_stage1(compiler, target) {
178+
let from = builder.compiler(1, &build.build);
179+
builder.ensure(Std {
180+
compiler: from,
181+
target: target,
182+
});
183+
println!("Uplifting stage1 std ({} -> {})", from.host, target);
184+
builder.ensure(StdLink {
185+
compiler: from,
186+
target_compiler: compiler,
187+
target: target,
188+
});
189+
return;
190+
}
158191

159192
let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
160193
println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
161194
compiler.host, target);
162195

163196
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
164197
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
165-
let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
198+
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build");
166199
let mut features = build.std_features();
167200

168201
if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") {
@@ -188,6 +221,7 @@ impl<'a> Step<'a> for Std<'a> {
188221
// config.toml equivalent) is used
189222
cargo.env("LLVM_CONFIG", build.llvm_config(target));
190223
}
224+
191225
cargo.arg("--features").arg(features)
192226
.arg("--manifest-path")
193227
.arg(build.src.join("src/libstd/Cargo.toml"));
@@ -206,6 +240,12 @@ impl<'a> Step<'a> for Std<'a> {
206240
run_cargo(build,
207241
&mut cargo,
208242
&libstd_stamp(build, &compiler, target));
243+
244+
builder.ensure(StdLink {
245+
compiler: builder.compiler(compiler.stage, &build.build),
246+
target_compiler: compiler,
247+
target: target,
248+
});
209249
}
210250
}
211251

@@ -219,7 +259,7 @@ impl<'a> Step<'a> for Std<'a> {
219259
// .dep(|s| s.name("create-sysroot").target(s.host));
220260

221261
#[derive(Serialize)]
222-
pub struct StdLink<'a> {
262+
struct StdLink<'a> {
223263
pub compiler: Compiler<'a>,
224264
pub target_compiler: Compiler<'a>,
225265
pub target: &'a str,
@@ -297,6 +337,17 @@ pub struct StartupObjects<'a> {
297337
impl<'a> Step<'a> for StartupObjects<'a> {
298338
type Output = ();
299339

340+
fn should_run(_builder: &Builder, path: &Path) -> bool {
341+
path.ends_with("src/rtstartup")
342+
}
343+
344+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, target: &str) {
345+
builder.ensure(StartupObjects {
346+
compiler: builder.compiler(builder.top_stage, host),
347+
target,
348+
})
349+
}
350+
300351
/// Build and prepare startup objects like rsbegin.o and rsend.o
301352
///
302353
/// These are primarily used on Windows right now for linking executables/dlls.
@@ -354,6 +405,21 @@ pub struct Test<'a> {
354405

355406
impl<'a> Step<'a> for Test<'a> {
356407
type Output = ();
408+
const DEFAULT: bool = true;
409+
410+
fn should_run(builder: &Builder, path: &Path) -> bool {
411+
path.ends_with("src/libtest") ||
412+
builder.crates("test").into_iter().any(|(_, krate_path)| {
413+
path.ends_with(krate_path)
414+
})
415+
}
416+
417+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, target: &str) {
418+
builder.ensure(Test {
419+
compiler: builder.compiler(builder.top_stage, host),
420+
target,
421+
})
422+
}
357423

358424
/// Build libtest.
359425
///
@@ -364,6 +430,23 @@ impl<'a> Step<'a> for Test<'a> {
364430
let build = builder.build;
365431
let target = self.target;
366432
let compiler = self.compiler;
433+
434+
builder.ensure(Std { compiler, target });
435+
436+
if build.force_use_stage1(compiler, target) {
437+
builder.ensure(Test {
438+
compiler: builder.compiler(1, &build.build),
439+
target: target,
440+
});
441+
println!("Uplifting stage1 test ({} -> {})", &build.build, target);
442+
builder.ensure(TestLink {
443+
compiler: builder.compiler(1, &build.build),
444+
target_compiler: compiler,
445+
target: target,
446+
});
447+
return;
448+
}
449+
367450
let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
368451
println!("Building stage{} test artifacts ({} -> {})", compiler.stage,
369452
compiler.host, target);
@@ -378,6 +461,12 @@ impl<'a> Step<'a> for Test<'a> {
378461
run_cargo(build,
379462
&mut cargo,
380463
&libtest_stamp(build, compiler, target));
464+
465+
builder.ensure(TestLink {
466+
compiler: builder.compiler(1, &build.build),
467+
target_compiler: compiler,
468+
target: target,
469+
});
381470
}
382471
}
383472

@@ -432,6 +521,22 @@ pub struct Rustc<'a> {
432521

433522
impl<'a> Step<'a> for Rustc<'a> {
434523
type Output = ();
524+
const ONLY_HOSTS: bool = true;
525+
const DEFAULT: bool = true;
526+
527+
fn should_run(builder: &Builder, path: &Path) -> bool {
528+
path.ends_with("src/librustc") ||
529+
builder.crates("rustc-main").into_iter().any(|(_, krate_path)| {
530+
path.ends_with(krate_path)
531+
})
532+
}
533+
534+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, target: &str) {
535+
builder.ensure(Rustc {
536+
compiler: builder.compiler(builder.top_stage, host),
537+
target,
538+
})
539+
}
435540

436541
/// Build the compiler.
437542
///
@@ -442,6 +547,33 @@ impl<'a> Step<'a> for Rustc<'a> {
442547
let build = builder.build;
443548
let compiler = self.compiler;
444549
let target = self.target;
550+
551+
builder.ensure(Test { compiler, target });
552+
553+
// Build LLVM for our target. This will implicitly build the host LLVM
554+
// if necessary.
555+
builder.ensure(native::Llvm { target });
556+
557+
if build.force_use_stage1(compiler, target) {
558+
builder.ensure(Rustc {
559+
compiler: builder.compiler(1, &build.build),
560+
target: target,
561+
});
562+
println!("Uplifting stage1 rustc ({} -> {})", &build.build, target);
563+
builder.ensure(RustcLink {
564+
compiler: builder.compiler(1, &build.build),
565+
target_compiler: compiler,
566+
target,
567+
});
568+
return;
569+
}
570+
571+
// Ensure that build scripts have a std to link against.
572+
builder.ensure(Std {
573+
compiler: builder.compiler(self.compiler.stage, &build.build),
574+
target: &build.build,
575+
});
576+
445577
let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
446578
println!("Building stage{} compiler artifacts ({} -> {})",
447579
compiler.stage, compiler.host, target);
@@ -513,6 +645,12 @@ impl<'a> Step<'a> for Rustc<'a> {
513645
run_cargo(build,
514646
&mut cargo,
515647
&librustc_stamp(build, compiler, target));
648+
649+
builder.ensure(RustcLink {
650+
compiler: builder.compiler(compiler.stage, &build.build),
651+
target_compiler: compiler,
652+
target,
653+
});
516654
}
517655
}
518656

@@ -523,7 +661,7 @@ impl<'a> Step<'a> for Rustc<'a> {
523661
// compile::rustc_link)
524662
// .dep(|s| s.name("libtest-link"));
525663
#[derive(Serialize)]
526-
pub struct RustcLink<'a> {
664+
struct RustcLink<'a> {
527665
pub compiler: Compiler<'a>,
528666
pub target_compiler: Compiler<'a>,
529667
pub target: &'a str,
@@ -551,19 +689,19 @@ impl<'a> Step<'a> for RustcLink<'a> {
551689

552690
/// Cargo's output path for the standard library in a given stage, compiled
553691
/// by a particular compiler for the specified target.
554-
fn libstd_stamp(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
692+
pub fn libstd_stamp(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
555693
build.cargo_out(compiler, Mode::Libstd, target).join(".libstd.stamp")
556694
}
557695

558696
/// Cargo's output path for libtest in a given stage, compiled by a particular
559697
/// compiler for the specified target.
560-
fn libtest_stamp(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
698+
pub fn libtest_stamp(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
561699
build.cargo_out(compiler, Mode::Libtest, target).join(".libtest.stamp")
562700
}
563701

564702
/// Cargo's output path for librustc in a given stage, compiled by a particular
565703
/// compiler for the specified target.
566-
fn librustc_stamp(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
704+
pub fn librustc_stamp(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
567705
build.cargo_out(compiler, Mode::Librustc, target).join(".librustc.stamp")
568706
}
569707

@@ -582,20 +720,25 @@ pub struct Sysroot<'a> {
582720
}
583721

584722
impl<'a> Step<'a> for Sysroot<'a> {
585-
type Output = ();
723+
type Output = PathBuf;
586724

587725
/// Returns the sysroot for the `compiler` specified that *this build system
588726
/// generates*.
589727
///
590728
/// That is, the sysroot for the stage0 compiler is not what the compiler
591729
/// thinks it is by default, but it's the same as the default for stages
592730
/// 1-3.
593-
fn run(self, builder: &Builder) {
731+
fn run(self, builder: &Builder) -> PathBuf {
594732
let build = builder.build;
595733
let compiler = self.compiler;
596-
let sysroot = build.sysroot(compiler);
734+
let sysroot = if compiler.stage == 0 {
735+
build.out.join(compiler.host).join("stage0-sysroot")
736+
} else {
737+
build.out.join(compiler.host).join(format!("stage{}", compiler.stage))
738+
};
597739
let _ = fs::remove_dir_all(&sysroot);
598740
t!(fs::create_dir_all(&sysroot));
741+
sysroot
599742
}
600743
}
601744

@@ -615,8 +758,11 @@ impl<'a> Step<'a> for Sysroot<'a> {
615758

616759
#[derive(Serialize)]
617760
pub struct Assemble<'a> {
618-
pub stage: u32,
619-
pub host: &'a str,
761+
/// The compiler which we will produce in this step. Assemble itself will
762+
/// take care of ensuring that the necessary prerequisites to do so exist,
763+
/// that is, this target can be a stage2 compiler and Assemble will build
764+
/// previous stages for you.
765+
pub target_compiler: Compiler<'a>,
620766
}
621767

622768
impl<'a> Step<'a> for Assemble<'a> {
@@ -629,20 +775,48 @@ impl<'a> Step<'a> for Assemble<'a> {
629775
/// compiler.
630776
fn run(self, builder: &Builder) {
631777
let build = builder.build;
632-
let stage = self.stage;
633-
let host = self.host;
634-
// nothing to do in stage0
635-
if stage == 0 {
636-
return
778+
let target_compiler = self.target_compiler;
779+
780+
if target_compiler.stage == 0 {
781+
assert_eq!(build.build, target_compiler.host,
782+
"Cannot obtain compiler for non-native build triple at stage 0");
783+
// The stage 0 compiler for the build triple is always pre-built.
784+
return target_compiler;
637785
}
638786

639-
println!("Copying stage{} compiler ({})", stage, host);
787+
// Get the compiler that we'll use to bootstrap ourselves.
788+
let build_compiler = if target_compiler.host != build.build {
789+
// Build a compiler for the host platform. We cannot use the stage0
790+
// compiler for the host platform for this because it doesn't have
791+
// the libraries we need. FIXME: Perhaps we should download those
792+
// libraries? It would make builds faster...
793+
builder.ensure(Assemble {
794+
target_compiler: Compiler {
795+
// FIXME: It may be faster if we build just a stage 1
796+
// compiler and then use that to bootstrap this compiler
797+
// forward.
798+
stage: target_compiler.stage - 1,
799+
host: &build.build
800+
},
801+
})
802+
} else {
803+
// Build the compiler we'll use to build the stage requested. This
804+
// may build more than one compiler (going down to stage 0).
805+
builder.ensure(Assemble {
806+
target_compiler: target_compiler.with_stage(target_compiler.stage - 1),
807+
})
808+
};
640809

641-
// The compiler that we're assembling
642-
let target_compiler = Compiler::new(stage, host);
810+
// Build the libraries for this compiler to link to (i.e., the libraries
811+
// it uses at runtime). NOTE: Crates the target compiler compiles don't
812+
// link to these. (FIXME: Is that correct? It seems to be correct most
813+
// of the time but I think we do link to these for stage2/bin compilers
814+
// when not performing a full bootstrap).
815+
builder.ensure(Rustc { compiler: build_compiler, target: target_compiler.host });
643816

644-
// The compiler that compiled the compiler we're assembling
645-
let build_compiler = Compiler::new(stage - 1, &build.build);
817+
let stage = target_compiler.stage;
818+
let host = target_compiler.host;
819+
println!("Assembling stage{} compiler ({})", stage, host);
646820

647821
// Link in all dylibs to the libdir
648822
let sysroot = build.sysroot(&target_compiler);

‎src/bootstrap/dist.rs

Lines changed: 185 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ pub struct Docs<'a> {
7676

7777
impl<'a> Step<'a> for Docs<'a> {
7878
type Output = ();
79+
const DEFAULT: bool = true;
80+
const ONLY_BUILD_TARGETS: bool = true;
81+
82+
fn should_run(_builder: &Builder, path: &Path) -> bool {
83+
path.ends_with("src/doc")
84+
}
85+
86+
fn make_run(builder: &Builder, _path: Option<&Path>, _host: &str, target: &str) {
87+
builder.ensure(Docs {
88+
stage: builder.top_stage,
89+
host: target,
90+
});
91+
}
7992

8093
/// Builds the `rust-docs` installer component.
8194
///
@@ -85,6 +98,8 @@ impl<'a> Step<'a> for Docs<'a> {
8598
let stage = self.stage;
8699
let host = self.host;
87100

101+
builder.default_doc(None);
102+
88103
println!("Dist docs stage{} ({})", stage, host);
89104
if !build.config.docs {
90105
println!("\tskipping - docs disabled");
@@ -268,6 +283,18 @@ pub struct Mingw<'a> {
268283

269284
impl<'a> Step<'a> for Mingw<'a> {
270285
type Output = ();
286+
const DEFAULT: bool = true;
287+
const ONLY_BUILD_TARGETS: bool = true;
288+
289+
fn should_run(_builder: &Builder, _path: &Path) -> bool {
290+
false
291+
}
292+
293+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, _target: &str) {
294+
builder.ensure(Mingw {
295+
host: host,
296+
});
297+
}
271298

272299
/// Build the `rust-mingw` installer component.
273300
///
@@ -276,6 +303,11 @@ impl<'a> Step<'a> for Mingw<'a> {
276303
fn run(self, builder: &Builder) {
277304
let build = builder.build;
278305
let host = self.host;
306+
307+
if !host.contains("pc-windows-gnu") {
308+
return;
309+
}
310+
279311
println!("Dist mingw ({})", host);
280312
let name = pkgname(build, "rust-mingw");
281313
let image = tmpdir(build).join(format!("{}-{}-image", name, host));
@@ -320,6 +352,20 @@ pub struct Rustc<'a> {
320352

321353
impl<'a> Step<'a> for Rustc<'a> {
322354
type Output = ();
355+
const DEFAULT: bool = true;
356+
const ONLY_HOSTS: bool = true;
357+
const ONLY_BUILD_TARGETS: bool = true;
358+
359+
fn should_run(_builder: &Builder, path: &Path) -> bool {
360+
path.ends_with("src/librustc")
361+
}
362+
363+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, _target: &str) {
364+
builder.ensure(Rustc {
365+
stage: builder.top_stage,
366+
host: host,
367+
});
368+
}
323369

324370
/// Creates the `rustc` installer component.
325371
fn run(self, builder: &builder) {
@@ -334,7 +380,7 @@ impl<'a> Step<'a> for Rustc<'a> {
334380
let _ = fs::remove_dir_all(&overlay);
335381

336382
// Prepare the rustc "image", what will actually end up getting installed
337-
prepare_image(build, stage, host, &image);
383+
prepare_image(builder, stage, host, &image);
338384

339385
// Prepare the overlay which is part of the tarball but won't actually be
340386
// installed
@@ -384,8 +430,9 @@ impl<'a> Step<'a> for Rustc<'a> {
384430
t!(fs::remove_dir_all(&image));
385431
t!(fs::remove_dir_all(&overlay));
386432

387-
fn prepare_image(build: &Build, stage: u32, host: &str, image: &Path) {
388-
let src = build.sysroot(&Compiler::new(stage, host));
433+
fn prepare_image(builder: &Builder, stage: u32, host: &str, image: &Path) {
434+
let build = builder.build;
435+
let src = build.sysroot(builder.compiler(stage, host));
389436
let libdir = libdir(host);
390437

391438
// Copy rustc/rustdoc binaries
@@ -409,7 +456,10 @@ impl<'a> Step<'a> for Rustc<'a> {
409456
cp_r(&build.src.join("man"), &image.join("share/man/man1"));
410457

411458
// Debugger scripts
412-
debugger_scripts(build, &image, host);
459+
builder.ensure(DebuggerScripts {
460+
sysroot: &image,
461+
host: host,
462+
});
413463

414464
// Misc license info
415465
let cp = |file: &str| {
@@ -423,8 +473,6 @@ impl<'a> Step<'a> for Rustc<'a> {
423473
}
424474
}
425475

426-
427-
428476
//rules.test("debugger-scripts", "src/etc/lldb_batchmode.py")
429477
// .run(move |s| dist::debugger_scripts(build, &build.sysroot(&s.compiler()),
430478
// s.target));
@@ -438,6 +486,18 @@ pub struct DebuggerScripts<'a> {
438486
impl<'a> Step<'a> for DebuggerScripts<'a> {
439487
type Output = ();
440488

489+
fn should_run(_builder: &Builder, path: &Path) -> bool {
490+
path.ends_with("src/etc/lldb_batchmode.py")
491+
}
492+
493+
fn make_run(builder: &Builder, _path: Option<&Path>, host: &str, _target: &str) {
494+
builder.ensure(DebuggerScripts {
495+
// FIXME: builder.top_stage is likely wrong in some cases.
496+
sysroot: &builder.sysroot(builder.compiler(builder.top_stage, host)),
497+
host: host,
498+
});
499+
}
500+
441501
/// Copies debugger scripts for `host` into the `sysroot` specified.
442502
fn run(self, builder: &Builder) {
443503
let build = builder.build;
@@ -542,6 +602,22 @@ pub struct Analysis<'a> {
542602

543603
impl<'a> Step<'a> for Analysis<'a> {
544604
type Output = ();
605+
const DEFAULT: bool = true;
606+
const ONLY_BUILD_TARGETS: bool = true;
607+
608+
fn should_run(_builder: &Builder, path: &Path) -> bool {
609+
path.ends_with("analysis")
610+
}
611+
612+
fn make_run(builder: &Builder, path: Option<&Path>, host: &str, target: &str) {
613+
if path.is_none() && !builder.build.config.extended {
614+
return;
615+
}
616+
builder.ensure(Analysis {
617+
compiler: builder.compiler(builder.top_stage, host),
618+
target: target,
619+
});
620+
}
545621

546622
/// Creates a tarball of save-analysis metadata, if available.
547623
fn run(self, builder: &Builder) {
@@ -559,15 +635,16 @@ impl<'a> Step<'a> for Analysis<'a> {
559635
// Package save-analysis from stage1 if not doing a full bootstrap, as the
560636
// stage2 artifacts is simply copied from stage1 in that case.
561637
let compiler = if build.force_use_stage1(compiler, target) {
562-
Compiler::new(1, compiler.host)
638+
builder.compiler(1, compiler.host)
563639
} else {
564640
compiler.clone()
565641
};
566642

567643
let name = pkgname(build, "rust-analysis");
568644
let image = tmpdir(build).join(format!("{}-{}-image", name, target));
569645

570-
let src = build.stage_out(&compiler, Mode::Libstd).join(target).join("release").join("deps");
646+
let src = build.stage_out(compiler, Mode::Libstd)
647+
.join(target).join("release").join("deps");
571648

572649
let image_src = src.join("save-analysis");
573650
let dst = image.join("lib/rustlib").join(target).join("analysis");
@@ -644,6 +721,18 @@ pub struct Src;
644721

645722
impl<'a> Step<'a> for Src {
646723
type Output = ();
724+
const DEFAULT: bool = true;
725+
const ONLY_HOSTS: bool = true;
726+
const ONLY_BUILD_TARGETS: bool = true;
727+
const ONLY_BUILD: bool = true;
728+
729+
fn should_run(_builder: &Builder, path: &Path) -> bool {
730+
path.ends_with("src")
731+
}
732+
733+
fn make_run(builder: &Builder, _path: Option<&Path>, _host: &str, _target: &str) {
734+
builder.ensure(Src);
735+
}
647736

648737
/// Creates the `rust-src` installer component
649738
fn run(self, builder: &Builder) {
@@ -727,6 +816,22 @@ pub struct PlainSourceTarball;
727816

728817
impl<'a> Step<'a> for PlainSourceTarball {
729818
type Output = ();
819+
const DEFAULT: bool = true;
820+
const ONLY_HOSTS: bool = true;
821+
const ONLY_BUILD_TARGETS: bool = true;
822+
const ONLY_BUILD: bool = true;
823+
824+
fn should_run(_builder: &Builder, path: &Path) -> bool {
825+
path.ends_with("src")
826+
}
827+
828+
fn make_run(builder: &Builder, path: Option<&Path>, _host: &str, _target: &str) {
829+
if path.is_none() && !builder.build.config.rust_dist_src {
830+
return;
831+
}
832+
833+
builder.ensure(PlainSourceTarball);
834+
}
730835

731836
/// Creates the plain source tarball
732837
fn run(self, builder: &Builder) {
@@ -862,13 +967,29 @@ pub struct Cargo<'a> {
862967

863968
impl<'a> Step<'a> for Cargo<'a> {
864969
type Output = ();
970+
const ONLY_BUILD_TARGETS: bool = true;
971+
const ONLY_HOSTS: bool = true;
972+
973+
fn should_run(_builder: &Builder, path: &Path) -> bool {
974+
path.ends_with("cargo")
975+
}
976+
977+
fn make_run(builder: &Builder, _path: Option<&Path>, _host: &str, target: &str) {
978+
builder.ensure(Cargo {
979+
stage: builder.top_stage,
980+
target: target,
981+
});
982+
}
865983

866984
fn run(self, builder: &Builder) {
867985
let build = builder.build;
868986
let stage = self.stage;
869987
let target = self.target;
988+
989+
builder.ensure(tool::Cargo { stage, target });
990+
870991
println!("Dist cargo stage{} ({})", stage, target);
871-
let compiler = Compiler::new(stage, &build.build);
992+
let compiler = builder.compiler(stage, &build.build);
872993

873994
let src = build.src.join("src/tools/cargo");
874995
let etc = src.join("src/etc");
@@ -941,14 +1062,30 @@ pub struct Rls<'a> {
9411062

9421063
impl<'a> Step<'a> for Rls<'a> {
9431064
type Output = ();
1065+
const ONLY_BUILD_TARGETS: bool = true;
1066+
const ONLY_HOSTS: bool = true;
1067+
1068+
fn should_run(_builder: &Builder, path: &Path) -> bool {
1069+
path.ends_with("rls")
1070+
}
1071+
1072+
fn make_run(builder: &Builder, _path: Option<&Path>, _host: &str, target: &str) {
1073+
builder.ensure(Rls {
1074+
stage: builder.top_stage,
1075+
target: target,
1076+
});
1077+
}
9441078

9451079
fn run(self, builder: &Builder) {
9461080
let build = builder.build;
9471081
let stage = self.stage;
9481082
let target = self.target;
9491083
assert!(build.config.extended);
1084+
1085+
builder.ensure(tool::Rls { stage, target });
1086+
9501087
println!("Dist RLS stage{} ({})", stage, target);
951-
let compiler = Compiler::new(stage, &build.build);
1088+
let compiler = builder.compiler(stage, &build.build);
9521089

9531090
let src = build.src.join("src/tools/rls");
9541091
let release_num = build.release_num("rls");
@@ -1017,12 +1154,38 @@ pub struct Extended<'a> {
10171154

10181155
impl<'a> Step<'a> for Extended<'a> {
10191156
type Output = ();
1157+
const DEFAULT: bool = true;
1158+
const ONLY_BUILD_TARGETS: bool = true;
1159+
const ONLY_HOSTS: bool = true;
1160+
1161+
fn should_run(_builder: &Builder, path: &Path) -> bool {
1162+
path.ends_with("cargo")
1163+
}
1164+
1165+
fn make_run(builder: &Builder, path: Option<&Path>, host: &str, target: &str) {
1166+
if path.is_none() && !builder.build.config.extended {
1167+
return;
1168+
}
1169+
builder.ensure(Extended {
1170+
compiler: builder.compiler(builder.top_stage, host),
1171+
target: target,
1172+
});
1173+
}
10201174

10211175
/// Creates a combined installer for the specified target in the provided stage.
10221176
fn run(self, builder: &Builder) {
10231177
let build = builder.build;
10241178
let stage = self.stage;
10251179
let target = self.target;
1180+
let compiler = builder.compiler(stage, &build.build);
1181+
1182+
builder.ensure(Std { compiler, target });
1183+
builder.ensure(Rustc { stage, host });
1184+
builder.ensure(Mingw { host });
1185+
builder.ensure(Docs { stage, host });
1186+
builder.ensure(Cargo { stage, target });
1187+
builder.ensure(Rls { stage, target });
1188+
builder.ensure(Analysis { compiler, target });
10261189

10271190
println!("Dist extended stage{} ({})", stage, target);
10281191

@@ -1420,11 +1583,21 @@ pub struct HashSign;
14201583

14211584
impl<'a> Step<'a> for HashSign {
14221585
type Output = ();
1586+
const ONLY_BUILD_TARGETS: bool = true;
1587+
const ONLY_HOSTS: bool = true;
1588+
const ONLY_BUILD: bool = true;
1589+
1590+
fn should_run(_builder: &Builder, path: &Path) -> bool {
1591+
path.ends_with("hash-and-sign")
1592+
}
1593+
1594+
fn make_run(builder: &Builder, _path: Option<&Path>, _host: &str, _target: &str) {
1595+
builder.ensure(HashSign);
1596+
}
14231597

14241598
fn run(self, builder: &Builder) {
14251599
let build = builder.build;
1426-
let compiler = Compiler::new(0, &build.build);
1427-
let mut cmd = build.tool_cmd(&compiler, "build-manifest");
1600+
let mut cmd = builder.tool_cmd(Tool::BuildManifest);
14281601
let sign = build.config.dist_sign_folder.as_ref().unwrap_or_else(|| {
14291602
panic!("\n\nfailed to specify `dist.sign-folder` in `config.toml`\n\n")
14301603
});

‎src/bootstrap/doc.rs

Lines changed: 284 additions & 40 deletions
Large diffs are not rendered by default.

‎src/bootstrap/install.rs

Lines changed: 121 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -148,45 +148,124 @@ fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
148148
}
149149
ret
150150
}
151-
/*
152-
rules.install("install-docs", "src/doc")
153-
.default(build.config.docs)
154-
.only_host_build(true)
155-
.dep(|s| s.name("dist-docs"))
156-
.run(move |s| install::Installer::new(build).install_docs(s.stage, s.target));
157-
rules.install("install-std", "src/libstd")
158-
.default(true)
159-
.only_host_build(true)
160-
.dep(|s| s.name("dist-std"))
161-
.run(move |s| install::Installer::new(build).install_std(s.stage));
162-
rules.install("install-cargo", "cargo")
163-
.default(build.config.extended)
164-
.host(true)
165-
.only_host_build(true)
166-
.dep(|s| s.name("dist-cargo"))
167-
.run(move |s| install::Installer::new(build).install_cargo(s.stage, s.target));
168-
rules.install("install-rls", "rls")
169-
.default(build.config.extended)
170-
.host(true)
171-
.only_host_build(true)
172-
.dep(|s| s.name("dist-rls"))
173-
.run(move |s| install::Installer::new(build).install_rls(s.stage, s.target));
174-
rules.install("install-analysis", "analysis")
175-
.default(build.config.extended)
176-
.only_host_build(true)
177-
.dep(|s| s.name("dist-analysis"))
178-
.run(move |s| install::Installer::new(build).install_analysis(s.stage, s.target));
179-
rules.install("install-src", "src")
180-
.default(build.config.extended)
181-
.host(true)
182-
.only_build(true)
183-
.only_host_build(true)
184-
.dep(|s| s.name("dist-src"))
185-
.run(move |s| install::Installer::new(build).install_src(s.stage));
186-
rules.install("install-rustc", "src/librustc")
187-
.default(true)
188-
.host(true)
189-
.only_host_build(true)
190-
.dep(|s| s.name("dist-rustc"))
191-
.run(move |s| install::Installer::new(build).install_rustc(s.stage, s.target));
192-
*/
151+
152+
macro_rules! install {
153+
($($name:ident,
154+
$path:expr,
155+
$default_cond:expr,
156+
only_hosts: $only_hosts:expr,
157+
($sel:ident, $builder:ident),
158+
$run_item:block $(, $c:ident)*;)+) => {
159+
$(#[derive(Serialize)]
160+
pub struct $name<'a> {
161+
pub stage: u32,
162+
pub target: &'a str,
163+
pub host: &'a str,
164+
}
165+
166+
impl<'a> Step<'a> for $name<'a> {
167+
type Output = ();
168+
const NAME: &'static str = concat!("install ", stringify!($name));
169+
const DEFAULT: bool = true;
170+
const ONLY_BUILD_TARGETS: bool = true;
171+
const ONLY_HOSTS: bool = $only_hosts;
172+
$(const $c: bool = true;)*
173+
174+
fn should_run(_builder: &Builder, path: &Path) -> bool {
175+
path.ends_with($path)
176+
}
177+
178+
fn make_run($builder: &Builder, path: Option<&Path>, host: &str, target: &str) {
179+
if path.is_none() && !($default_cond) {
180+
return;
181+
}
182+
$builder.ensure($name {
183+
stage: $builder.top_stage,
184+
target,
185+
host,
186+
});
187+
}
188+
189+
fn run($sel, $builder: &Builder) {
190+
$run_item
191+
}
192+
})+
193+
}
194+
}
195+
196+
install!(
197+
// rules.install("install-docs", "src/doc")
198+
// .default(build.config.docs)
199+
// .only_host_build(true)
200+
// .dep(|s| s.name("dist-docs"))
201+
// .run(move |s| install::Installer::new(build).install_docs(s.stage, s.target));
202+
Docs, "src/doc", builder.build.config.docs, only_hosts: false, (self, builder), {
203+
builder.ensure(dist::Docs { stage: self.stage, host: self.host });
204+
Installer::new(builder.build).install_docs(self.stage, self.target);
205+
};
206+
// rules.install("install-std", "src/libstd")
207+
// .default(true)
208+
// .only_host_build(true)
209+
// .dep(|s| s.name("dist-std"))
210+
// .run(move |s| install::Installer::new(build).install_std(s.stage));
211+
Std, "src/libstd", true, only_hosts: true, (self, builder), {
212+
builder.ensure(dist::Std {
213+
compiler: builder.compiler(self.stage, self.host),
214+
target: self.target
215+
});
216+
Installer::new(builder.build).install_std(self.stage);
217+
};
218+
// rules.install("install-cargo", "cargo")
219+
// .default(build.config.extended)
220+
// .host(true)
221+
// .only_host_build(true)
222+
// .dep(|s| s.name("dist-cargo"))
223+
// .run(move |s| install::Installer::new(build).install_cargo(s.stage, s.target));
224+
Cargo, "cargo", builder.build.config.extended, only_hosts: true, (self, builder), {
225+
builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
226+
Installer::new(builder.build).install_cargo(self.stage, self.target);
227+
};
228+
// rules.install("install-rls", "rls")
229+
// .default(build.config.extended)
230+
// .host(true)
231+
// .only_host_build(true)
232+
// .dep(|s| s.name("dist-rls"))
233+
// .run(move |s| install::Installer::new(build).install_rls(s.stage, s.target));
234+
Rls, "rls", builder.build.config.extended, only_hosts: true, (self, builder), {
235+
builder.ensure(dist::Rls { stage: self.stage, target: self.target });
236+
Installer::new(builder.build).install_rls(self.stage, self.target);
237+
};
238+
// rules.install("install-analysis", "analysis")
239+
// .default(build.config.extended)
240+
// .only_host_build(true)
241+
// .dep(|s| s.name("dist-analysis"))
242+
// .run(move |s| install::Installer::new(build).install_analysis(s.stage, s.target));
243+
Analysis, "analysis", builder.build.config.extended, only_hosts: false, (self, builder), {
244+
builder.ensure(dist::Analysis {
245+
compiler: builder.compiler(self.stage, self.host),
246+
target: self.target
247+
});
248+
Installer::new(builder.build).install_analysis(self.stage, self.target);
249+
};
250+
// rules.install("install-src", "src")
251+
// .default(build.config.extended)
252+
// .host(true)
253+
// .only_build(true)
254+
// .only_host_build(true)
255+
// .dep(|s| s.name("dist-src"))
256+
// .run(move |s| install::Installer::new(build).install_src(s.stage));
257+
Src, "src", builder.build.config.extended, only_hosts: true, (self, builder), {
258+
builder.ensure(dist::Src);
259+
Installer::new(builder.build).install_src(self.stage);
260+
}, ONLY_BUILD;
261+
// rules.install("install-rustc", "src/librustc")
262+
// .default(true)
263+
// .host(true)
264+
// .only_host_build(true)
265+
// .dep(|s| s.name("dist-rustc"))
266+
// .run(move |s| install::Installer::new(build).install_rustc(s.stage, s.target));
267+
Rustc, "src/librustc", builder.build.config.extended, only_hosts: true, (self, builder), {
268+
builder.ensure(dist::Rustc { stage: self.stage, host: self.host });
269+
Installer::new(builder.build).install_rustc(self.stage, self.target);
270+
};
271+
);

‎src/bootstrap/native.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use Build;
3333
use util;
3434
use build_helper::up_to_date;
3535

36-
/j/ rules.build("llvm", "src/llvm")
36+
// rules.build("llvm", "src/llvm")
3737
// .host(true)
3838
// .dep(move |s| {
3939
// if s.target == build.build {
@@ -51,6 +51,7 @@ pub struct Llvm<'a> {
5151

5252
impl<'a> Step<'a> for Llvm<'a> {
5353
type Output = ();
54+
const ONLY_HOSTS: bool = true;
5455

5556
/// Compile LLVM for `target`.
5657
fn run(self, builder: &Builder) {
@@ -151,6 +152,7 @@ impl<'a> Step<'a> for Llvm<'a> {
151152

152153
// http://llvm.org/docs/HowToCrossCompileLLVM.html
153154
if target != build.build {
155+
builder.ensure(Llvm { target: &build.build });
154156
// FIXME: if the llvm root for the build triple is overridden then we
155157
// should use llvm-tblgen from there, also should verify that it
156158
// actually exists most of the time in normal installs of LLVM.
@@ -249,6 +251,14 @@ pub struct TestHelpers<'a> {
249251
impl<'a> Step<'a> for TestHelpers<'a> {
250252
type Output = ();
251253

254+
fn should_run(_builder: &Builder, path: &Path) -> bool {
255+
path.ends_with("src/rt/rust_test_helpers.c")
256+
}
257+
258+
fn make_run(builder: &Builder, _path: Option<&Path>, _host: &str, target: &str) {
259+
builder.ensure(TestHelpers { target })
260+
}
261+
252262
/// Compiles the `rust_test_helpers.c` library which we used in various
253263
/// `run-pass` test suites for ABI testing.
254264
fn run(self, builder: &Builder) {
@@ -295,12 +305,16 @@ const OPENSSL_SHA256: &'static str =
295305

296306
#[derive(Serialize)]
297307
pub struct Openssl<'a> {
298-
target: &'a str,
308+
pub target: &'a str,
299309
}
300310

301311
impl<'a> Step<'a> for Openssl<'a> {
302312
type Output = ();
303313

314+
fn should_run(_builder: &Builder, _path: &Path) -> bool {
315+
false
316+
}
317+
304318
fn run(self, builder: &Builder) {
305319
let build = bulder.build;
306320
let target = self.target;

‎src/bootstrap/tool.rs

Lines changed: 249 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::process::Command;
1515
use Mode;
1616
use builder::{Step, Builder};
1717
use util::{exe, add_lib_path};
18-
use compile::{self, stamp, Rustc};
18+
use compile::{self, libtest_stamp, libstd_stamp, librustc_stamp, Rustc};
1919
use native;
2020
use channel::GitInfo;
2121

@@ -63,7 +63,7 @@ impl<'a> Step<'a> for CleanTools<'a> {
6363
let target = self.target;
6464
let mode = self.mode;
6565

66-
let compiler = Compiler::new(stage, &build.build);
66+
let compiler = builder.compiler(stage, &build.build);
6767

6868
let stamp = match mode {
6969
Mode::Libstd => libstd_stamp(build, &compiler, target),
@@ -76,103 +76,39 @@ impl<'a> Step<'a> for CleanTools<'a> {
7676
}
7777
}
7878

79-
// rules.build("tool-rustbook", "src/tools/rustbook")
80-
// .dep(|s| s.name("maybe-clean-tools"))
81-
// .dep(|s| s.name("librustc-tool"))
82-
// .run(move |s| compile::tool(build, s.stage, s.target, "rustbook"));
83-
// rules.build("tool-error-index", "src/tools/error_index_generator")
84-
// .dep(|s| s.name("maybe-clean-tools"))
85-
// .dep(|s| s.name("librustc-tool"))
86-
// .run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator"));
87-
// rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen")
88-
// .dep(|s| s.name("maybe-clean-tools"))
89-
// .dep(|s| s.name("libstd-tool"))
90-
// .run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen"));
91-
// rules.build("tool-tidy", "src/tools/tidy")
92-
// .dep(|s| s.name("maybe-clean-tools"))
93-
// .dep(|s| s.name("libstd-tool"))
94-
// .run(move |s| compile::tool(build, s.stage, s.target, "tidy"));
95-
// rules.build("tool-linkchecker", "src/tools/linkchecker")
96-
// .dep(|s| s.name("maybe-clean-tools"))
97-
// .dep(|s| s.name("libstd-tool"))
98-
// .run(move |s| compile::tool(build, s.stage, s.target, "linkchecker"));
99-
// rules.build("tool-cargotest", "src/tools/cargotest")
100-
// .dep(|s| s.name("maybe-clean-tools"))
101-
// .dep(|s| s.name("libstd-tool"))
102-
// .run(move |s| compile::tool(build, s.stage, s.target, "cargotest"));
103-
// rules.build("tool-compiletest", "src/tools/compiletest")
104-
// .dep(|s| s.name("maybe-clean-tools"))
105-
// .dep(|s| s.name("libtest-tool"))
106-
// .run(move |s| compile::tool(build, s.stage, s.target, "compiletest"));
107-
// rules.build("tool-build-manifest", "src/tools/build-manifest")
108-
// .dep(|s| s.name("maybe-clean-tools"))
109-
// .dep(|s| s.name("libstd-tool"))
110-
// .run(move |s| compile::tool(build, s.stage, s.target, "build-manifest"));
111-
// rules.build("tool-remote-test-server", "src/tools/remote-test-server")
112-
// .dep(|s| s.name("maybe-clean-tools"))
113-
// .dep(|s| s.name("libstd-tool"))
114-
// .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-server"));
115-
// rules.build("tool-remote-test-client", "src/tools/remote-test-client")
116-
// .dep(|s| s.name("maybe-clean-tools"))
117-
// .dep(|s| s.name("libstd-tool"))
118-
// .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-client"));
119-
// rules.build("tool-rust-installer", "src/tools/rust-installer")
120-
// .dep(|s| s.name("maybe-clean-tools"))
121-
// .dep(|s| s.name("libstd-tool"))
122-
// .run(move |s| compile::tool(build, s.stage, s.target, "rust-installer"));
123-
// rules.build("tool-cargo", "src/tools/cargo")
124-
// .host(true)
125-
// .default(build.config.extended)
126-
// .dep(|s| s.name("maybe-clean-tools"))
127-
// .dep(|s| s.name("libstd-tool"))
128-
// .dep(|s| s.stage(0).host(s.target).name("openssl"))
129-
// .dep(move |s| {
130-
// // Cargo depends on procedural macros, which requires a full host
131-
// // compiler to be available, so we need to depend on that.
132-
// s.name("librustc-link")
133-
// .target(&build.build)
134-
// .host(&build.build)
135-
// })
136-
// .run(move |s| compile::tool(build, s.stage, s.target, "cargo"));
137-
// rules.build("tool-rls", "src/tools/rls")
138-
// .host(true)
139-
// .default(build.config.extended)
140-
// .dep(|s| s.name("librustc-tool"))
141-
// .dep(|s| s.stage(0).host(s.target).name("openssl"))
142-
// .dep(move |s| {
143-
// // rls, like cargo, uses procedural macros
144-
// s.name("librustc-link")
145-
// .target(&build.build)
146-
// .host(&build.build)
147-
// })
148-
// .run(move |s| compile::tool(build, s.stage, s.target, "rls"));
149-
//
150-
15179
#[derive(Serialize)]
152-
pub struct Tool<'a> {
80+
pub struct ToolBuild<'a> {
15381
pub stage: u32,
15482
pub target: &'a str,
15583
pub tool: &'a str,
84+
pub mode: Mode,
15685
}
15786

158-
impl<'a> Step<'a> for Tool<'a> {
159-
type Output = ();
87+
impl<'a> Step<'a> for ToolBuild<'a> {
88+
type Output = PathBuf;
16089

16190
/// Build a tool in `src/tools`
16291
///
16392
/// This will build the specified tool with the specified `host` compiler in
16493
/// `stage` into the normal cargo output directory.
165-
fn run(self, builder: &Builder) {
94+
fn run(self, builder: &Builder) -> PathBuf {
16695
let build = builder.build;
16796
let stage = self.stage;
16897
let target = self.target;
16998
let tool = self.tool;
17099

100+
let compiler = builder.compiler(stage, &build.build);
101+
builder.ensure(CleanTools { stage, target, mode: self.mode });
102+
match self.mode {
103+
Mode::Libstd => builder.ensure(compile::Std { compiler, target }),
104+
Mode::Libtest => builder.ensure(compile::Test { compiler, target }),
105+
Mode::Librustc => builder.ensure(compile::Rustc { compiler, target }),
106+
Mode::Tool => panic!("unexpected Mode::Tool for tool build")
107+
}
108+
171109
let _folder = build.fold_output(|| format!("stage{}-{}", stage, tool));
172110
println!("Building stage{} tool {} ({})", stage, tool, target);
173111

174-
let compiler = Compiler::new(stage, &build.build);
175-
176112
let mut cargo = build.cargo(&compiler, Mode::Tool, target, "build");
177113
let dir = build.src.join("src/tools").join(tool);
178114
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
@@ -201,5 +137,238 @@ impl<'a> Step<'a> for Tool<'a> {
201137
}
202138

203139
build.run(&mut cargo);
140+
build.cargo_out(compiler, Mode::Tool, target).join(exe(tool, compiler.host))
141+
}
142+
}
143+
144+
macro_rules! tool {
145+
($($name:ident, $path:expr, $tool_name:expr, $mode:expr;)+) => {
146+
#[derive(Copy, Clone)]
147+
pub enum Tool {
148+
$(
149+
$name,
150+
)+
151+
}
152+
153+
impl<'a> Builder<'a> {
154+
pub fn tool_exe(&self, tool: Tool) -> PathBuf {
155+
match tool {
156+
$(Tool::$name =>
157+
self.ensure($name {
158+
stage: 0,
159+
target: &self.build.build,
160+
}),
161+
)+
162+
}
163+
}
164+
}
165+
166+
$(
167+
#[derive(Serialize)]
168+
pub struct $name<'a> {
169+
pub stage: u32,
170+
pub target: &'a str,
171+
}
172+
173+
impl<'a> Step<'a> for $name<'a> {
174+
type Output = PathBuf;
175+
const NAME: &'static str = concat!(stringify!($name), " tool");
176+
177+
fn should_run(_builder: &Builder, path: &Path) -> bool {
178+
path.ends_with($path)
179+
}
180+
181+
fn make_run(builder: &Builder, _path: Option<&Path>, _host: &str, target: &str) {
182+
builder.ensure($name {
183+
stage: builder.top_stage,
184+
target,
185+
});
186+
}
187+
188+
fn run(self, builder: &Builder) -> PathBuf {
189+
builder.ensure(ToolBuild {
190+
stage: self.stage,
191+
target: self.target,
192+
tool: $tool_name,
193+
mode: $mode,
194+
})
195+
}
196+
}
197+
)+
198+
}
199+
}
200+
201+
tool!(
202+
// rules.build("tool-rustbook", "src/tools/rustbook")
203+
// .dep(|s| s.name("maybe-clean-tools"))
204+
// .dep(|s| s.name("librustc-tool"))
205+
// .run(move |s| compile::tool(build, s.stage, s.target, "rustbook"));
206+
Rustbook, "src/tools/rustbook", "rustbook", Mode::Librustc;
207+
// rules.build("tool-error-index", "src/tools/error_index_generator")
208+
// .dep(|s| s.name("maybe-clean-tools"))
209+
// .dep(|s| s.name("librustc-tool"))
210+
// .run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator"));
211+
ErrorIndex, "src/tools/error_index_generator", "error_index_generator", Mode::Librustc;
212+
// rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen")
213+
// .dep(|s| s.name("maybe-clean-tools"))
214+
// .dep(|s| s.name("libstd-tool"))
215+
// .run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen"));
216+
UnstableBook, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::Libstd;
217+
// rules.build("tool-tidy", "src/tools/tidy")
218+
// .dep(|s| s.name("maybe-clean-tools"))
219+
// .dep(|s| s.name("libstd-tool"))
220+
// .run(move |s| compile::tool(build, s.stage, s.target, "tidy"));
221+
Tidy, "src/tools/tidy", "tidy", Mode::Libstd;
222+
// rules.build("tool-linkchecker", "src/tools/linkchecker")
223+
// .dep(|s| s.name("maybe-clean-tools"))
224+
// .dep(|s| s.name("libstd-tool"))
225+
// .run(move |s| compile::tool(build, s.stage, s.target, "linkchecker"));
226+
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::Libstd;
227+
// rules.build("tool-cargotest", "src/tools/cargotest")
228+
// .dep(|s| s.name("maybe-clean-tools"))
229+
// .dep(|s| s.name("libstd-tool"))
230+
// .run(move |s| compile::tool(build, s.stage, s.target, "cargotest"));
231+
CargoTest, "src/tools/cargotest", "cargotest", Mode::Libstd;
232+
// rules.build("tool-compiletest", "src/tools/compiletest")
233+
// .dep(|s| s.name("maybe-clean-tools"))
234+
// .dep(|s| s.name("libtest-tool"))
235+
// .run(move |s| compile::tool(build, s.stage, s.target, "compiletest"));
236+
Compiletest, "src/tools/compiletest", "compiletest", Mode::Libtest;
237+
// rules.build("tool-build-manifest", "src/tools/build-manifest")
238+
// .dep(|s| s.name("maybe-clean-tools"))
239+
// .dep(|s| s.name("libstd-tool"))
240+
// .run(move |s| compile::tool(build, s.stage, s.target, "build-manifest"));
241+
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd;
242+
// rules.build("tool-remote-test-server", "src/tools/remote-test-server")
243+
// .dep(|s| s.name("maybe-clean-tools"))
244+
// .dep(|s| s.name("libstd-tool"))
245+
// .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-server"));
246+
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server", Mode::Libstd;
247+
// rules.build("tool-remote-test-client", "src/tools/remote-test-client")
248+
// .dep(|s| s.name("maybe-clean-tools"))
249+
// .dep(|s| s.name("libstd-tool"))
250+
// .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-client"));
251+
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd;
252+
// rules.build("tool-rust-installer", "src/tools/rust-installer")
253+
// .dep(|s| s.name("maybe-clean-tools"))
254+
// .dep(|s| s.name("libstd-tool"))
255+
// .run(move |s| compile::tool(build, s.stage, s.target, "rust-installer"));
256+
RustInstaller, "src/tools/rust-installer", "rust-installer", Mode::Libstd;
257+
);
258+
259+
// rules.build("tool-cargo", "src/tools/cargo")
260+
// .host(true)
261+
// .default(build.config.extended)
262+
// .dep(|s| s.name("maybe-clean-tools"))
263+
// .dep(|s| s.name("libstd-tool"))
264+
// .dep(|s| s.stage(0).host(s.target).name("openssl"))
265+
// .dep(move |s| {
266+
// // Cargo depends on procedural macros, which requires a full host
267+
// // compiler to be available, so we need to depend on that.
268+
// s.name("librustc-link")
269+
// .target(&build.build)
270+
// .host(&build.build)
271+
// })
272+
// .run(move |s| compile::tool(build, s.stage, s.target, "cargo"));
273+
#[derive(Serialize)]
274+
pub struct Cargo<'a> {
275+
pub stage: u32,
276+
pub target: &'a str,
277+
}
278+
279+
impl<'a> Step<'a> for Cargo<'a> {
280+
type Output = PathBuf;
281+
const NAME: &'static str = "cargo tool";
282+
const DEFAULT: bool = true;
283+
const ONLY_HOSTS: bool = true;
284+
285+
fn should_run(_builder: &Builder, path: &Path) -> bool {
286+
path.ends_with("src/tools/cargo")
287+
}
288+
289+
fn make_run(builder: &Builder, path: Option<&Path>, _host: &str, target: &str) {
290+
if path.is_none() && !builder.build.config.extended {
291+
return;
292+
}
293+
builder.ensure(Cargo {
294+
stage: builder.top_stage,
295+
target,
296+
});
297+
}
298+
299+
fn run(self, builder: &Builder) -> PathBuf {
300+
builder.ensure(native::Openssl {
301+
target: self.target,
302+
});
303+
// Cargo depends on procedural macros, which requires a full host
304+
// compiler to be available, so we need to depend on that.
305+
builder.ensure(Rustc {
306+
compiler: builder.compiler(builder.top_stage, &builder.build.build),
307+
target: &builder.build.build,
308+
});
309+
builder.ensure(ToolBuild {
310+
stage: self.stage,
311+
target: self.target,
312+
tool: "cargo",
313+
mode: Mode::Libstd,
314+
})
315+
}
316+
}
317+
318+
// rules.build("tool-rls", "src/tools/rls")
319+
// .host(true)
320+
// .default(build.config.extended)
321+
// .dep(|s| s.name("librustc-tool"))
322+
// .dep(|s| s.stage(0).host(s.target).name("openssl"))
323+
// .dep(move |s| {
324+
// // rls, like cargo, uses procedural macros
325+
// s.name("librustc-link")
326+
// .target(&build.build)
327+
// .host(&build.build)
328+
// })
329+
// .run(move |s| compile::tool(build, s.stage, s.target, "rls"));
330+
//
331+
#[derive(Serialize)]
332+
pub struct Rls<'a> {
333+
pub stage: u32,
334+
pub target: &'a str,
335+
}
336+
337+
impl<'a> Step<'a> for Rls<'a> {
338+
type Output = PathBuf;
339+
const NAME: &'static str = "RLS tool";
340+
const DEFAULT: bool = true;
341+
const ONLY_HOSTS: bool = true;
342+
343+
fn should_run(_builder: &Builder, path: &Path) -> bool {
344+
path.ends_with("src/tools/rls")
345+
}
346+
347+
fn make_run(builder: &Builder, path: Option<&Path>, _host: &str, target: &str) {
348+
if path.is_none() && !builder.build.config.extended {
349+
return;
350+
}
351+
builder.ensure(Cargo {
352+
stage: builder.top_stage,
353+
target,
354+
});
355+
}
356+
357+
fn run(self, builder: &Builder) -> PathBuf {
358+
builder.ensure(native::Openssl {
359+
target: self.target,
360+
});
361+
// RLS depends on procedural macros, which requires a full host
362+
// compiler to be available, so we need to depend on that.
363+
builder.ensure(Rustc {
364+
compiler: builder.compiler(builder.top_stage, &builder.build.build),
365+
target: &builder.build.build,
366+
});
367+
builder.ensure(ToolBuild {
368+
stage: self.stage,
369+
target: self.target,
370+
tool: "rls",
371+
mode: Mode::Librustc,
372+
})
204373
}
205374
}

0 commit comments

Comments
 (0)
Please sign in to comment.