Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check __ANDROID_API__ instead of defining it automatically #633

Merged
merged 1 commit into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this sound?:

If you generate a standalone NDK toolchain in order to compile your project, the wrapper automatically passes the ANDROID_API constant to the actual compiler. Otherwise, the __ANDROID_API__ must be defined with a value of at least 21 on 64-bit targets or 18 on 32-bit targets (e.g. export CFLAGS=-D__ANDROID_API__=21).




Additional Features that are Useful for Development
Expand Down
11 changes: 0 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,17 +587,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")
Expand Down