@@ -5,19 +5,39 @@ def envoy_package():
55
66# Compute the final copts based on various options.
77def envoy_copts (repository , test = False ):
8- return [
9- "-Wall" ,
10- "-Wextra" ,
11- "-Werror" ,
12- "-Wnon-virtual-dtor" ,
13- "-Woverloaded-virtual" ,
14- "-Wold-style-cast" ,
15- "-std=c++14" ,
16- ] + select ({
8+ posix_options = [
9+ "-Wall" ,
10+ "-Wextra" ,
11+ "-Werror" ,
12+ "-Wnon-virtual-dtor" ,
13+ "-Woverloaded-virtual" ,
14+ "-Wold-style-cast" ,
15+ "-std=c++14" ,
16+ ]
17+
18+ msvc_options = [
19+ "-WX" ,
20+ "-DWIN32" ,
21+ "-DWIN32_LEAN_AND_MEAN" ,
22+ # need win8 for ntohll
23+ # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
24+ "-D_WIN32_WINNT=0x0602" ,
25+ "-DNTDDI_VERSION=0x06020000" ,
26+ "-DCARES_STATICLIB" ,
27+ "-DNGHTTP2_STATICLIB" ,
28+ ]
29+
30+ return select ({
31+ "//bazel:windows_x86_64" : msvc_options ,
32+ "//conditions:default" : posix_options ,
33+ }) + select ({
1734 # Bazel adds an implicit -DNDEBUG for opt.
1835 repository + "//bazel:opt_build" : [] if test else ["-ggdb3" ],
1936 repository + "//bazel:fastbuild_build" : [],
2037 repository + "//bazel:dbg_build" : ["-ggdb3" ],
38+ repository + "//bazel:windows_opt_build" : [],
39+ repository + "//bazel:windows_fastbuild_build" : [],
40+ repository + "//bazel:windows_dbg_build" : [],
2141 }) + select ({
2242 repository + "//bazel:disable_tcmalloc" : ["-DABSL_MALLOC_HOOK_MMAP_DISABLE" ],
2343 "//conditions:default" : ["-DTCMALLOC" ],
@@ -47,6 +67,9 @@ def envoy_linkopts():
4767 "-pagezero_size 10000" ,
4868 "-image_base 100000000" ,
4969 ],
70+ "//bazel:windows_x86_64" : [
71+ "-DEFAULTLIB:advapi32.lib" ,
72+ ],
5073 "//conditions:default" : [
5174 "-pthread" ,
5275 "-lrt" ,
@@ -62,6 +85,7 @@ def _envoy_stamped_linkopts():
6285 #
6386 # /usr/bin/ld.gold: internal error in write_build_id, at ../../gold/layout.cc:5419
6487 "@envoy//bazel:coverage_build" : [],
88+ "//bazel:windows_x86_64" : [],
6589
6690 # MacOS doesn't have an official equivalent to the `.note.gnu.build-id`
6791 # ELF section, so just stuff the raw ID into a new text section.
@@ -120,6 +144,13 @@ def tcmalloc_external_deps(repository):
120144 "//conditions:default" : [envoy_external_dep_path ("tcmalloc_and_profiler" )],
121145 })
122146
147+ # Dependencies on libevent should be wrapped with this function.
148+ def libevent_external_deps (repository ):
149+ return [envoy_external_dep_path ("event" )] + select ({
150+ repository + "//bazel:windows_x86_64" : [],
151+ "//conditions:default" : [envoy_external_dep_path ("event_pthreads" )],
152+ })
153+
123154# Transform the package path (e.g. include/envoy/common) into a path for
124155# exporting the package headers at (e.g. envoy/common). Source files can then
125156# include using this path scheme (e.g. #include "envoy/common/time.h").
@@ -144,13 +175,17 @@ def envoy_cc_library(
144175 visibility = None ,
145176 external_deps = [],
146177 tcmalloc_dep = None ,
178+ libevent_dep = None ,
147179 repository = "" ,
148180 linkstamp = None ,
149181 tags = [],
150182 deps = [],
151183 strip_include_prefix = None ):
152184 if tcmalloc_dep :
153185 deps += tcmalloc_external_deps (repository )
186+ if libevent_dep :
187+ deps += libevent_external_deps (repository )
188+
154189 native .cc_library (
155190 name = name ,
156191 srcs = srcs ,
@@ -168,7 +203,10 @@ def envoy_cc_library(
168203 include_prefix = envoy_include_prefix (PACKAGE_NAME ),
169204 alwayslink = 1 ,
170205 linkstatic = 1 ,
171- linkstamp = linkstamp ,
206+ linkstamp = select ({
207+ repository + "//bazel:windows_x86_64" : None ,
208+ "//conditions:default" : linkstamp ,
209+ }),
172210 strip_include_prefix = strip_include_prefix ,
173211 )
174212
@@ -481,5 +519,6 @@ def envoy_select_force_libcpp(if_libcpp, default = None):
481519 return select ({
482520 "@envoy//bazel:force_libcpp" : if_libcpp ,
483521 "@bazel_tools//tools/osx:darwin" : [],
522+ "//bazel:windows_x86_64" : [],
484523 "//conditions:default" : default or [],
485524 })
0 commit comments