}
fn run(v: &[StepDescription], builder: &Builder, paths: &[PathBuf]) {
+ let should_runs = v.iter().map(|desc| {
+ (desc.should_run)(ShouldRun::new(builder))
+ }).collect::<Vec<_>>();
if paths.is_empty() {
- for desc in v {
- if desc.default {
+ for (desc, should_run) in v.iter().zip(should_runs) {
+ if desc.default && should_run.is_really_default {
desc.maybe_run(builder, None);
}
}
} else {
for path in paths {
let mut attempted_run = false;
- for desc in v {
- if (desc.should_run)(ShouldRun::new(builder)).run(path) {
+ for (desc, should_run) in v.iter().zip(&should_runs) {
+ if should_run.run(path) {
attempted_run = true;
desc.maybe_run(builder, Some(path));
}
#[derive(Clone)]
pub struct ShouldRun<'a> {
- builder: &'a Builder<'a>,
+ pub builder: &'a Builder<'a>,
// use a BTreeSet to maintain sort order
paths: BTreeSet<PathBuf>,
+
+ // If this is a default rule, this is an additional constraint placed on
+ // it's run. Generally something like compiler docs being enabled.
+ is_really_default: bool,
}
impl<'a> ShouldRun<'a> {
ShouldRun {
builder: builder,
paths: BTreeSet::new(),
+ is_really_default: true, // by default no additional conditions
}
}
+ pub fn default_condition(mut self, cond: bool) -> Self {
+ self.is_really_default = cond;
+ self
+ }
+
pub fn krate(mut self, name: &str) -> Self {
for (_, krate_path) in self.builder.crates(name) {
self.paths.insert(PathBuf::from(krate_path));
}
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src/tools/linkchecker")
+ let builder = run.builder;
+ run.path("src/tools/linkchecker").default_condition(builder.build.config.docs)
}
fn make_run(
host: Interned<String>,
_target: Interned<String>,
) {
- if path.is_some() {
- builder.ensure(Linkcheck { host });
- } else {
- if builder.build.config.docs {
- builder.ensure(Linkcheck { host });
- }
- }
+ builder.ensure(Linkcheck { host });
}
}
const ONLY_BUILD_TARGETS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("analysis")
+ let builder = run.builder;
+ run.path("analysis").default_condition(builder.build.config.extended)
}
fn make_run(
host: Interned<String>,
target: Interned<String>
) {
- if path.is_none() && !builder.build.config.extended {
- return;
- }
builder.ensure(Analysis {
compiler: builder.compiler(builder.top_stage, host),
target: target,
const ONLY_BUILD: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src")
+ let builder = run.builder;
+ run.path("src").default_condition(builder.config.rust_dist_src)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, _target: Interned<String>
) {
- if path.is_none() && !builder.build.config.rust_dist_src {
- return;
- }
-
builder.ensure(PlainSourceTarball);
}
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("cargo")
+ let builder = run.builder;
+ run.path("cargo").default_condition(builder.config.extended)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- if path.is_none() && !builder.build.config.extended {
- return;
- }
builder.ensure(Extended {
stage: builder.top_stage,
target: target,
const DEFAULT: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path($path)
+ let builder = run.builder;
+ run.path($path).default_condition(builder.build.config.docs)
}
fn make_run(
const DEFAULT: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src/doc/unstable-book")
+ let builder = run.builder;
+ run.path("src/doc/unstable-book").default_condition(builder.build.config.docs)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- if path.is_none() && !builder.build.config.docs {
- // Not a default rule if docs are disabled.
- return;
- }
-
builder.ensure(UnstableBook {
target,
});
const DEFAULT: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src/doc/book")
+ let builder = run.builder;
+ run.path("src/doc/book").default_condition(builder.build.config.docs)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- if path.is_none() && !builder.build.config.docs {
- // Not a default rule if docs are disabled.
- return;
- }
-
builder.ensure(TheBook {
target,
name: "book",
const DEFAULT: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.krate("std")
+ let builder = run.builder;
+ run.krate("std").default_condition(builder.build.config.docs)
}
-
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- let run = || {
- builder.ensure(Std {
- stage: builder.top_stage,
- target
- });
- };
-
- if let Some(path) = path {
- for (_, krate_path) in builder.crates("std") {
- if path.ends_with(krate_path) {
- run();
- }
- }
- } else {
- if builder.build.config.docs {
- run();
- }
- }
+ builder.ensure(Std {
+ stage: builder.top_stage,
+ target
+ });
}
/// Compile all standard library documentation.
const DEFAULT: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.krate("test")
+ let builder = run.builder;
+ run.krate("test").default_condition(builder.config.compiler_docs)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- let run = || {
- builder.ensure(Test {
- stage: builder.top_stage,
- target
- });
- };
-
- if let Some(path) = path {
- for (_, krate_path) in builder.crates("test") {
- if path.ends_with(krate_path) {
- run();
- }
- }
- } else {
- if builder.build.config.compiler_docs {
- run();
- }
- }
+ builder.ensure(Test {
+ stage: builder.top_stage,
+ target
+ });
}
/// Compile all libtest documentation.
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.krate("rustc-main")
+ let builder = run.builder;
+ run.krate("rustc-main").default_condition(builder.build.config.docs)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- let run = || {
- builder.ensure(Rustc {
- stage: builder.top_stage,
- target
- });
- };
-
- if let Some(path) = path {
- for (_, krate_path) in builder.crates("rustc-main") {
- if path.ends_with(krate_path) {
- run();
- }
- }
- } else {
- if builder.build.config.docs {
- run();
- }
- }
+ builder.ensure(Rustc {
+ stage: builder.top_stage,
+ target
+ });
}
/// Generate all compiler documentation.
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src/tools/error_index_generator")
+ let builder = run.builder;
+ run.path("src/tools/error_index_generator").default_condition(builder.build.config.docs)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- if path.is_none() && !builder.build.config.docs {
- // Not a default rule if docs are disabled.
- return;
- }
-
builder.ensure(ErrorIndex {
target,
});
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src/tools/unstable-book-gen")
+ let builder = run.builder;
+ run.path("src/tools/unstable-book-gen").default_condition(builder.build.config.docs)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>,
) {
- if path.is_none() && !builder.build.config.docs {
- // Not a default rule if docs are disabled.
- return;
- }
-
builder.ensure(UnstableBookGen {
target,
});
$(const $c: bool = true;)*
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path($path)
+ let $builder = run.builder;
+ run.path($path).default_condition($default_cond)
}
fn make_run(
host: Interned<String>,
target: Interned<String>,
) {
- if path.is_none() && !($default_cond) {
- return;
- }
$builder.ensure($name {
stage: $builder.top_stage,
target,
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src/tools/cargo")
+ let builder = run.builder;
+ run.path("src/tools/cargo").default_condition(builder.build.config.extended)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- if path.is_none() && !builder.build.config.extended {
- return;
- }
builder.ensure(Cargo {
stage: builder.top_stage,
target,
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
- run.path("src/tools/rls")
+ let builder = run.builder;
+ run.path("src/tools/rls").default_condition(builder.build.config.extended)
}
fn make_run(
builder: &Builder, path: Option<&Path>, _host: Interned<String>, target: Interned<String>
) {
- if path.is_none() && !builder.build.config.extended {
- return;
- }
builder.ensure(Rls {
stage: builder.top_stage,
target,