1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Implementation of compiling the compiler and standard library, in "check" mode.
13 use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, add_to_sysroot};
14 use builder::{RunConfig, Builder, ShouldRun, Step};
15 use {Build, Compiler, Mode};
17 use std::path::PathBuf;
19 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
21 pub target: Interned<String>,
26 const DEFAULT: bool = true;
28 fn should_run(run: ShouldRun) -> ShouldRun {
29 run.path("src/libstd").krate("std")
32 fn make_run(run: RunConfig) {
33 run.builder.ensure(Std {
38 fn run(self, builder: &Builder) {
39 let build = builder.build;
40 let target = self.target;
41 let compiler = builder.compiler(0, build.build);
43 let _folder = build.fold_output(|| format!("stage{}-std", compiler.stage));
44 println!("Checking std artifacts ({} -> {})", &compiler.host, target);
46 let out_dir = build.stage_out(compiler, Mode::Libstd);
47 build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
48 let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
49 std_cargo(build, &compiler, target, &mut cargo);
52 &libstd_stamp(build, compiler, target),
54 let libdir = builder.sysroot_libdir(compiler, target);
55 add_to_sysroot(&libdir, &libstd_stamp(build, compiler, target));
59 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
61 pub target: Interned<String>,
66 const ONLY_HOSTS: bool = true;
67 const DEFAULT: bool = true;
69 fn should_run(run: ShouldRun) -> ShouldRun {
70 run.path("src/librustc").krate("rustc-main")
73 fn make_run(run: RunConfig) {
74 run.builder.ensure(Rustc {
79 /// Build the compiler.
81 /// This will build the compiler for a particular stage of the build using
82 /// the `compiler` targeting the `target` architecture. The artifacts
83 /// created will also be linked into the sysroot directory.
84 fn run(self, builder: &Builder) {
85 let build = builder.build;
86 let compiler = builder.compiler(0, build.build);
87 let target = self.target;
89 let _folder = build.fold_output(|| format!("stage{}-rustc", compiler.stage));
90 println!("Checking compiler artifacts ({} -> {})", &compiler.host, target);
92 let stage_out = builder.stage_out(compiler, Mode::Librustc);
93 build.clear_if_dirty(&stage_out, &libstd_stamp(build, compiler, target));
94 build.clear_if_dirty(&stage_out, &libtest_stamp(build, compiler, target));
96 let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "check");
97 rustc_cargo(build, target, &mut cargo);
100 &librustc_stamp(build, compiler, target),
102 let libdir = builder.sysroot_libdir(compiler, target);
103 add_to_sysroot(&libdir, &librustc_stamp(build, compiler, target));
107 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
109 pub target: Interned<String>,
114 const DEFAULT: bool = true;
116 fn should_run(run: ShouldRun) -> ShouldRun {
117 run.path("src/libtest").krate("test")
120 fn make_run(run: RunConfig) {
121 run.builder.ensure(Test {
126 fn run(self, builder: &Builder) {
127 let build = builder.build;
128 let target = self.target;
129 let compiler = builder.compiler(0, build.build);
131 let _folder = build.fold_output(|| format!("stage{}-test", compiler.stage));
132 println!("Checking test artifacts ({} -> {})", &compiler.host, target);
133 let out_dir = build.stage_out(compiler, Mode::Libtest);
134 build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
135 let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "check");
136 test_cargo(build, &compiler, target, &mut cargo);
139 &libtest_stamp(build, compiler, target),
141 let libdir = builder.sysroot_libdir(compiler, target);
142 add_to_sysroot(&libdir, &libtest_stamp(build, compiler, target));
146 /// Cargo's output path for the standard library in a given stage, compiled
147 /// by a particular compiler for the specified target.
148 pub fn libstd_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
149 build.cargo_out(compiler, Mode::Libstd, target).join(".libstd-check.stamp")
152 /// Cargo's output path for libtest in a given stage, compiled by a particular
153 /// compiler for the specified target.
154 pub fn libtest_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
155 build.cargo_out(compiler, Mode::Libtest, target).join(".libtest-check.stamp")
158 /// Cargo's output path for librustc in a given stage, compiled by a particular
159 /// compiler for the specified target.
160 pub fn librustc_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
161 build.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp")