-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBUILD.bazel
57 lines (52 loc) · 1.8 KB
/
BUILD.bazel
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
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_skylib//lib:selects.bzl", "selects")
bool_flag(
# Since this flag can be set from the command line, give it a very ugly name
# to discourage its use by users.
name = "__internal_has_libfuzzer",
build_setting_default = False,
)
config_setting(
name = "has_libfuzzer",
flag_values = {":__internal_has_libfuzzer": "True"},
)
selects.config_setting_group(
name = "on_linux_and_has_libfuzzer",
match_all = [
":has_libfuzzer",
"@platforms//os:linux",
],
)
config_setting(
name = "collect_coverage",
values = {"collect_code_coverage": "True"},
visibility = ["//visibility:public"],
)
cc_library(
name = "cifuzz",
srcs = select({
# We have to use dumper.cpp instead of dumper.c here as the non-Xcode
# toolchain on macOS needs -isysroot to be set to the macOS SDK path in
# order to find C headers. However, Bazel only offers BAZEL_CXXOPTS to
# set this flag in a way that affects the builtin include directory list
# compiled by the @local_config_cc auto-configured toolchain. There is
# no BAZEL_COPTS.
":has_libfuzzer": ["src/dumper.cpp"],
"//conditions:default": [],
}),
hdrs = [
"include/cifuzz/cifuzz.h",
"include/fuzzer/FuzzedDataProvider.h",
],
includes = ["include"],
linkopts = select({
# On Linux, we wrap the __sanitizer_set_death_callback method to
# also dump sanitizer findings when they are non-fatal.
# See src/dumper.c for details.
":on_linux_and_has_libfuzzer": ["-Wl,--wrap=__sanitizer_set_death_callback"],
"//conditions:default": [],
}),
linkstatic = True,
visibility = ["//visibility:public"],
alwayslink = True,
)