blob: 479fcb80e085e9a19b3979cda475d0332b08c87a [file] [log] [blame]
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_fuzzer/fuzzer.gni")
declare_args() {
# Sets the sanitizer to pass to clang. Valid values are those for "-fsanitize"
# listed in https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html.
pw_sanitizer = ""
}
config("default_config") {
include_dirs = [ "public" ]
}
# This is added automatically by the `pw_fuzzer` template.
config("fuzzing") {
common_flags = [ "-fsanitize=fuzzer" ]
if (pw_sanitizer != "") {
common_flags += [ "-fsanitize=$pw_sanitizer" ]
}
cflags = common_flags
ldflags = common_flags
}
source_set("pw_fuzzer") {
public_configs = [ ":default_config" ]
public = [ "public/pw_fuzzer/fuzzed_data_provider.h" ]
sources = public
public_deps = [ "$dir_pw_log" ]
}
# See https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode
config("fuzzing_build_mode_unsafe_for_production") {
defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ]
}
config("fuzzing_verbose_logging") {
defines = [ "FUZZING_VERBOSE_LOGGING" ]
}
pw_doc_group("docs") {
inputs = [ "doc_resources/pw_fuzzer_coverage_guided.png" ]
sources = [ "docs.rst" ]
}
# Sample fuzzer
pw_fuzzer("toy_fuzzer") {
sources = [ "examples/toy_fuzzer.cc" ]
deps = [ "$dir_pw_string" ]
}
pw_test_group("tests") {
tests = [ ":toy_fuzzer" ]
}