blob: 9833c0224e65352419b872524a2436df1e60f7aa [file] [log] [blame]
# Copyright 2023 The Tint 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
#
# http://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("//build_overrides/build.gni")
import("../../scripts/tint_overrides_with_defaults.gni")
template("libtint_source_set") {
source_set(target_name) {
forward_variables_from(invoker, "*", [ "configs" ])
if (!defined(invoker.deps)) {
deps = []
}
if (defined(invoker.configs)) {
configs += invoker.configs
}
configs += [ "${tint_src_dir}:tint_common_config" ]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
if (!defined(invoker.public_configs)) {
public_configs = []
}
public_configs += [ "${tint_src_dir}:tint_public_config" ]
}
}
###############################################################################
# Unit tests
###############################################################################
template("tint_unittests_source_set") {
if (tint_build_unittests) {
source_set(target_name) {
forward_variables_from(invoker, "*", [ "configs" ])
testonly = true
if (defined(invoker.configs)) {
configs += invoker.configs
}
configs += [ "${tint_src_dir}:tint_unittests_config" ]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
if (!defined(invoker.deps)) {
deps = []
}
deps += [ "${tint_src_dir}:gmock_and_gtest" ]
}
}
}
###############################################################################
# Fuzzers
###############################################################################
import("//testing/libfuzzer/fuzzer_test.gni")
fuzzer_corpus_wgsl_dir = "${root_gen_dir}/fuzzers/wgsl_corpus"
fuzzer_corpus_wgsl_stamp = "${fuzzer_corpus_wgsl_dir}.stamp"
template("tint_fuzz_source_set") {
source_set(target_name) {
forward_variables_from(invoker, "*", [ "configs" ])
testonly = true
if (!defined(invoker.deps)) {
deps = []
}
if (defined(invoker.configs)) {
configs += invoker.configs
}
configs += [ "${tint_src_dir}:tint_common_config" ]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
if (!defined(invoker.public_configs)) {
public_configs = []
}
public_configs += [ "${tint_src_dir}:tint_public_config" ]
}
}
template("tint_fuzzer_test") {
fuzzer_test(target_name) {
forward_variables_from(invoker, "*")
exclude_main = false
if (target_name == "wgsl") {
dict = "dictionary.txt"
libfuzzer_options = [
"only_ascii=1", # TODO(bclayton): Remove this to fuzz unicode?
"max_len=10000",
]
seed_corpus = fuzzer_corpus_wgsl_dir
seed_corpus_deps = [ "${tint_src_dir}:tint_generate_wgsl_corpus" ]
} else {
assert(false, "unsupported tint fuzzer target")
}
}
}