Skip to content

Commit a8038c2

Browse files
committed
Add Android stlport and default toolchains to BUILD.
These are additional possibilities for --crosstool_top for Android NDK compilation. Since the NDK doesn't have -lpthread, getting these flags wrong leads to a linker error. Fixes: 180084220
1 parent 45e9707 commit a8038c2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

BUILD

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ create_compiler_config_setting(
6969
],
7070
)
7171

72+
# Android NDK builds can specify different crosstool_top flags to choose which
73+
# STL they use for C++. We need these multiple variants to catch all of those
74+
# versions of crosstool_top and reliably detect Android.
75+
#
76+
# For more info on the various crosstool_tops used by NDK Bazel builds, see:
77+
# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl
78+
7279
config_setting(
7380
name = "android",
7481
values = {
@@ -80,6 +87,17 @@ config_setting(
8087
],
8188
)
8289

90+
config_setting(
91+
name = "android-stlport",
92+
values = {
93+
"crosstool_top": "@androidndk//:toolchain-stlport",
94+
},
95+
visibility = [
96+
# Public, but Protobuf only visibility.
97+
"//:__subpackages__",
98+
],
99+
)
100+
83101
config_setting(
84102
name = "android-libcpp",
85103
values = {
@@ -102,11 +120,24 @@ config_setting(
102120
],
103121
)
104122

123+
config_setting(
124+
name = "android-default",
125+
values = {
126+
"crosstool_top": "@androidndk//:default_crosstool",
127+
},
128+
visibility = [
129+
# Public, but Protobuf only visibility.
130+
"//:__subpackages__",
131+
],
132+
)
133+
105134
# Android and MSVC builds do not need to link in a separate pthread library.
106135
LINK_OPTS = select({
107136
":android": [],
137+
":android-stlport": [],
108138
":android-libcpp": [],
109139
":android-gnu-libstdcpp": [],
140+
":android-default": [],
110141
":msvc": [
111142
# Suppress linker warnings about files with no symbols defined.
112143
"-ignore:4221",

0 commit comments

Comments
 (0)