Skip to content

Commit 3493c89

Browse files
committed
Propagate target_compatible_with to generated targets
1 parent ad31d13 commit 3493c89

3 files changed

Lines changed: 31 additions & 5 deletions

File tree

docs/cc-fuzzing-rules.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Provider for storing the language-independent part of the specification of a fuz
5858
<pre>
5959
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test")
6060

61-
cc_fuzz_test(<a href="#cc_fuzz_test-name">name</a>, <a href="#cc_fuzz_test-corpus">corpus</a>, <a href="#cc_fuzz_test-dicts">dicts</a>, <a href="#cc_fuzz_test-engine">engine</a>, <a href="#cc_fuzz_test-size">size</a>, <a href="#cc_fuzz_test-tags">tags</a>, <a href="#cc_fuzz_test-timeout">timeout</a>, <a href="#cc_fuzz_test-binary_kwargs">**binary_kwargs</a>)
61+
cc_fuzz_test(<a href="#cc_fuzz_test-name">name</a>, <a href="#cc_fuzz_test-corpus">corpus</a>, <a href="#cc_fuzz_test-dicts">dicts</a>, <a href="#cc_fuzz_test-engine">engine</a>, <a href="#cc_fuzz_test-size">size</a>, <a href="#cc_fuzz_test-tags">tags</a>, <a href="#cc_fuzz_test-target_compatible_with">target_compatible_with</a>, <a href="#cc_fuzz_test-timeout">timeout</a>,
62+
<a href="#cc_fuzz_test-binary_kwargs">**binary_kwargs</a>)
6263
</pre>
6364

6465
Defines a C++ fuzz test and a few associated tools and metadata.
@@ -92,6 +93,7 @@ most relevant ones are:
9293
| <a id="cc_fuzz_test-engine"></a>engine | A label pointing to the fuzzing engine to use. | `Label("@rules_fuzzing//fuzzing:cc_engine")` |
9394
| <a id="cc_fuzz_test-size"></a>size | The size of the regression test. This does *not* affect fuzzing itself. Takes the [common size values](https://bazel.build/reference/be/common-definitions#test.size). | `None` |
9495
| <a id="cc_fuzz_test-tags"></a>tags | Tags set on the generated targets. | `None` |
96+
| <a id="cc_fuzz_test-target_compatible_with"></a>target_compatible_with | Platform constraints set on the generated targets. | `None` |
9597
| <a id="cc_fuzz_test-timeout"></a>timeout | The timeout for the regression test. This does *not* affect fuzzing itself. Takes the [common timeout values](https://docs.bazel.build/versions/main/be/common-definitions.html#test.timeout). | `None` |
9698
| <a id="cc_fuzz_test-binary_kwargs"></a>binary_kwargs | Keyword arguments directly forwarded to the fuzz test binary rule. | none |
9799

@@ -104,7 +106,8 @@ most relevant ones are:
104106
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "fuzzing_decoration")
105107

106108
fuzzing_decoration(<a href="#fuzzing_decoration-name">name</a>, <a href="#fuzzing_decoration-raw_binary">raw_binary</a>, <a href="#fuzzing_decoration-engine">engine</a>, <a href="#fuzzing_decoration-corpus">corpus</a>, <a href="#fuzzing_decoration-dicts">dicts</a>, <a href="#fuzzing_decoration-instrument_binary">instrument_binary</a>,
107-
<a href="#fuzzing_decoration-define_regression_test">define_regression_test</a>, <a href="#fuzzing_decoration-tags">tags</a>, <a href="#fuzzing_decoration-test_size">test_size</a>, <a href="#fuzzing_decoration-test_tags">test_tags</a>, <a href="#fuzzing_decoration-test_timeout">test_timeout</a>)
109+
<a href="#fuzzing_decoration-define_regression_test">define_regression_test</a>, <a href="#fuzzing_decoration-tags">tags</a>, <a href="#fuzzing_decoration-target_compatible_with">target_compatible_with</a>, <a href="#fuzzing_decoration-test_size">test_size</a>, <a href="#fuzzing_decoration-test_tags">test_tags</a>,
110+
<a href="#fuzzing_decoration-test_timeout">test_timeout</a>)
108111
</pre>
109112

110113
Generates the standard targets associated to a fuzz test.
@@ -127,6 +130,7 @@ documentation for the set of targets generated.
127130
| <a id="fuzzing_decoration-instrument_binary"></a>instrument_binary | **(Experimental, may be removed in the future.)**<br><br>By default, the generated targets depend on `raw_binary` through a Bazel configuration using flags from the `@rules_fuzzing//fuzzing` package to determine the fuzzing build mode, engine, and sanitizer instrumentation.<br><br>When this argument is false, the targets assume that `raw_binary` is already built in the proper configuration and will not apply the transition.<br><br>Most users should not need to change this argument. If you think the default instrumentation mode does not work for your use case, please file a Github issue to discuss. | `True` |
128131
| <a id="fuzzing_decoration-define_regression_test"></a>define_regression_test | If true, generate a regression test rule. | `True` |
129132
| <a id="fuzzing_decoration-tags"></a>tags | Additional tags set on non-test targets. | `None` |
133+
| <a id="fuzzing_decoration-target_compatible_with"></a>target_compatible_with | Platform constraints set on the generated targets. | `None` |
130134
| <a id="fuzzing_decoration-test_size"></a>test_size | The size of the fuzzing regression test. | `None` |
131135
| <a id="fuzzing_decoration-test_tags"></a>test_tags | Tags set on the fuzzing regression test. | `None` |
132136
| <a id="fuzzing_decoration-test_timeout"></a>test_timeout | The timeout for the fuzzing regression test. | `None` |

docs/java-fuzzing-rules.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ Provider for storing the language-independent part of the specification of a fuz
5959
load("@rules_fuzzing//fuzzing:java_defs.bzl", "fuzzing_decoration")
6060

6161
fuzzing_decoration(<a href="#fuzzing_decoration-name">name</a>, <a href="#fuzzing_decoration-raw_binary">raw_binary</a>, <a href="#fuzzing_decoration-engine">engine</a>, <a href="#fuzzing_decoration-corpus">corpus</a>, <a href="#fuzzing_decoration-dicts">dicts</a>, <a href="#fuzzing_decoration-instrument_binary">instrument_binary</a>,
62-
<a href="#fuzzing_decoration-define_regression_test">define_regression_test</a>, <a href="#fuzzing_decoration-tags">tags</a>, <a href="#fuzzing_decoration-test_size">test_size</a>, <a href="#fuzzing_decoration-test_tags">test_tags</a>, <a href="#fuzzing_decoration-test_timeout">test_timeout</a>)
62+
<a href="#fuzzing_decoration-define_regression_test">define_regression_test</a>, <a href="#fuzzing_decoration-tags">tags</a>, <a href="#fuzzing_decoration-target_compatible_with">target_compatible_with</a>, <a href="#fuzzing_decoration-test_size">test_size</a>, <a href="#fuzzing_decoration-test_tags">test_tags</a>,
63+
<a href="#fuzzing_decoration-test_timeout">test_timeout</a>)
6364
</pre>
6465

6566
Generates the standard targets associated to a fuzz test.
@@ -82,6 +83,7 @@ documentation for the set of targets generated.
8283
| <a id="fuzzing_decoration-instrument_binary"></a>instrument_binary | **(Experimental, may be removed in the future.)**<br><br>By default, the generated targets depend on `raw_binary` through a Bazel configuration using flags from the `@rules_fuzzing//fuzzing` package to determine the fuzzing build mode, engine, and sanitizer instrumentation.<br><br>When this argument is false, the targets assume that `raw_binary` is already built in the proper configuration and will not apply the transition.<br><br>Most users should not need to change this argument. If you think the default instrumentation mode does not work for your use case, please file a Github issue to discuss. | `True` |
8384
| <a id="fuzzing_decoration-define_regression_test"></a>define_regression_test | If true, generate a regression test rule. | `True` |
8485
| <a id="fuzzing_decoration-tags"></a>tags | Additional tags set on non-test targets. | `None` |
86+
| <a id="fuzzing_decoration-target_compatible_with"></a>target_compatible_with | Platform constraints set on the generated targets. | `None` |
8587
| <a id="fuzzing_decoration-test_size"></a>test_size | The size of the fuzzing regression test. | `None` |
8688
| <a id="fuzzing_decoration-test_tags"></a>test_tags | Tags set on the fuzzing regression test. | `None` |
8789
| <a id="fuzzing_decoration-test_timeout"></a>test_timeout | The timeout for the fuzzing regression test. | `None` |
@@ -94,8 +96,8 @@ documentation for the set of targets generated.
9496
<pre>
9597
load("@rules_fuzzing//fuzzing:java_defs.bzl", "java_fuzz_test")
9698

97-
java_fuzz_test(<a href="#java_fuzz_test-name">name</a>, <a href="#java_fuzz_test-srcs">srcs</a>, <a href="#java_fuzz_test-target_class">target_class</a>, <a href="#java_fuzz_test-corpus">corpus</a>, <a href="#java_fuzz_test-dicts">dicts</a>, <a href="#java_fuzz_test-engine">engine</a>, <a href="#java_fuzz_test-size">size</a>, <a href="#java_fuzz_test-tags">tags</a>, <a href="#java_fuzz_test-timeout">timeout</a>,
98-
<a href="#java_fuzz_test-binary_kwargs">**binary_kwargs</a>)
99+
java_fuzz_test(<a href="#java_fuzz_test-name">name</a>, <a href="#java_fuzz_test-srcs">srcs</a>, <a href="#java_fuzz_test-target_class">target_class</a>, <a href="#java_fuzz_test-corpus">corpus</a>, <a href="#java_fuzz_test-dicts">dicts</a>, <a href="#java_fuzz_test-engine">engine</a>, <a href="#java_fuzz_test-size">size</a>, <a href="#java_fuzz_test-tags">tags</a>, <a href="#java_fuzz_test-target_compatible_with">target_compatible_with</a>,
100+
<a href="#java_fuzz_test-timeout">timeout</a>, <a href="#java_fuzz_test-binary_kwargs">**binary_kwargs</a>)
99101
</pre>
100102

101103
Defines a Java fuzz test and a few associated tools and metadata.
@@ -131,6 +133,7 @@ most relevant ones are:
131133
| <a id="java_fuzz_test-engine"></a>engine | A label pointing to the fuzzing engine to use. | `Label("@rules_fuzzing//fuzzing:java_engine")` |
132134
| <a id="java_fuzz_test-size"></a>size | The size of the regression test. This does *not* affect fuzzing itself. Takes the [common size values](https://bazel.build/reference/be/common-definitions#test.size). | `None` |
133135
| <a id="java_fuzz_test-tags"></a>tags | Tags set on the generated targets. | `None` |
136+
| <a id="java_fuzz_test-target_compatible_with"></a>target_compatible_with | Platform constraints set on the generated targets. | `None` |
134137
| <a id="java_fuzz_test-timeout"></a>timeout | The timeout for the regression test. This does *not* affect fuzzing itself. Takes the [common timeout values](https://docs.bazel.build/versions/main/be/common-definitions.html#test.timeout). | `None` |
135138
| <a id="java_fuzz_test-binary_kwargs"></a>binary_kwargs | Keyword arguments directly forwarded to the fuzz test binary rule. | none |
136139

fuzzing/private/fuzz_test.bzl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def fuzzing_decoration(
3232
instrument_binary = True,
3333
define_regression_test = True,
3434
tags = None,
35+
target_compatible_with = None,
3536
test_size = None,
3637
test_tags = None,
3738
test_timeout = None):
@@ -65,6 +66,7 @@ def fuzzing_decoration(
6566
file a Github issue to discuss.
6667
define_regression_test: If true, generate a regression test rule.
6768
tags: Additional tags set on non-test targets.
69+
target_compatible_with: Platform constraints set on the generated targets.
6870
test_size: The size of the fuzzing regression test.
6971
test_tags: Tags set on the fuzzing regression test.
7072
test_timeout: The timeout for the fuzzing regression test.
@@ -91,6 +93,7 @@ def fuzzing_decoration(
9193
dictionary = dict_name if dicts else None,
9294
testonly = True,
9395
tags = tags,
96+
target_compatible_with = target_compatible_with,
9497
)
9598
else:
9699
fuzzing_binary_uninstrumented(
@@ -101,13 +104,15 @@ def fuzzing_decoration(
101104
dictionary = dict_name if dicts else None,
102105
testonly = True,
103106
tags = tags,
107+
target_compatible_with = target_compatible_with,
104108
)
105109

106110
fuzzing_corpus(
107111
name = corpus_name,
108112
srcs = corpus,
109113
testonly = True,
110114
tags = tags,
115+
target_compatible_with = target_compatible_with,
111116
)
112117

113118
if dicts:
@@ -117,13 +122,15 @@ def fuzzing_decoration(
117122
output = name + ".dict",
118123
testonly = True,
119124
tags = tags,
125+
target_compatible_with = target_compatible_with,
120126
)
121127

122128
fuzzing_launcher(
123129
name = launcher_name,
124130
binary = instrum_binary_name,
125131
testonly = True,
126132
tags = tags,
133+
target_compatible_with = target_compatible_with,
127134
)
128135

129136
if define_regression_test:
@@ -133,6 +140,7 @@ def fuzzing_decoration(
133140
size = test_size,
134141
tags = test_tags,
135142
timeout = test_timeout,
143+
target_compatible_with = target_compatible_with,
136144
)
137145

138146
oss_fuzz_package(
@@ -141,6 +149,7 @@ def fuzzing_decoration(
141149
binary = instrum_binary_name,
142150
testonly = True,
143151
tags = tags,
152+
target_compatible_with = target_compatible_with,
144153
)
145154

146155
def cc_fuzz_test(
@@ -150,6 +159,7 @@ def cc_fuzz_test(
150159
engine = Label("//fuzzing:cc_engine"),
151160
size = None,
152161
tags = None,
162+
target_compatible_with = None,
153163
timeout = None,
154164
**binary_kwargs):
155165
"""Defines a C++ fuzz test and a few associated tools and metadata.
@@ -179,6 +189,7 @@ def cc_fuzz_test(
179189
size: The size of the regression test. This does *not* affect fuzzing
180190
itself. Takes the [common size values](https://bazel.build/reference/be/common-definitions#test.size).
181191
tags: Tags set on the generated targets.
192+
target_compatible_with: Platform constraints set on the generated targets.
182193
timeout: The timeout for the regression test. This does *not* affect
183194
fuzzing itself. Takes the [common timeout values](https://docs.bazel.build/versions/main/be/common-definitions.html#test.timeout).
184195
**binary_kwargs: Keyword arguments directly forwarded to the fuzz test
@@ -200,6 +211,7 @@ def cc_fuzz_test(
200211
cc_binary(
201212
name = raw_binary_name,
202213
tags = (tags or []) + ["manual"],
214+
target_compatible_with = target_compatible_with,
203215
**binary_kwargs
204216
)
205217

@@ -210,6 +222,7 @@ def cc_fuzz_test(
210222
corpus = corpus,
211223
dicts = dicts,
212224
tags = tags,
225+
target_compatible_with = target_compatible_with,
213226
test_size = size,
214227
test_tags = (tags or []) + [
215228
"fuzz-test",
@@ -235,6 +248,7 @@ def java_fuzz_test(
235248
engine = Label("//fuzzing:java_engine"),
236249
size = None,
237250
tags = None,
251+
target_compatible_with = None,
238252
timeout = None,
239253
**binary_kwargs):
240254
"""Defines a Java fuzz test and a few associated tools and metadata.
@@ -267,6 +281,7 @@ def java_fuzz_test(
267281
size: The size of the regression test. This does *not* affect fuzzing
268282
itself. Takes the [common size values](https://bazel.build/reference/be/common-definitions#test.size).
269283
tags: Tags set on the generated targets.
284+
target_compatible_with: Platform constraints set on the generated targets.
270285
timeout: The timeout for the regression test. This does *not* affect
271286
fuzzing itself. Takes the [common timeout values](https://docs.bazel.build/versions/main/be/common-definitions.html#test.timeout).
272287
**binary_kwargs: Keyword arguments directly forwarded to the fuzz test
@@ -297,6 +312,7 @@ def java_fuzz_test(
297312
create_executable = False,
298313
deploy_manifest_lines = [target_class_manifest_line],
299314
tags = (tags or []) + ["manual"],
315+
target_compatible_with = target_compatible_with,
300316
)
301317

302318
# use += rather than append to allow users to pass in select() expressions for
@@ -327,6 +343,7 @@ def java_fuzz_test(
327343
srcs = srcs,
328344
main_class = "com.code_intelligence.jazzer.Jazzer",
329345
tags = (tags or []) + ["manual"],
346+
target_compatible_with = target_compatible_with,
330347
**binary_kwargs
331348
)
332349

@@ -351,6 +368,7 @@ def java_fuzz_test(
351368
}),
352369
target = raw_target_name,
353370
tags = (tags or []) + ["manual"],
371+
target_compatible_with = target_compatible_with,
354372
)
355373

356374
fuzzing_decoration(
@@ -360,6 +378,7 @@ def java_fuzz_test(
360378
corpus = corpus,
361379
dicts = dicts,
362380
tags = tags,
381+
target_compatible_with = target_compatible_with,
363382
test_size = size,
364383
test_tags = (tags or []) + [
365384
"fuzz-test",

0 commit comments

Comments
 (0)