Skip to content

Commit

Permalink
rustbuild: explicitely build some components only for a given stage
Browse files Browse the repository at this point in the history
Some components are only built when they're being pulled in
as dependencies with .stage(0) specified.
They now can also be pulled in with build-all-tools, hence
only build them as stage 0.

Signed-off-by: Marc-Antoine Perennou <[email protected]>
  • Loading branch information
Keruspe committed Jun 30, 2017
1 parent c4b51c4 commit 071ae56
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,43 +543,50 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
rules.build("tool-rustbook", "src/tools/rustbook")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("librustc-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "rustbook"));
rules.build("tool-error-index", "src/tools/error_index_generator")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("librustc-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator"));
rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen"));
rules.build("tool-tidy", "src/tools/tidy")
.default(build.config.build_all_tools)
.host(true)
.only_build(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "tidy"));
rules.build("tool-linkchecker", "src/tools/linkchecker")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "linkchecker"));
rules.build("tool-cargotest", "src/tools/cargotest")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "cargotest"));
rules.build("tool-compiletest", "src/tools/compiletest")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libtest-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "compiletest"));
Expand All @@ -588,6 +595,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.host(true)
.only_build(true)
.only_host_build(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "build-manifest"));
Expand All @@ -600,12 +608,14 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
rules.build("tool-remote-test-client", "src/tools/remote-test-client")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "remote-test-client"));
rules.build("tool-rust-installer", "src/tools/rust-installer")
.default(build.config.build_all_tools)
.host(true)
.only_stage(0)
.dep(|s| s.name("maybe-clean-tools"))
.dep(|s| s.name("libstd-tool"))
.run(move |s| compile::tool(build, s.stage, s.target, "rust-installer"));
Expand Down Expand Up @@ -980,6 +990,9 @@ struct Rule<'a> {
/// targets.
only_build: bool,

/// Whether this rule is only built for one stage (usually stage 0).
only_stage: Option<u32>,

/// A list of "order only" dependencies. This rules does not actually
/// depend on these rules, but if they show up in the dependency graph then
/// this rule must be executed after all these rules.
Expand Down Expand Up @@ -1008,6 +1021,7 @@ impl<'a> Rule<'a> {
host: false,
only_host_build: false,
only_build: false,
only_stage: None,
after: Vec::new(),
}
}
Expand Down Expand Up @@ -1059,6 +1073,11 @@ impl<'a, 'b> RuleBuilder<'a, 'b> {
self.rule.only_host_build = only_host_build;
self
}

fn only_stage(&mut self, stage: u32) -> &mut Self {
self.rule.only_stage = Some(stage);
self
}
}

impl<'a, 'b> Drop for RuleBuilder<'a, 'b> {
Expand Down Expand Up @@ -1225,6 +1244,7 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
Subcommand::Install { ref paths } => (Kind::Install, &paths[..]),
Subcommand::Clean => panic!(),
};
let current_stage = self.sbuild.stage;

let mut rules: Vec<_> = self.rules.values().filter_map(|rule| {
if rule.kind != kind {
Expand Down Expand Up @@ -1278,7 +1298,10 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?

hosts.iter().flat_map(move |host| {
arr.iter().map(move |target| {
self.sbuild.name(rule.name).target(target).host(host)
self.sbuild.name(rule.name)
.target(target)
.host(host)
.stage(rule.only_stage.unwrap_or(current_stage))
})
})
}).collect()
Expand Down

0 comments on commit 071ae56

Please sign in to comment.