Skip to content

Commit 0bce3a1

Browse files
achasveachashtuch
authored andcommitted
build: Support tags[] arg for more specific build control (envoyproxy#8233)
Support tags[] arg for more specific build control. Where the underlying bazel primitives support tags[], envoy_() should support them. Risk Level: Low Testing: Local on Windows and Linux CI Signed-off-by: Yechiel Kalmenson <[email protected]>
1 parent 3351107 commit 0bce3a1

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

api/bazel/api_build_system.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def api_proto_library(
105105
visibility = ["//visibility:private"],
106106
srcs = [],
107107
deps = [],
108+
tags = [],
108109
external_proto_deps = [],
109110
external_cc_proto_deps = [],
110111
external_py_proto_deps = [],
@@ -116,6 +117,7 @@ def api_proto_library(
116117
name = name,
117118
srcs = srcs,
118119
deps = deps + external_proto_deps + _COMMON_PROTO_DEPS,
120+
tags = tags,
119121
visibility = visibility,
120122
)
121123
cc_proto_library_name = _Suffix(name, _CC_SUFFIX)

bazel/envoy_binary.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def envoy_cc_binary(
1919
repository = "",
2020
stamped = False,
2121
deps = [],
22-
linkopts = []):
22+
linkopts = [],
23+
tags = []):
2324
if not linkopts:
2425
linkopts = _envoy_linkopts()
2526
if stamped:
@@ -38,6 +39,7 @@ def envoy_cc_binary(
3839
malloc = tcmalloc_external_dep(repository),
3940
stamp = 1,
4041
deps = deps,
42+
tags = tags,
4143
)
4244

4345
# Select the given values if exporting is enabled in the current build.

bazel/envoy_test.bzl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def envoy_cc_fuzz_test(
9393
repository + "//bazel:dynamic_stdlib",
9494
],
9595
repository = repository,
96+
tags = tags,
9697
**kwargs
9798
)
9899
native.cc_test(
@@ -155,21 +156,24 @@ def envoy_cc_test(
155156
coverage = True,
156157
local = False,
157158
size = "medium"):
158-
test_lib_tags = []
159159
if coverage:
160-
test_lib_tags.append("coverage_test_lib")
160+
coverage_tags = tags + ["coverage_test_lib"]
161+
else:
162+
coverage_tags = tags
161163
_envoy_cc_test_infrastructure_library(
162164
name = name + "_lib_internal_only",
163165
srcs = srcs,
164166
data = data,
165167
external_deps = external_deps,
166168
deps = deps + [repository + "//test/test_common:printers_includes"],
167169
repository = repository,
168-
tags = test_lib_tags,
170+
tags = coverage_tags,
169171
copts = copts,
170172
# Allow public visibility so these can be consumed in coverage tests in external projects.
171173
visibility = ["//visibility:public"],
172174
)
175+
if coverage:
176+
coverage_tags = tags + ["coverage_test"]
173177
native.cc_test(
174178
name = name,
175179
copts = envoy_copts(repository, test = True) + copts,
@@ -183,7 +187,7 @@ def envoy_cc_test(
183187
# from https://github.com/google/googletest/blob/6e1970e2376c14bf658eb88f655a054030353f9f/googlemock/src/gmock.cc#L51
184188
# 2 - by default, mocks act as StrictMocks.
185189
args = args + ["--gmock_default_mock_behavior=2"],
186-
tags = tags + ["coverage_test"],
190+
tags = coverage_tags,
187191
local = local,
188192
shard_count = shard_count,
189193
size = size,
@@ -254,6 +258,7 @@ def envoy_sh_test(
254258
srcs = [],
255259
data = [],
256260
coverage = True,
261+
tags = [],
257262
**kargs):
258263
if coverage:
259264
test_runner_cc = name + "_test_runner.cc"
@@ -268,13 +273,14 @@ def envoy_sh_test(
268273
name = name + "_lib",
269274
srcs = [test_runner_cc],
270275
data = srcs + data,
271-
tags = ["coverage_test_lib"],
276+
tags = tags + ["coverage_test_lib"],
272277
deps = ["//test/test_common:environment_lib"],
273278
)
274279
native.sh_test(
275280
name = name,
276281
srcs = ["//bazel:sh_test_wrapper.sh"],
277282
data = srcs + data,
278283
args = srcs,
284+
tags = tags,
279285
**kargs
280286
)

0 commit comments

Comments
 (0)