forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvoy_internal.bzl
135 lines (125 loc) · 5.9 KB
/
envoy_internal.bzl
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
# DO NOT LOAD THIS FILE. Targets from this file should be considered private
# and not used outside of the @envoy//bazel package.
load(":envoy_select.bzl", "envoy_select_google_grpc", "envoy_select_hot_restart")
# Compute the final copts based on various options.
def envoy_copts(repository, test = False):
posix_options = [
"-Wall",
"-Wextra",
"-Werror",
"-Wnon-virtual-dtor",
"-Woverloaded-virtual",
"-Wold-style-cast",
"-Wformat",
"-Wformat-security",
"-Wvla",
]
# Windows options for cleanest service compilation;
# General MSVC C++ options for Envoy current expectations.
# Target windows.h for all Windows 10 (0x0A) API prototypes (ntohll etc)
# (See https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx )
# Optimize Windows headers by dropping GUI-oriented features from compilation
msvc_options = [
"-WX",
"-Zc:__cplusplus",
"-DWIN32",
"-D_WIN32_WINNT=0x0A00", # _WIN32_WINNT_WIN10
"-DNTDDI_VERSION=0x0A000000", # NTDDI_WIN10
"-DWIN32_LEAN_AND_MEAN",
"-DNOUSER",
"-DNOMCX",
"-DNOIME",
"-DNOCRYPT",
# Ignore unguarded gcc pragmas in quiche (unrecognized by MSVC)
# TODO(wrowe): Drop this change when fixed in bazel/external/quiche.genrule_cmd
"-wd4068",
# this is to silence the incorrect MSVC compiler warning when trying to convert between
# std::optional data types while conversions between primitive types are producing no error
"-wd4244",
]
return select({
repository + "//bazel:windows_x86_64": msvc_options,
"//conditions:default": posix_options,
}) + select({
# Bazel adds an implicit -DNDEBUG for opt.
repository + "//bazel:opt_build": [] if test else ["-ggdb3", "-gsplit-dwarf"],
repository + "//bazel:fastbuild_build": [],
repository + "//bazel:dbg_build": ["-ggdb3", "-gsplit-dwarf"],
repository + "//bazel:windows_opt_build": [],
repository + "//bazel:windows_fastbuild_build": [],
repository + "//bazel:windows_dbg_build": [],
}) + select({
repository + "//bazel:clang_build": ["-fno-limit-debug-info", "-Wgnu-conditional-omitted-operand", "-Wc++2a-extensions"],
repository + "//bazel:gcc_build": ["-Wno-maybe-uninitialized"],
"//conditions:default": [],
}) + select({
repository + "//bazel:no_debug_info": ["-g0"],
"//conditions:default": [],
}) + select({
repository + "//bazel:disable_tcmalloc": ["-DABSL_MALLOC_HOOK_MMAP_DISABLE"],
"//conditions:default": ["-DTCMALLOC"],
}) + select({
repository + "//bazel:debug_tcmalloc": ["-DENVOY_MEMORY_DEBUG_ENABLED=1"],
"//conditions:default": [],
}) + select({
repository + "//bazel:disable_signal_trace": [],
"//conditions:default": ["-DENVOY_HANDLE_SIGNALS"],
}) + select({
repository + "//bazel:disable_object_dump_on_signal_trace": [],
"//conditions:default": ["-DENVOY_OBJECT_TRACE_ON_DUMP"],
}) + select({
repository + "//bazel:disable_deprecated_features": ["-DENVOY_DISABLE_DEPRECATED_FEATURES"],
"//conditions:default": [],
}) + select({
repository + "//bazel:enable_log_debug_assert_in_release": ["-DENVOY_LOG_DEBUG_ASSERT_IN_RELEASE"],
"//conditions:default": [],
}) + select({
repository + "//bazel:disable_known_issue_asserts": ["-DENVOY_DISABLE_KNOWN_ISSUE_ASSERTS"],
"//conditions:default": [],
}) + select({
# APPLE_USE_RFC_3542 is needed to support IPV6_PKTINFO in MAC OS.
repository + "//bazel:apple": ["-D__APPLE_USE_RFC_3542"],
"//conditions:default": [],
}) + envoy_select_hot_restart(["-DENVOY_HOT_RESTART"], repository) + \
_envoy_select_perf_annotation(["-DENVOY_PERF_ANNOTATION"]) + \
envoy_select_google_grpc(["-DENVOY_GOOGLE_GRPC"], repository) + \
_envoy_select_path_normalization_by_default(["-DENVOY_NORMALIZE_PATH_BY_DEFAULT"], repository)
# References to Envoy external dependencies should be wrapped with this function.
def envoy_external_dep_path(dep):
return "//external:%s" % dep
def envoy_linkstatic():
return select({
"@envoy//bazel:dynamic_link_tests": 0,
"//conditions:default": 1,
})
def envoy_select_force_libcpp(if_libcpp, default = None):
return select({
"@envoy//bazel:force_libcpp": if_libcpp,
"@envoy//bazel:apple": [],
"@envoy//bazel:windows_x86_64": [],
"//conditions:default": default or [],
})
def envoy_stdlib_deps():
return select({
"@envoy//bazel:asan_build": ["@envoy//bazel:dynamic_stdlib"],
"@envoy//bazel:msan_build": ["@envoy//bazel:dynamic_stdlib"],
"@envoy//bazel:tsan_build": ["@envoy//bazel:dynamic_stdlib"],
"//conditions:default": ["@envoy//bazel:static_stdlib"],
})
# Dependencies on tcmalloc_and_profiler should be wrapped with this function.
def tcmalloc_external_dep(repository):
return select({
repository + "//bazel:disable_tcmalloc": None,
"//conditions:default": envoy_external_dep_path("gperftools"),
})
# Select the given values if default path normalization is on in the current build.
def _envoy_select_path_normalization_by_default(xs, repository = ""):
return select({
repository + "//bazel:enable_path_normalization_by_default": xs,
"//conditions:default": [],
})
def _envoy_select_perf_annotation(xs):
return select({
"@envoy//bazel:enable_perf_annotation": xs,
"//conditions:default": [],
})