| # Copyright 2018 The Dawn & Tint Authors | |
| # | |
| # Redistribution and use in source and binary forms, with or without | |
| # modification, are permitted provided that the following conditions are met: | |
| # | |
| # 1. Redistributions of source code must retain the above copyright notice, this | |
| # list of conditions and the following disclaimer. | |
| # | |
| # 2. Redistributions in binary form must reproduce the above copyright notice, | |
| # this list of conditions and the following disclaimer in the documentation | |
| # and/or other materials provided with the distribution. | |
| # | |
| # 3. Neither the name of the copyright holder nor the names of its | |
| # contributors may be used to endorse or promote products derived from | |
| # this software without specific prior written permission. | |
| # | |
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| import("../../../scripts/dawn_overrides_with_defaults.gni") | |
| if (dawn_has_fuzzers) { | |
| import("//build_overrides/build.gni") | |
| import("//testing/libfuzzer/fuzzer_test.gni") | |
| import("${dawn_root}/scripts/dawn_features.gni") | |
| import("${dawn_root}/src/dawn/fuzzers/dawn_fuzzers.gni") | |
| static_library("dawn_wire_server_fuzzer_common") { | |
| sources = [ | |
| "DawnWireServerFuzzer.cpp", | |
| "DawnWireServerFuzzer.h", | |
| ] | |
| public_deps = [ | |
| "${dawn_root}/src/dawn:cpp", | |
| "${dawn_root}/src/dawn:proc", | |
| "${dawn_root}/src/dawn/common", | |
| "${dawn_root}/src/dawn/native:static", | |
| "${dawn_root}/src/dawn/utils", | |
| "${dawn_root}/src/dawn/wire:static", | |
| ] | |
| } | |
| fuzzer_test("dawn_wire_server_and_frontend_fuzzer") { | |
| sources = [ "DawnWireServerAndFrontendFuzzer.cpp" ] | |
| deps = [ ":dawn_wire_server_fuzzer_common" ] | |
| additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] | |
| } | |
| if (is_win) { | |
| fuzzer_test("dawn_wire_server_and_d3d12_backend_fuzzer") { | |
| sources = [ "DawnWireServerAndD3D12BackendFuzzer.cpp" ] | |
| deps = [ ":dawn_wire_server_fuzzer_common" ] | |
| additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] | |
| } | |
| } | |
| fuzzer_test("dawn_wire_server_and_vulkan_backend_fuzzer") { | |
| sources = [ "DawnWireServerAndVulkanBackendFuzzer.cpp" ] | |
| deps = [ ":dawn_wire_server_fuzzer_common" ] | |
| additional_configs = [ "${dawn_root}/src/dawn/common:internal_config" ] | |
| } | |
| if (is_dawn_lpm_fuzzer && build_with_chromium && dawn_use_swiftshader && | |
| !disable_libfuzzer && use_fuzzing_engine) { | |
| import("//third_party/protobuf/proto_library.gni") | |
| import("${dawn_root}/generator/dawn_generator.gni") | |
| # Generate the fuzzer's serializer in `.cpp` | |
| dawn_json_lpm_generator("dawn_lpmfuzz_cpp") { | |
| target = "dawn_lpmfuzz_cpp" | |
| outputs = [ | |
| "src/dawn/fuzzers/lpmfuzz/DawnLPMSerializer_autogen.cpp", | |
| "src/dawn/fuzzers/lpmfuzz/DawnLPMSerializer_autogen.h", | |
| "src/dawn/fuzzers/lpmfuzz/DawnLPMConstants_autogen.h", | |
| ] | |
| } | |
| # Generate the `.proto` files | |
| dawn_json_lpm_generator("dawn_lpmfuzz_proto") { | |
| target = "dawn_lpmfuzz_proto" | |
| outputs = [ | |
| "src/dawn/fuzzers/lpmfuzz/dawn_lpm_autogen.proto", | |
| "src/dawn/fuzzers/lpmfuzz/dawn_object_types_lpm_autogen.proto", | |
| ] | |
| } | |
| # Copy handwritten `.proto` file to build directory | |
| copy("copy_dawn_custom_lpm") { | |
| sources = | |
| [ "${dawn_root}/src/dawn/fuzzers/lpmfuzz/dawn_custom_lpm.proto" ] | |
| outputs = [ "$root_out_dir/gen/third_party/dawn/src/dawn/fuzzers/lpmfuzz/dawn_custom_lpm.proto" ] | |
| } | |
| # Generate the `.pb.h` and `.pb.cc` files | |
| proto_library("dawn_lpm_proto") { | |
| proto_in_dir = "$root_out_dir/gen" | |
| proto_out_dir = "//" | |
| sources = get_target_outputs(":dawn_lpmfuzz_proto") | |
| sources += get_target_outputs(":copy_dawn_custom_lpm") | |
| generate_python = false | |
| use_protobuf_full = true | |
| deps = [ | |
| ":copy_dawn_custom_lpm", | |
| ":dawn_lpmfuzz_proto", | |
| "//third_party/protobuf:protobuf_full", | |
| ] | |
| } | |
| # Compile dawnlpm fuzzer with extensive tint coverage | |
| dawn_lpm_template("dawn_lpm_fuzzer_vulkan_backend_with_tint") { | |
| defines = [ "DAWNLPM_FUZZ_TINT=1" ] | |
| dawn_lpm_sources = get_target_outputs(":dawn_lpmfuzz_cpp") | |
| dawn_lpm_sources += [ | |
| "lpmfuzz/DawnLPMFuzzer.cpp", | |
| "lpmfuzz/DawnLPMFuzzer.h", | |
| "lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp", | |
| "lpmfuzz/DawnLPMObjectStore.cpp", | |
| "lpmfuzz/DawnLPMObjectStore.h", | |
| "lpmfuzz/DawnLPMSerializerCustom.cpp", | |
| "lpmfuzz/DawnLPMSerializerCustom.h", | |
| ] | |
| } | |
| # Compile dawnlpm api fuzzer | |
| dawn_lpm_template("dawn_lpm_fuzzer_vulkan_backend") { | |
| defines = [ "DAWNLPM_FUZZ_TINT=0" ] | |
| dawn_lpm_sources = get_target_outputs(":dawn_lpmfuzz_cpp") | |
| dawn_lpm_sources += [ | |
| "lpmfuzz/DawnLPMFuzzer.cpp", | |
| "lpmfuzz/DawnLPMFuzzer.h", | |
| "lpmfuzz/DawnLPMFuzzerAndVulkanBackend.cpp", | |
| "lpmfuzz/DawnLPMObjectStore.cpp", | |
| "lpmfuzz/DawnLPMObjectStore.h", | |
| "lpmfuzz/DawnLPMSerializerCustom.cpp", | |
| "lpmfuzz/DawnLPMSerializerCustom.h", | |
| ] | |
| } | |
| } | |
| # A group target to build all the fuzzers | |
| group("fuzzers") { | |
| testonly = true | |
| deps = [ | |
| ":dawn_wire_server_and_frontend_fuzzer", | |
| ":dawn_wire_server_and_vulkan_backend_fuzzer", | |
| ] | |
| if (is_win) { | |
| deps += [ ":dawn_wire_server_and_d3d12_backend_fuzzer" ] | |
| } | |
| } | |
| } |