Skip to content

Commit 5cd9d87

Browse files
committed
Add is_linux and llvm_components_contain to run-make-support
1 parent eb72697 commit 5cd9d87

File tree

1 file changed

+13
-0
lines changed
  • src/tools/run-make-support/src

1 file changed

+13
-0
lines changed

src/tools/run-make-support/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
7474
}
7575
}
7676

77+
/// Check if target is linux-like.
78+
#[must_use]
79+
pub fn is_linux() -> bool {
80+
target().contains("linux")
81+
}
82+
7783
/// Check if target is windows-like.
7884
#[must_use]
7985
pub fn is_windows() -> bool {
@@ -92,6 +98,13 @@ pub fn is_darwin() -> bool {
9298
target().contains("darwin")
9399
}
94100

101+
/// Check if `component` is within `LLVM_COMPONENTS`
102+
#[must_use]
103+
pub fn llvm_components_contain(component: &str) -> bool {
104+
// `LLVM_COMPONENTS` is a space-separated list of words
105+
env_var("LLVM_COMPONENTS").split_whitespace().find(|s| s == &component).is_some()
106+
}
107+
95108
#[track_caller]
96109
#[must_use]
97110
pub fn python_command() -> Command {

0 commit comments

Comments
 (0)