}
fn maybe_run(&self, builder: &Builder<'_>, pathset: &PathSet) {
- if builder.config.exclude.iter().any(|e| pathset.has(e)) {
- eprintln!("Skipping {:?} because it is excluded", pathset);
+ if self.is_excluded(builder, pathset) {
return;
- } else if !builder.config.exclude.is_empty() {
- eprintln!(
- "{:?} not skipped for {:?} -- not in {:?}",
- pathset, self.name, builder.config.exclude
- );
}
// Determine the targets participating in this rule.
}
}
+ fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
+ if builder.config.exclude.iter().any(|e| pathset.has(e)) {
+ eprintln!("Skipping {:?} because it is excluded", pathset);
+ return true;
+ }
+
+ if !builder.config.exclude.is_empty() {
+ eprintln!(
+ "{:?} not skipped for {:?} -- not in {:?}",
+ pathset, self.name, builder.config.exclude
+ );
+ }
+ false
+ }
+
fn run(v: &[StepDescription], builder: &Builder<'_>, paths: &[PathBuf]) {
let should_runs =
v.iter().map(|desc| (desc.should_run)(ShouldRun::new(builder))).collect::<Vec<_>>();
self.cache.put(step, out.clone());
out
}
+
+ /// Ensure that a given step is built *only if it's supposed to be built by default*, returning
+ /// its output. This will cache the step, so it's safe (and good!) to call this as often as
+ /// needed to ensure that all dependencies are build.
+ pub(crate) fn ensure_if_default<T, S: Step<Output = Option<T>>>(
+ &'a self,
+ step: S,
+ ) -> S::Output {
+ let desc = StepDescription::from::<S>();
+ let should_run = (desc.should_run)(ShouldRun::new(self));
+
+ // Avoid running steps contained in --exclude
+ for pathset in &should_run.paths {
+ if desc.is_excluded(self, pathset) {
+ return None;
+ }
+ }
+
+ // Only execute if it's supposed to run as default
+ if desc.default && should_run.is_really_default() { self.ensure(step) } else { None }
+ }
}
#[cfg(test)]
}
impl Step for Docs {
- type Output = GeneratedTarball;
+ type Output = Option<GeneratedTarball>;
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
}
/// Builds the `rust-docs` installer component.
- fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
+ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
let host = self.host;
builder.default_doc(&[]);
tarball.set_product_name("Rust Documentation");
tarball.add_bulk_dir(&builder.doc_out(host), dest);
tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644);
- tarball.generate()
+ Some(tarball.generate())
}
}
let mut tarballs = Vec::new();
let mut built_tools = HashSet::new();
- macro_rules! add_tool {
+ macro_rules! add_component {
($name:expr => $step:expr) => {
- if should_build_extended_tool(builder, $name) {
- if let Some(tarball) = builder.ensure($step) {
- tarballs.push(tarball);
- built_tools.insert($name);
- }
+ if let Some(tarball) = builder.ensure_if_default($step) {
+ tarballs.push(tarball);
+ built_tools.insert($name);
}
};
}
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
- if builder.config.docs {
- tarballs.push(builder.ensure(Docs { host: target }));
- }
-
if target.contains("windows-gnu") {
tarballs.push(builder.ensure(Mingw { host: target }).expect("missing mingw"));
}
- if builder.config.profiler_enabled(target)
- || should_build_extended_tool(builder, "rust-demangler")
- {
- if let Some(tarball) = builder.ensure(RustDemangler { compiler, target }) {
- tarballs.push(tarball);
- built_tools.insert("rust-demangler");
- }
- }
-
- add_tool!("cargo" => Cargo { compiler, target });
- add_tool!("rustfmt" => Rustfmt { compiler, target });
- add_tool!("rls" => Rls { compiler, target });
- add_tool!("rust-analyzer" => RustAnalyzer { compiler, target });
- add_tool!("llvm-tools" => LlvmTools { target });
- add_tool!("clippy" => Clippy { compiler, target });
- add_tool!("miri" => Miri { compiler, target });
- add_tool!("analysis" => Analysis { compiler, target });
+ add_component!("rust-docs" => Docs { host: target });
+ add_component!("rust-demangler"=> RustDemangler { compiler, target });
+ add_component!("cargo" => Cargo { compiler, target });
+ add_component!("rustfmt" => Rustfmt { compiler, target });
+ add_component!("rls" => Rls { compiler, target });
+ add_component!("rust-analyzer" => RustAnalyzer { compiler, target });
+ add_component!("llvm-components" => LlvmTools { target });
+ add_component!("clippy" => Clippy { compiler, target });
+ add_component!("miri" => Miri { compiler, target });
+ add_component!("analysis" => Analysis { compiler, target });
let etc = builder.src.join("src/etc/installer");