blob: 3d101c21e037621e14d539a10a6ca3a8a04d5d81 [file] [log] [blame]
# Copyright (c) 2020 Project CHIP 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("//build_overrides/chip.gni")
import("${build_root}/config/compiler/compiler.gni")
declare_args() {
enable_fuzz_test_targets =
is_clang && (current_os == "linux" || current_os == "mac")
}
# Define a fuzz target for chip.
#
# Fuzz generally only apply on the following environments:
# - linux and mac host builds when using clang
#
# Sample usage
#
# chip_fuzz_target("fuzz-target-name") {
# sources = [
# "FuzzTarget.cpp", # Fuzz target
# ]
#
# public_deps = [
# "${chip_root}/src/lib/foo", # add dependencies here
# "${nlunit_test_root}:nlunit-test",
# ]
# }
#
#
template("chip_fuzz_target") {
if (enable_fuzz_test_targets) {
executable(target_name) {
forward_variables_from(invoker, "*")
if (defined(public_configs)) {
public_configs += [
"//build/config/compiler:libfuzzer_fuzzing",
"//build/config/compiler:sanitize_address",
]
} else {
public_configs = [
"//build/config/compiler:libfuzzer_fuzzing",
"//build/config/compiler:sanitize_address",
]
}
if (!defined(oubput_dir)) {
output_dir = "${root_out_dir}/tests"
}
}
}
}