1# Copyright 2021 The Tint 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 15function(add_tint_regex_fuzzer NAME) 16 add_executable(${NAME} ${NAME}.cc ${REGEX_FUZZER_SOURCES}) 17 target_link_libraries(${NAME} libtint-fuzz libtint_regex_fuzzer) 18 tint_default_compile_options(${NAME}) 19 target_compile_definitions(${NAME} PRIVATE CUSTOM_MUTATOR) 20 target_include_directories(${NAME} PRIVATE ${CMAKE_BINARY_DIR}) 21endfunction() 22 23set(LIBTINT_REGEX_FUZZER_SOURCES 24 ../mersenne_twister_engine.cc 25 ../mersenne_twister_engine.h 26 ../random_generator.cc 27 ../random_generator.h 28 ../random_generator_engine.cc 29 ../random_generator_engine.h 30 wgsl_mutator.cc 31 wgsl_mutator.h) 32 33# Add static library target. 34add_library(libtint_regex_fuzzer STATIC ${LIBTINT_REGEX_FUZZER_SOURCES}) 35tint_default_compile_options(libtint_regex_fuzzer) 36 37set(REGEX_FUZZER_SOURCES 38 cli.cc 39 cli.h 40 fuzzer.cc 41 override_cli_params.h 42 ../tint_common_fuzzer.cc 43 ../tint_common_fuzzer.h) 44 45set_source_files_properties(fuzzer.cc PROPERTIES COMPILE_FLAGS -Wno-missing-prototypes) 46 47# Add libfuzzer targets. 48# Targets back-ends according to command line arguments. 49add_tint_regex_fuzzer(tint_regex_fuzzer) 50# Targets back-ends individually. 51add_tint_regex_fuzzer(tint_regex_hlsl_writer_fuzzer) 52add_tint_regex_fuzzer(tint_regex_msl_writer_fuzzer) 53add_tint_regex_fuzzer(tint_regex_spv_writer_fuzzer) 54add_tint_regex_fuzzer(tint_regex_wgsl_writer_fuzzer) 55 56# Add tests. 57if (${TINT_BUILD_TESTS}) 58 set(TEST_SOURCES 59 regex_fuzzer_tests.cc) 60 61 add_executable(tint_regex_fuzzer_unittests ${TEST_SOURCES}) 62 63 target_include_directories( 64 tint_regex_fuzzer_unittests PRIVATE ${gmock_SOURCE_DIR}/include) 65 target_link_libraries(tint_regex_fuzzer_unittests gmock_main libtint_regex_fuzzer) 66 tint_default_compile_options(tint_regex_fuzzer_unittests) 67 target_compile_options(tint_regex_fuzzer_unittests PRIVATE 68 -Wno-global-constructors 69 -Wno-weak-vtables 70 -Wno-covered-switch-default) 71 72 target_include_directories(tint_regex_fuzzer_unittests PRIVATE ${CMAKE_BINARY_DIR}) 73 74 add_test(NAME tint_regex_fuzzer_unittests COMMAND tint_regex_fuzzer_unittests) 75endif () 76