diff --git a/BUILD b/BUILD index 39ea104566..389882b06d 100644 --- a/BUILD +++ b/BUILD @@ -65,6 +65,13 @@ create_compiler_config_setting( ], ) +# Android NDK builds can specify different crosstool_top flags to choose which +# STL they use for C++. We need these multiple variants to catch all of those +# versions of crosstool_top and reliably detect Android. +# +# For more info on the various crosstool_tops used by NDK Bazel builds, see: +# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl + config_setting( name = "android", values = { @@ -76,6 +83,17 @@ config_setting( ], ) +config_setting( + name = "android-stlport", + values = { + "crosstool_top": "@androidndk//:toolchain-stlport", + }, + visibility = [ + # Public, but Protobuf only visibility. + "//:__subpackages__", + ], +) + config_setting( name = "android-libcpp", values = { @@ -98,11 +116,24 @@ config_setting( ], ) +config_setting( + name = "android-default", + values = { + "crosstool_top": "@androidndk//:default_crosstool", + }, + visibility = [ + # Public, but Protobuf only visibility. + "//:__subpackages__", + ], +) + # Android and MSVC builds do not need to link in a separate pthread library. LINK_OPTS = select({ ":android": [], + ":android-stlport": [], ":android-libcpp": [], ":android-gnu-libstdcpp": [], + ":android-default": [], ":msvc": [ # Suppress linker warnings about files with no symbols defined. "-ignore:4221",