/
BUILD
256 lines (241 loc) · 8.79 KB
/
BUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:envoy_build_system.bzl", "envoy_cmake_external", "envoy_package")
load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")
licenses(["notice"]) # Apache 2
envoy_package()
# autotools packages are unusable on Windows as-is
# TODO: Consider our own gperftools.BUILD file as we do with many other packages
configure_make(
name = "gperftools_build",
configure_options = [
"--enable-shared=no",
"--enable-frame-pointers",
"--disable-libunwind",
] + select({
"//bazel:apple": ["AR=/usr/bin/ar"],
"//conditions:default": [],
}),
lib_source = "@com_github_gperftools_gperftools//:all",
linkopts = ["-lpthread"],
make_commands = ["make install-libLTLIBRARIES install-perftoolsincludeHEADERS"],
static_libraries = select({
"//bazel:debug_tcmalloc": ["libtcmalloc_debug.a"],
"//conditions:default": ["libtcmalloc_and_profiler.a"],
}),
tags = ["skip_on_windows"],
)
# Workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/227
cc_library(
name = "gperftools",
tags = ["skip_on_windows"],
deps = [
"gperftools_build",
],
)
configure_make(
name = "luajit",
configure_command = "build.py",
configure_env_vars = select({
# This shouldn't be needed! See
# https://github.com/envoyproxy/envoy/issues/6084
# TODO(htuch): Remove when #6084 is fixed
"//bazel:asan_build": {"ENVOY_CONFIG_ASAN": "1"},
"//bazel:msan_build": {"ENVOY_CONFIG_MSAN": "1"},
"//bazel:windows_dbg_build": {"WINDOWS_DBG_BUILD": "debug"},
"//conditions:default": {},
}),
lib_source = "@com_github_luajit_luajit//:all",
make_commands = [],
out_include_dir = "include/luajit-2.1",
static_libraries = select({
"//bazel:windows_x86_64": ["lua51.lib"],
"//conditions:default": ["libluajit-5.1.a"],
}),
)
configure_make(
name = "moonjit",
configure_command = "build.py",
configure_env_vars = select({
# This shouldn't be needed! See
# https://github.com/envoyproxy/envoy/issues/6084
# TODO(htuch): Remove when #6084 is fixed
"//bazel:asan_build": {"ENVOY_CONFIG_ASAN": "1"},
"//bazel:msan_build": {"ENVOY_CONFIG_MSAN": "1"},
"//bazel:windows_dbg_build": {"WINDOWS_DBG_BUILD": "debug"},
"//conditions:default": {},
}),
lib_source = "@com_github_moonjit_moonjit//:all",
make_commands = [],
out_include_dir = "include/moonjit-2.2",
static_libraries = select({
"//bazel:windows_x86_64": ["lua51.lib"],
"//conditions:default": ["libluajit-5.1.a"],
}),
)
envoy_cmake_external(
name = "ares",
cache_entries = {
"CARES_SHARED": "no",
"CARES_STATIC": "on",
"CMAKE_CXX_COMPILER_FORCED": "on",
"CMAKE_INSTALL_LIBDIR": "lib",
},
defines = ["CARES_STATICLIB"],
lib_source = "@com_github_c_ares_c_ares//:all",
linkopts = select({
"//bazel:apple": ["-lresolv"],
"//conditions:default": [],
}),
postfix_script = select({
"//bazel:windows_x86_64": "cp -L $EXT_BUILD_ROOT/external/com_github_c_ares_c_ares/nameser.h $INSTALLDIR/include/nameser.h",
"//conditions:default": "",
}),
static_libraries = select({
"//bazel:windows_x86_64": ["cares.lib"],
"//conditions:default": ["libcares.a"],
}),
)
envoy_cmake_external(
name = "curl",
cache_entries = {
"BUILD_CURL_EXE": "off",
"BUILD_TESTING": "off",
"BUILD_SHARED_LIBS": "off",
"CURL_HIDDEN_SYMBOLS": "off",
"CMAKE_USE_LIBSSH2": "off",
"CURL_BROTLI": "off",
"CMAKE_USE_GSSAPI": "off",
"HTTP_ONLY": "on",
"CMAKE_INSTALL_LIBDIR": "lib",
# Explicitly enable Unix sockets, once afunix.h is correctly detected
# "USE_UNIX_SOCKETS": "on",
# Explicitly disable "Windows" crypto for Windows
"CURL_DISABLE_CRYPTO_AUTH": "on",
# C-Ares.
"ENABLE_ARES": "on",
"CARES_LIBRARY": "$EXT_BUILD_DEPS/ares",
"CARES_INCLUDE_DIR": "$EXT_BUILD_DEPS/ares/include",
# SSL (via Envoy's SSL dependency) is disabled, curl's CMake uses
# FindOpenSSL.cmake which fails at what looks like version parsing
# (the libraries are found ok).
"CURL_CA_PATH": "none",
"CMAKE_USE_OPENSSL": "off",
"OPENSSL_ROOT_DIR": "$EXT_BUILD_DEPS",
# NGHTTP2.
"USE_NGHTTP2": "on",
"NGHTTP2_LIBRARY": "$EXT_BUILD_DEPS/nghttp2",
"NGHTTP2_INCLUDE_DIR": "$EXT_BUILD_DEPS/nghttp2/include",
# ZLIB.
"CURL_ZLIB": "on",
"ZLIB_LIBRARY": "$EXT_BUILD_DEPS/zlib",
"ZLIB_INCLUDE_DIR": "$EXT_BUILD_DEPS/zlib/include",
"CMAKE_CXX_COMPILER_FORCED": "on",
"CMAKE_C_FLAGS_BAZEL": "-fPIC",
# Note we use Bazel's flags (not _RELEASE/_DEBUG CMake flags), but this toggle
# also works around a bug in CMP0091 logic which re-injected a badly placed -M flag.
# See https://github.com/bazelbuild/rules_foreign_cc/issues/426
"CURL_STATIC_CRT": "on",
},
defines = ["CURL_STATICLIB"],
generate_crosstool_file = True,
lib_source = "@com_github_curl//:all",
static_libraries = select({
"//bazel:windows_x86_64": ["libcurl.lib"],
"//conditions:default": ["libcurl.a"],
}),
deps = [
":ares",
":nghttp2",
":zlib",
"//external:ssl",
],
)
envoy_cmake_external(
name = "event",
cache_entries = {
"EVENT__DISABLE_OPENSSL": "on",
"EVENT__DISABLE_MBEDTLS": "on",
"EVENT__DISABLE_REGRESS": "on",
"EVENT__DISABLE_TESTS": "on",
"EVENT__LIBRARY_TYPE": "STATIC",
# Force _GNU_SOURCE on for Android builds. This would be contained in
# a 'select' but the downstream macro uses a select on all of these
# options, and they cannot be nested.
# If https://github.com/bazelbuild/rules_foreign_cc/issues/289 is fixed
# this can be removed.
# More details https://github.com/lyft/envoy-mobile/issues/116
"_GNU_SOURCE": "on",
},
lib_source = "@com_github_libevent_libevent//:all",
static_libraries = select({
# macOS organization of libevent is different from Windows/Linux.
# Including libevent_core is a requirement on those platforms, but
# results in duplicate symbols when built on macOS.
# See https://github.com/lyft/envoy-mobile/issues/677 for details.
"//bazel:apple": [
"libevent.a",
"libevent_pthreads.a",
],
"//bazel:windows_x86_64": [
"event.lib",
"event_core.lib",
],
"//conditions:default": [
"libevent.a",
"libevent_pthreads.a",
"libevent_core.a",
],
}),
)
envoy_cmake_external(
name = "nghttp2",
cache_entries = {
"ENABLE_LIB_ONLY": "on",
"ENABLE_SHARED_LIB": "off",
"ENABLE_STATIC_LIB": "on",
"CMAKE_INSTALL_LIBDIR": "lib",
"CMAKE_CXX_COMPILER_FORCED": "on",
},
cmake_files_dir = "$BUILD_TMPDIR/lib/CMakeFiles",
debug_cache_entries = {"ENABLE_DEBUG": "on"},
defines = ["NGHTTP2_STATICLIB"],
lib_source = "@com_github_nghttp2_nghttp2//:all",
static_libraries = select({
"//bazel:windows_x86_64": ["nghttp2.lib"],
"//conditions:default": ["libnghttp2.a"],
}),
)
envoy_cmake_external(
name = "zlib",
cache_entries = {
"BUILD_SHARED_LIBS": "off",
"CMAKE_CXX_COMPILER_FORCED": "on",
"CMAKE_C_COMPILER_FORCED": "on",
"SKIP_BUILD_EXAMPLES": "on",
# The following entries are for zlib-ng. Since zlib and zlib-ng are compatible source
# codes and CMake ignores unknown cache entries, it is fine to combine it into one
# dictionary.
#
# Reference: https://github.com/zlib-ng/zlib-ng#build-options.
"ZLIB_COMPAT": "on",
"ZLIB_ENABLE_TESTS": "off",
# Warning: Turning WITH_OPTIM to "on" doesn't pass ZlibCompressorImplTest.CallingChecksum.
"WITH_OPTIM": "on",
# However turning off SSE4 fixes it.
"WITH_SSE4": "off",
# Warning: Turning WITH_NEW_STRATEGIES to "on" doesn't pass gzip compressor fuzz test.
# Turning this off means falling into NO_QUICK_STRATEGY route.
"WITH_NEW_STRATEGIES": "off",
# Only allow aligned address.
# Reference: https://github.com/zlib-ng/zlib-ng#advanced-build-options.
"UNALIGNED_OK": "off",
},
lib_source = select({
"//bazel:zlib_ng": "@com_github_zlib_ng_zlib_ng//:all",
"//conditions:default": "@net_zlib//:all",
}),
static_libraries = select({
"//bazel:windows_x86_64": ["zlibstatic.lib"],
"//conditions:default": ["libz.a"],
}),
)