From a4ee73d41f18c78ca8cfb4f548c3adac8b694b0f Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 23 Apr 2022 10:38:16 -0500 Subject: [PATCH] Don't give a hard error on unknown paths if they're excluded The motivation for this is to allow `x t compiler/* --exclude rustc_codegen_cranelift --exclude rustc_codegen_gcc` instead of the much more irritating ``` x t compiler/rustc compiler/rustc_apfloat compiler/rustc_arena compiler/rustc_ast compiler/rustc_ast_lowering compiler/rustc_ast_passes compiler/rustc_ast_pretty compiler/rustc_attr compiler/rustc_borrowck compiler/rustc_builtin_macros compiler/rustc_codegen_llvm compiler/rustc_codegen_ssa compiler/rustc_const_eval compiler/rustc_data_structures compiler/rustc_driver compiler/rustc_error_codes compiler/rustc_error_messages compiler/rustc_errors compiler/rustc_expand compiler/rustc_feature compiler/rustc_fs_util compiler/rustc_graphviz compiler/rustc_hir compiler/rustc_hir_pretty compiler/rustc_incremental compiler/rustc_index compiler/rustc_infer compiler/rustc_interface compiler/rustc_lexer compiler/rustc_lint compiler/rustc_lint_defs compiler/rustc_llvm compiler/rustc_log compiler/rustc_macros compiler/rustc_metadata compiler/rustc_middle compiler/rustc_mir_build compiler/rustc_mir_dataflow compiler/rustc_mir_transform compiler/rustc_monomorphize compiler/rustc_parse compiler/rustc_parse_format compiler/rustc_passes compiler/rustc_plugin_impl compiler/rustc_privacy compiler/rustc_query_impl compiler/rustc_query_system compiler/rustc_resolve compiler/rustc_save_analysis compiler/rustc_serialize compiler/rustc_session compiler/rustc_span compiler/rustc_symbol_mangling compiler/rustc_target compiler/rustc_traits compiler/rustc_trait_selection compiler/rustc_typeck compiler/rustc_type_ir compiler/rustc_ty_utils ``` --- src/bootstrap/builder.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0c4f3265dbf9e..c8d1f5b3bb661 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -168,7 +168,7 @@ impl PathSet { PathSet::Set(BTreeSet::new()) } - fn one>(path: P, kind: Kind) -> PathSet { + pub fn one>(path: P, kind: Kind) -> PathSet { let mut set = BTreeSet::new(); set.insert(TaskPath { path: path.into(), kind: Some(kind) }); PathSet::Set(set) @@ -226,18 +226,7 @@ impl StepDescription { } fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool { - if builder.config.exclude.iter().any(|e| pathset.has(&e.path, e.kind)) { - eprintln!("Skipping {:?} because it is excluded", pathset); - return true; - } - - if !builder.config.exclude.is_empty() { - builder.verbose(&format!( - "{:?} not skipped for {:?} -- not in {:?}", - pathset, self.name, builder.config.exclude - )); - } - false + builder.is_excluded(pathset, &format!("for {:?}", self.name)) } fn run(v: &[StepDescription], builder: &Builder<'_>, paths: &[PathBuf]) { @@ -283,7 +272,7 @@ impl StepDescription { } } - if !attempted_run { + if !attempted_run && !builder.is_excluded(&PathSet::one(path, builder.kind), "") { panic!("error: no rules matched {}", path.display()); } } @@ -747,6 +736,21 @@ impl<'a> Builder<'a> { StepDescription::run(v, self, paths); } + pub fn is_excluded(&self, pathset: &PathSet, extra_description: &str) -> bool { + if self.config.exclude.iter().any(|e| pathset.has(&e.path, e.kind)) { + eprintln!("Skipping {:?} because it is excluded", pathset); + return true; + } + + if !self.config.exclude.is_empty() { + self.verbose(&format!( + "{:?} not skipped{} -- not in {:?}", + pathset, extra_description, self.config.exclude + )); + } + false + } + /// Obtain a compiler at a given stage and for a given host. Explicitly does /// not take `Compiler` since all `Compiler` instances are meant to be /// obtained through this function, since it ensures that they are valid