Skip to content

Commit

Permalink
Add support for using conditionally available NDK APIs
Browse files Browse the repository at this point in the history
Coming in r26. For more, see android/ndk#837
  • Loading branch information
cpsauer committed Nov 15, 2022
1 parent 48bf74c commit dd6da5d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ndk_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,15 @@ def ndk_cc_toolchain_config(
enabled = True,
),

# By default, allow use of APIs above the api_level, so long as the use is
# protected with a call to __builtin_available(android <version>, *).
# For more, see https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#weak-symbols-for-api-definitions
# This takes effect with NDK r26 and greater.
feature(
name = "android_ndk_conditional_API_availabilty",
enabled = True,
),

# User-settable feature controls warning aggressiveness for compilation.
feature(name = "warnings_as_errors"),

Expand Down Expand Up @@ -682,6 +691,14 @@ def ndk_cc_toolchain_config(
],
features = ["android_unwind_tables"],
),
flag_set(
actions = actions.all_compile,
flags = [
"-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__",
"-Werror=unguarded-availability",
],
features = ["android_ndk_conditional_API_availabilty"],
),

## Options for particular compile modes:

Expand Down

0 comments on commit dd6da5d

Please sign in to comment.