cargo
}
-macro_rules! tool {
+macro_rules! bootstrap_tool {
($(
- $name:ident, $path:expr, $tool_name:expr, $mode:expr
+ $name:ident, $path:expr, $tool_name:expr
$(,llvm_tools = $llvm:expr)*
$(,is_external_tool = $external:expr)*
;
impl Tool {
pub fn get_mode(&self) -> Mode {
- let mode = match self {
- $(Tool::$name => $mode,)+
- };
- mode
+ Mode::ToolBootstrap
}
/// Whether this tool requires LLVM to run
impl<'a> Builder<'a> {
pub fn tool_exe(&self, tool: Tool) -> PathBuf {
- let stage = self.tool_default_stage(tool);
match tool {
$(Tool::$name =>
self.ensure($name {
- compiler: self.compiler(stage, self.config.build),
+ compiler: self.compiler(0, self.config.build),
target: self.config.build,
}),
)+
}
}
-
- pub fn tool_default_stage(&self, tool: Tool) -> u32 {
- // Compile the error-index in the same stage as rustdoc to avoid
- // recompiling rustdoc twice if we can. Otherwise compile
- // everything else in stage0 as there's no need to rebootstrap
- // everything.
- match tool {
- Tool::ErrorIndex if self.top_stage >= 2 => self.top_stage,
- _ => 0,
- }
- }
}
$(
fn make_run(run: RunConfig<'_>) {
run.builder.ensure($name {
- compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
+ // snapshot compiler
+ compiler: run.builder.compiler(0, run.builder.config.build),
target: run.target,
});
}
compiler: self.compiler,
target: self.target,
tool: $tool_name,
- mode: $mode,
+ mode: Mode::ToolBootstrap,
path: $path,
is_optional_tool: false,
source_type: if false $(|| $external)* {
}
}
-tool!(
- Rustbook, "src/tools/rustbook", "rustbook", Mode::ToolBootstrap;
- ErrorIndex, "src/tools/error_index_generator", "error_index_generator", Mode::ToolRustc;
- UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolBootstrap;
- Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap;
- Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolBootstrap;
- CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap;
- Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
- BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
- RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
- RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
- is_external_tool = true;
- RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
+bootstrap_tool!(
+ Rustbook, "src/tools/rustbook", "rustbook";
+ UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
+ Tidy, "src/tools/tidy", "tidy";
+ Linkchecker, "src/tools/linkchecker", "linkchecker";
+ CargoTest, "src/tools/cargotest", "cargotest";
+ Compiletest, "src/tools/compiletest", "compiletest", llvm_tools = true;
+ BuildManifest, "src/tools/build-manifest", "build-manifest";
+ RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
+ RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;
+ RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
);
+#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+pub struct ErrorIndex {
+ pub compiler: Compiler,
+}
+
+impl ErrorIndex {
+ pub fn command(builder: &Builder<'_>, compiler: Compiler) -> Command {
+ let mut cmd = Command::new(builder.ensure(ErrorIndex {
+ compiler
+ }));
+ add_lib_path(
+ vec![PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host))],
+ &mut cmd,
+ );
+ cmd
+ }
+}
+
+impl Step for ErrorIndex {
+ type Output = PathBuf;
+
+ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+ run.path("src/tools/error_index_generator")
+ }
+
+ fn make_run(run: RunConfig<'_>) {
+ // Compile the error-index in the same stage as rustdoc to avoid
+ // recompiling rustdoc twice if we can.
+ let stage = if run.builder.top_stage >= 2 { run.builder.top_stage } else { 0 };
+ run.builder.ensure(ErrorIndex {
+ compiler: run.builder.compiler(stage, run.builder.config.build),
+ });
+ }
+
+ fn run(self, builder: &Builder<'_>) -> PathBuf {
+ builder.ensure(ToolBuild {
+ compiler: self.compiler,
+ target: self.compiler.host,
+ tool: "error_index_generator",
+ mode: Mode::ToolRustc,
+ path: "src/tools/error_index_generator",
+ is_optional_tool: false,
+ source_type: SourceType::InTree,
+ extra_features: Vec::new(),
+ }).expect("expected to build -- essential tool")
+ }
+}
+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RemoteTestServer {
pub compiler: Compiler,
/// `host`.
pub fn tool_cmd(&self, tool: Tool) -> Command {
let mut cmd = Command::new(self.tool_exe(tool));
- let compiler = self.compiler(self.tool_default_stage(tool), self.config.build);
+ let compiler = self.compiler(0, self.config.build);
self.prepare_tool_cmd(compiler, tool, &mut cmd);
cmd
}
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
let host = &compiler.host;
let mut lib_paths: Vec<PathBuf> = vec![
- if compiler.stage == 0 && tool != Tool::ErrorIndex {
+ if compiler.stage == 0 {
self.build.rustc_snapshot_libdir()
} else {
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host))