• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@rules_cc//cc:cc_library.bzl", "cc_library")
16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
17load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
18
19package(default_visibility = ["//visibility:public"])
20
21licenses(["notice"])
22
23################################################################################
24# FuzzTest support
25#
26# Create FuzzTest-style fuzzers by adding a dep on //pw_fuzzer:fuzztest
27
28# Identifies when upstream FuzzTest is being used.
29config_setting(
30    name = "use_fuzztest",
31    testonly = True,
32    flag_values = {
33        "//pw_fuzzer:fuzztest_backend": "@com_google_fuzztest//fuzztest:fuzztest_core",
34    },
35)
36
37cc_library(
38    name = "fuzztest",
39    testonly = True,
40    hdrs = ["public/pw_fuzzer/fuzztest.h"] + select({
41        ":use_fuzztest": ["private/pw_fuzzer/internal/fuzztest.h"],
42        "//conditions:default": [],
43    }),
44    includes = ["public"] + select({
45        ":use_fuzztest": ["private"],
46        "//conditions:default": [],
47    }),
48    deps = [
49        ":fuzztest_backend",
50        "//pw_containers:flat_map",
51        "//pw_containers:inline_deque",
52        "//pw_containers:inline_queue",
53        "//pw_containers:intrusive_list",
54        "//pw_containers:vector",
55        "//pw_result",
56        "//pw_status",
57        "//pw_string",
58    ],
59)
60
61label_flag(
62    name = "fuzztest_backend",
63    build_setting_default = ":fuzztest_stub",
64)
65
66cc_library(
67    name = "fuzztest_stub",
68    testonly = True,
69    hdrs = [
70        "private_overrides/pw_fuzzer/internal/fuzztest.h",
71        "public_overrides/fuzztest/fuzztest.h",
72    ],
73    includes = [
74        "private_overrides",
75        "public_overrides",
76    ],
77    tags = ["noclangtidy"],
78    deps = ["//pw_unit_test"],
79)
80
81################################################################################
82# libFuzzer support
83#
84# Create libFuzzer-style fuzzers by using the `pw_fuzzer` template from
85# fuzzer.gni.
86
87cc_library(
88    name = "libfuzzer",
89    hdrs = [
90        "public/pw_fuzzer/asan_interface.h",
91        "public/pw_fuzzer/fuzzed_data_provider.h",
92    ],
93    strip_include_prefix = "public",
94)
95
96sphinx_docs_library(
97    name = "docs",
98    srcs = [
99        "concepts.rst",
100        "docs.rst",
101        "guides/fuzztest.rst",
102        "guides/index.rst",
103        "guides/libfuzzer.rst",
104        "guides/reproducing_oss_fuzz_bugs.rst",
105        "//pw_fuzzer/examples/fuzztest:docs",
106    ],
107    prefix = "pw_fuzzer/",
108    target_compatible_with = incompatible_with_mcu(),
109)
110