Add llvm_components_contain to run-make-support

This commit is contained in:
Jerry Wang 2024-07-15 19:42:45 -04:00
parent f00f850919
commit a9e14668d6
No known key found for this signature in database
GPG Key ID: B9657729C5192EDC
2 changed files with 8 additions and 1 deletions

View File

@ -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::{

View File

@ -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]