Revert "Revert "Check __ANDROID_API__ instead of defining it""

Reland commit b2fd4fabee20e321c4f327f15e6de76dfb21eea2.
This commit is contained in:
Brian Smith 2018-05-22 08:18:53 -10:00
parent 13d210dac8
commit 08ec4f374c
2 changed files with 3 additions and 11 deletions

View File

@ -58,6 +58,9 @@ Note in particular that if you are cross-compiling an x86 build on a 64-bit
version of Linux, then you need to have the proper gcc-multilibs and
g++-multilibs packages or equivalent installed.
On Android, you will need to define the `__ANDROID_API__` constant to at least
`21` on 64-bit and `18` on 32-bit.
Additional Features that are Useful for Development

View File

@ -571,17 +571,6 @@ fn cc(file: &Path, ext: &str, target: &Target, warnings_are_errors: bool,
// http://www.openwall.com/lists/musl/2015/06/17/1
let _ = c.flag("-U_FORTIFY_SOURCE");
}
if target.os() == "android" {
// Define __ANDROID_API__ to the Android API level we want.
// Needed for Android NDK Unified Headers, see:
// https://android.googlesource.com/platform/ndk/+/master/docs/UnifiedHeaders.md#Supporting-Unified-Headers-in-Your-Build-System
if target.arch() == "aarch64" {
// Minimum API level where AArch64 is available is 21.
let _ = c.define("__ANDROID_API__", Some("21"));
} else {
let _ = c.define("__ANDROID_API__", Some("18"));
}
}
let mut c = c.get_compiler().to_command();
let _ = c.arg("-c")