Skip to content

Commit 0821573

Browse files
committed
bootstrap: PathSet::check only considers starts_with for --skip flag
The original motivation for adding this `path.starts_with` check was to allow things like `--skip=src/etc`. But it affects quite a lot more things than just `--skip`; bootstrap is really not designed for the case when multiple Steps match the same filter. For example, `x test src` does ... something! Not sure what, but something! Change `starts_with` to only affect `--skip`, not anything else. The original motivation for this was to make it so that `x doc src/doc --open` doesn't open a dozen different books, but I expect it to fix various other steps in bootstrap as well.
1 parent f5e2df7 commit 0821573

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,7 +3636,7 @@ impl Step for CodegenCranelift {
36363636
const IS_HOST: bool = true;
36373637

36383638
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
3639-
run.paths(&["compiler/rustc_codegen_cranelift"])
3639+
run.paths(&["compiler/rustc_codegen_cranelift"]).path("compiler")
36403640
}
36413641

36423642
fn make_run(run: RunConfig<'_>) {
@@ -3754,7 +3754,7 @@ impl Step for CodegenGCC {
37543754
const IS_HOST: bool = true;
37553755

37563756
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
3757-
run.paths(&["compiler/rustc_codegen_gcc"])
3757+
run.paths(&["compiler/rustc_codegen_gcc"]).path("compiler")
37583758
}
37593759

37603760
fn make_run(run: RunConfig<'_>) {

src/bootstrap/src/core/builder/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,18 @@ impl PathSet {
363363
PathSet::Set(set)
364364
}
365365

366-
fn has(&self, needle: &Path, module: Kind) -> bool {
366+
fn has(&self, needle: &Path, module: Kind, filter_start: bool) -> bool {
367367
match self {
368-
PathSet::Set(set) => set.iter().any(|p| Self::check(p, needle, module)),
369-
PathSet::Suite(suite) => Self::check(suite, needle, module),
368+
PathSet::Set(set) => set.iter().any(|p| Self::check(p, needle, module, filter_start)),
369+
PathSet::Suite(suite) => Self::check(suite, needle, module, filter_start),
370370
}
371371
}
372372

373373
// internal use only
374-
fn check(p: &TaskPath, needle: &Path, module: Kind) -> bool {
374+
fn check(p: &TaskPath, needle: &Path, module: Kind, filter_start: bool) -> bool {
375375
let check_path = || {
376376
// This order is important for retro-compatibility, as `starts_with` was introduced later.
377-
p.path.ends_with(needle) || p.path.starts_with(needle)
377+
p.path.ends_with(needle) || (filter_start && p.path.starts_with(needle))
378378
};
379379
if let Some(p_kind) = &p.kind { check_path() && *p_kind == module } else { check_path() }
380380
}
@@ -389,7 +389,7 @@ impl PathSet {
389389
let mut check = |p| {
390390
let mut result = false;
391391
for n in needles.iter_mut() {
392-
let matched = Self::check(p, &n.path, module);
392+
let matched = Self::check(p, &n.path, module, false);
393393
if matched {
394394
n.will_be_executed = true;
395395
result = true;
@@ -535,7 +535,7 @@ impl StepDescription {
535535
}
536536

537537
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
538-
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) {
538+
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind, true)) {
539539
if !matches!(builder.config.get_dry_run(), DryRun::SelfCheck) {
540540
println!("Skipping {pathset:?} because it is excluded");
541541
}
@@ -1861,7 +1861,7 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler
18611861
let should_run = (desc.should_run)(ShouldRun::new(self, desc.kind));
18621862

18631863
for path in &self.paths {
1864-
if should_run.paths.iter().any(|s| s.has(path, desc.kind))
1864+
if should_run.paths.iter().any(|s| s.has(path, desc.kind, false))
18651865
&& !desc.is_excluded(
18661866
self,
18671867
&PathSet::Suite(TaskPath { path: path.clone(), kind: Some(desc.kind) }),

0 commit comments

Comments
 (0)