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 15package(default_visibility = ["//visibility:public"]) 16 17licenses(["notice"]) 18 19################################################################################ 20# FuzzTest support 21# 22# Create FuzzTest-style fuzzers by adding a dep on //pw_fuzzer:fuzztest 23 24# Identifies when upstream FuzzTest is being used. 25config_setting( 26 name = "use_fuzztest", 27 testonly = True, 28 flag_values = { 29 "//pw_fuzzer:fuzztest_backend": "@com_google_fuzztest//fuzztest:fuzztest_core", 30 }, 31) 32 33cc_library( 34 name = "fuzztest", 35 testonly = True, 36 hdrs = ["public/pw_fuzzer/fuzztest.h"] + select({ 37 ":use_fuzztest": ["private/pw_fuzzer/internal/fuzztest.h"], 38 "//conditions:default": [], 39 }), 40 includes = ["public"] + select({ 41 ":use_fuzztest": ["private"], 42 "//conditions:default": [], 43 }), 44 deps = [ 45 ":fuzztest_backend", 46 "//pw_containers", 47 "//pw_result", 48 "//pw_status", 49 "//pw_string", 50 ], 51) 52 53label_flag( 54 name = "fuzztest_backend", 55 build_setting_default = ":fuzztest_stub", 56) 57 58cc_library( 59 name = "fuzztest_stub", 60 testonly = True, 61 hdrs = [ 62 "private_overrides/pw_fuzzer/internal/fuzztest.h", 63 "public_overrides/fuzztest/fuzztest.h", 64 ], 65 includes = [ 66 "private_overrides", 67 "public_overrides", 68 ], 69 deps = ["//pw_unit_test"], 70) 71 72################################################################################ 73# libFuzzer support 74# 75# Create libFuzzer-style fuzzers by using the `pw_fuzzer` template from 76# fuzzer.gni. 77 78cc_library( 79 name = "libfuzzer", 80 hdrs = [ 81 "public/pw_fuzzer/asan_interface.h", 82 "public/pw_fuzzer/fuzzed_data_provider.h", 83 ], 84 strip_include_prefix = "public", 85) 86