Aaron Green | f3c3d2b | 2020-04-02 23:12:31 -0700 | [diff] [blame] | 1 | # Copyright 2020 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 | |
| 15 | import("$dir_pw_docgen/docs.gni") |
| 16 | import("$dir_pw_fuzzer/fuzzer.gni") |
| 17 | |
| 18 | declare_args() { |
| 19 | # Sets the sanitizer to pass to clang. Valid values are those for "-fsanitize" |
| 20 | # listed in https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html. |
| 21 | pw_sanitizer = "" |
| 22 | } |
| 23 | |
Aaron Green | 33c6782 | 2020-04-06 13:47:38 -0700 | [diff] [blame^] | 24 | config("default_config") { |
| 25 | include_dirs = [ "public" ] |
| 26 | } |
| 27 | |
Aaron Green | f3c3d2b | 2020-04-02 23:12:31 -0700 | [diff] [blame] | 28 | # This is added automatically by the `pw_fuzzer` template. |
Aaron Green | 33c6782 | 2020-04-06 13:47:38 -0700 | [diff] [blame^] | 29 | config("fuzzing") { |
Aaron Green | f3c3d2b | 2020-04-02 23:12:31 -0700 | [diff] [blame] | 30 | common_flags = [ "-fsanitize=fuzzer" ] |
| 31 | if (pw_sanitizer != "") { |
| 32 | common_flags += [ "-fsanitize=$pw_sanitizer" ] |
| 33 | } |
| 34 | cflags = common_flags |
| 35 | ldflags = common_flags |
| 36 | } |
| 37 | |
Aaron Green | 33c6782 | 2020-04-06 13:47:38 -0700 | [diff] [blame^] | 38 | source_set("pw_fuzzer") { |
| 39 | public_configs = [ ":default_config" ] |
| 40 | public = [ "public/pw_fuzzer/fuzzed_data_provider.h" ] |
| 41 | sources = public |
| 42 | public_deps = [ "$dir_pw_log" ] |
| 43 | } |
| 44 | |
| 45 | # See https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode |
| 46 | config("fuzzing_build_mode_unsafe_for_production") { |
| 47 | defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ] |
| 48 | } |
| 49 | |
| 50 | config("fuzzing_verbose_logging") { |
| 51 | defines = [ "FUZZING_VERBOSE_LOGGING" ] |
| 52 | } |
| 53 | |
Aaron Green | f3c3d2b | 2020-04-02 23:12:31 -0700 | [diff] [blame] | 54 | pw_doc_group("docs") { |
| 55 | inputs = [ "doc_resources/pw_fuzzer_coverage_guided.png" ] |
| 56 | sources = [ "docs.rst" ] |
| 57 | } |
| 58 | |
| 59 | # Sample fuzzer |
| 60 | pw_fuzzer("toy_fuzzer") { |
| 61 | sources = [ "examples/toy_fuzzer.cc" ] |
| 62 | deps = [ "$dir_pw_string" ] |
| 63 | } |
| 64 | |
| 65 | pw_test_group("tests") { |
| 66 | tests = [ ":toy_fuzzer" ] |
| 67 | } |