refactor extended tarball generaton to use the new ensure_if_default
This commit is contained in:
parent
2cfac3f045
commit
c15e248090
@ -163,14 +163,8 @@ fn from<S: Step>() -> StepDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_run(&self, builder: &Builder<'_>, pathset: &PathSet) {
|
fn maybe_run(&self, builder: &Builder<'_>, pathset: &PathSet) {
|
||||||
if builder.config.exclude.iter().any(|e| pathset.has(e)) {
|
if self.is_excluded(builder, pathset) {
|
||||||
eprintln!("Skipping {:?} because it is excluded", pathset);
|
|
||||||
return;
|
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.
|
// Determine the targets participating in this rule.
|
||||||
@ -182,6 +176,21 @@ fn maybe_run(&self, builder: &Builder<'_>, pathset: &PathSet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]) {
|
fn run(v: &[StepDescription], builder: &Builder<'_>, paths: &[PathBuf]) {
|
||||||
let should_runs =
|
let should_runs =
|
||||||
v.iter().map(|desc| (desc.should_run)(ShouldRun::new(builder))).collect::<Vec<_>>();
|
v.iter().map(|desc| (desc.should_run)(ShouldRun::new(builder))).collect::<Vec<_>>();
|
||||||
@ -1579,6 +1588,27 @@ pub fn ensure<S: Step>(&'a self, step: S) -> S::Output {
|
|||||||
self.cache.put(step, out.clone());
|
self.cache.put(step, out.clone());
|
||||||
out
|
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)]
|
#[cfg(test)]
|
||||||
|
@ -59,7 +59,7 @@ pub struct Docs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Step for Docs {
|
impl Step for Docs {
|
||||||
type Output = GeneratedTarball;
|
type Output = Option<GeneratedTarball>;
|
||||||
const DEFAULT: bool = true;
|
const DEFAULT: bool = true;
|
||||||
|
|
||||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||||
@ -72,7 +72,7 @@ fn make_run(run: RunConfig<'_>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builds the `rust-docs` installer component.
|
/// Builds the `rust-docs` installer component.
|
||||||
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
|
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
|
||||||
let host = self.host;
|
let host = self.host;
|
||||||
builder.default_doc(&[]);
|
builder.default_doc(&[]);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
|
|||||||
tarball.set_product_name("Rust Documentation");
|
tarball.set_product_name("Rust Documentation");
|
||||||
tarball.add_bulk_dir(&builder.doc_out(host), dest);
|
tarball.add_bulk_dir(&builder.doc_out(host), dest);
|
||||||
tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644);
|
tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644);
|
||||||
tarball.generate()
|
Some(tarball.generate())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,13 +1359,11 @@ fn run(self, builder: &Builder<'_>) {
|
|||||||
|
|
||||||
let mut tarballs = Vec::new();
|
let mut tarballs = Vec::new();
|
||||||
let mut built_tools = HashSet::new();
|
let mut built_tools = HashSet::new();
|
||||||
macro_rules! add_tool {
|
macro_rules! add_component {
|
||||||
($name:expr => $step:expr) => {
|
($name:expr => $step:expr) => {
|
||||||
if should_build_extended_tool(builder, $name) {
|
if let Some(tarball) = builder.ensure_if_default($step) {
|
||||||
if let Some(tarball) = builder.ensure($step) {
|
tarballs.push(tarball);
|
||||||
tarballs.push(tarball);
|
built_tools.insert($name);
|
||||||
built_tools.insert($name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1377,31 +1375,20 @@ macro_rules! add_tool {
|
|||||||
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
|
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
|
||||||
tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
|
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") {
|
if target.contains("windows-gnu") {
|
||||||
tarballs.push(builder.ensure(Mingw { host: target }).expect("missing mingw"));
|
tarballs.push(builder.ensure(Mingw { host: target }).expect("missing mingw"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if builder.config.profiler_enabled(target)
|
add_component!("rust-docs" => Docs { host: target });
|
||||||
|| should_build_extended_tool(builder, "rust-demangler")
|
add_component!("rust-demangler"=> RustDemangler { compiler, target });
|
||||||
{
|
add_component!("cargo" => Cargo { compiler, target });
|
||||||
if let Some(tarball) = builder.ensure(RustDemangler { compiler, target }) {
|
add_component!("rustfmt" => Rustfmt { compiler, target });
|
||||||
tarballs.push(tarball);
|
add_component!("rls" => Rls { compiler, target });
|
||||||
built_tools.insert("rust-demangler");
|
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_tool!("cargo" => Cargo { compiler, target });
|
add_component!("analysis" => Analysis { 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 });
|
|
||||||
|
|
||||||
let etc = builder.src.join("src/etc/installer");
|
let etc = builder.src.join("src/etc/installer");
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ fn run($sel, $builder: &Builder<'_>) {
|
|||||||
|
|
||||||
install!((self, builder, _config),
|
install!((self, builder, _config),
|
||||||
Docs, "src/doc", _config.docs, only_hosts: false, {
|
Docs, "src/doc", _config.docs, only_hosts: false, {
|
||||||
let tarball = builder.ensure(dist::Docs { host: self.target });
|
let tarball = builder.ensure(dist::Docs { host: self.target }).expect("missing docs");
|
||||||
install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
|
install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball);
|
||||||
};
|
};
|
||||||
Std, "library/std", true, only_hosts: false, {
|
Std, "library/std", true, only_hosts: false, {
|
||||||
|
Loading…
Reference in New Issue
Block a user