diff --git a/ndk_cc_toolchain_config.bzl b/ndk_cc_toolchain_config.bzl index 7cfebd2..05647a0 100644 --- a/ndk_cc_toolchain_config.bzl +++ b/ndk_cc_toolchain_config.bzl @@ -532,6 +532,12 @@ def ndk_cc_toolchain_config( enabled = True, ), + # Optionally, allow use of APIs above the api_level, so long as the use is + # protected with a call to __builtin_available(android , *). + # 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_availability"), + # User-settable feature controls warning aggressiveness for compilation. feature(name = "warnings_as_errors"), @@ -682,6 +688,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_availability"], + ), ## Options for particular compile modes: