mirror of
https://github.com/italicsjenga/ash-molten.git
synced 2024-12-23 21:31:30 +11:00
Query target_os cfg flags from the env
This commit is contained in:
parent
0bbc0436e8
commit
b8a269ca29
17
build.rs
17
build.rs
|
@ -1,4 +1,15 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
// Iterator over target_os cfg flags
|
||||||
|
fn target_os() -> impl Iterator<Item = String> {
|
||||||
|
std::env::vars().filter_map(|(flag, val)| {
|
||||||
|
const NAME: &'static str = "CARGO_CFG_TARGET_OS";
|
||||||
|
if flag.starts_with(NAME) {
|
||||||
|
Some(val)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
// Features are not used inside build scripts, so we have to explicitly query them from the
|
// Features are not used inside build scripts, so we have to explicitly query them from the
|
||||||
// enviroment
|
// enviroment
|
||||||
fn is_external_enabled() -> bool {
|
fn is_external_enabled() -> bool {
|
||||||
|
@ -16,7 +27,11 @@ fn is_external_enabled() -> bool {
|
||||||
.is_some()
|
.is_some()
|
||||||
}
|
}
|
||||||
fn main() {
|
fn main() {
|
||||||
if !(cfg!(target_os = "macos") || cfg!(target_os = "ios")) {
|
let supported_platforms = ["macos", "ios"];
|
||||||
|
let is_mac_or_ios = target_os()
|
||||||
|
.find(|target| supported_platforms.contains(&target.as_str()))
|
||||||
|
.is_some();
|
||||||
|
if !is_mac_or_ios {
|
||||||
panic!("ash-molten can only be built on macOS or of iOS");
|
panic!("ash-molten can only be built on macOS or of iOS");
|
||||||
}
|
}
|
||||||
// The 'external' feature was not enabled. Molten will be built automaticaly.
|
// The 'external' feature was not enabled. Molten will be built automaticaly.
|
||||||
|
|
Loading…
Reference in a new issue