diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index b15705e8965..e6a45f57de6 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -61,7 +61,7 @@ pub use env::{env_var, env_var_os}; pub use run::{cmd, run, run_fail, run_with_args}; /// Helpers for checking target information. -pub use targets::{is_darwin, is_msvc, is_windows, target, uname}; +pub use targets::{is_darwin, is_msvc, is_windows, llvm_components_contain, target, uname}; /// Helpers for building names of output artifacts that are potentially target-specific. pub use artifact_names::{ diff --git a/src/tools/run-make-support/src/targets.rs b/src/tools/run-make-support/src/targets.rs index 42d4a45680d..5dcb0b83430 100644 --- a/src/tools/run-make-support/src/targets.rs +++ b/src/tools/run-make-support/src/targets.rs @@ -28,6 +28,13 @@ pub fn is_darwin() -> bool { target().contains("darwin") } +/// Check if `component` is within `LLVM_COMPONENTS` +#[must_use] +pub fn llvm_components_contain(component: &str) -> bool { + // `LLVM_COMPONENTS` is a space-separated list of words + env_var("LLVM_COMPONENTS").split_whitespace().find(|s| s == &component).is_some() +} + /// Run `uname`. This assumes that `uname` is available on the platform! #[track_caller] #[must_use]