-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21c9b47
commit 6b13969
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
extern crate cc; | ||
|
||
use std::env; | ||
|
||
fn main() { | ||
match env::var("CARGO_CFG_TARGET_OS").unwrap_or_default().as_str() { | ||
"android" => build_android(), | ||
_ => {} | ||
} | ||
} | ||
|
||
fn build_android() { | ||
let expansion = cc::Build::new().file("src/android-api.c").expand(); | ||
let expansion = match std::str::from_utf8(&expansion) { | ||
Ok(s) => s, | ||
Err(_) => return, | ||
}; | ||
println!("expanded android version detection:\n{}", expansion); | ||
let marker = "APIVERSION"; | ||
let i = match expansion.find(marker) { | ||
Some(i) => i, | ||
None => return, | ||
}; | ||
let version = match expansion[i + marker.len() + 1..].split_whitespace().next() { | ||
Some(s) => s, | ||
None => return, | ||
}; | ||
let version = match version.parse::<u32>() { | ||
Ok(n) => n, | ||
Err(_) => return, | ||
}; | ||
if version >= 21 { | ||
println!("cargo:rustc-cfg=feature=\"dl_iterate_phdr\""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Used from the build script to detect the value of the `__ANDROID_API__` | ||
// builtin #define | ||
|
||
APIVERSION __ANDROID_API__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters