1# Copyright 2018 The Dawn Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://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, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import("//build_overrides/build.gni") 16import("../../scripts/dawn_overrides_with_defaults.gni") 17 18# We only have libfuzzer in Chromium builds but if we build fuzzer targets only 19# there, we would risk breaking fuzzer targets all the time when making changes 20# to Dawn. To avoid that, we make fuzzer targets compile in standalone builds 21# as well with a dawn_fuzzer_test target that acts like Chromium's fuzzer_test. 22# 23# The standalone fuzzer targets are able to run a single fuzzer input which 24# could help reproduce fuzzer crashes more easily because you don't need a 25# whole Chromium checkout. 26 27if (build_with_chromium) { 28 import("//testing/libfuzzer/fuzzer_test.gni") 29 30 # In Chromium build we just proxy everything to the real fuzzer_test 31 template("dawn_fuzzer_test") { 32 fuzzer_test(target_name) { 33 forward_variables_from(invoker, "*") 34 } 35 } 36} else { 37 import("//testing/test.gni") 38 39 # In standalone build we do something similar to fuzzer_test. 40 template("dawn_fuzzer_test") { 41 test(target_name) { 42 forward_variables_from(invoker, 43 [ 44 "asan_options", 45 "cflags", 46 "cflags_cc", 47 "check_includes", 48 "defines", 49 "deps", 50 "include_dirs", 51 "sources", 52 ]) 53 54 if (defined(asan_options)) { 55 not_needed([ "asan_options" ]) 56 } 57 58 if (!defined(configs)) { 59 configs = [] 60 } 61 62 # Weirdly fuzzer_test uses a special variable for additional configs. 63 if (defined(invoker.additional_configs)) { 64 configs += invoker.additional_configs 65 } 66 67 sources += [ "StandaloneFuzzerMain.cpp" ] 68 } 69 } 70} 71 72static_library("dawn_spirv_cross_fuzzer_common") { 73 sources = [ 74 "DawnSPIRVCrossFuzzer.cpp", 75 "DawnSPIRVCrossFuzzer.h", 76 ] 77 public_deps = [ "${dawn_shaderc_dir}:libshaderc_spvc" ] 78} 79 80# TODO(rharrison): Remove asan_options once signal trap is no longer 81# needed. 82# Uses Dawn specific options and varies input data 83dawn_fuzzer_test("dawn_spirv_cross_glsl_fast_fuzzer") { 84 sources = [ "DawnSPIRVCrossGLSLFastFuzzer.cpp" ] 85 deps = [ ":dawn_spirv_cross_fuzzer_common" ] 86 asan_options = [ "allow_user_segv_handler=1" ] 87} 88 89# TODO(rharrison): Remove asan_options once signal trap is no longer 90# needed. 91# Uses Dawn specific options and varies input data 92dawn_fuzzer_test("dawn_spirv_cross_hlsl_fast_fuzzer") { 93 sources = [ "DawnSPIRVCrossHLSLFastFuzzer.cpp" ] 94 deps = [ ":dawn_spirv_cross_fuzzer_common" ] 95 asan_options = [ "allow_user_segv_handler=1" ] 96} 97 98# TODO(rharrison): Remove asan_options once signal trap is no longer 99# needed. 100# Uses Dawn specific options and varies input data 101dawn_fuzzer_test("dawn_spirv_cross_msl_fast_fuzzer") { 102 sources = [ "DawnSPIRVCrossMSLFastFuzzer.cpp" ] 103 deps = [ ":dawn_spirv_cross_fuzzer_common" ] 104 asan_options = [ "allow_user_segv_handler=1" ] 105} 106 107dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") { 108 sources = [ "DawnWireServerAndFrontendFuzzer.cpp" ] 109 110 deps = [ 111 "${dawn_root}/:libdawn_native_static", 112 "${dawn_root}/:libdawn_wire_static", 113 "${dawn_root}/src/common", 114 "${dawn_root}/src/dawn:libdawn_static", 115 ] 116 117 additional_configs = [ "${dawn_root}/src/common:dawn_internal" ] 118} 119