blob: e3e12a4f5d31fd199e6fba4c9d819f5f63b51b28 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/clang/clang.gni")
import("//build/go/go_binary.gni")
import("//build/go/go_library.gni")
import("//build/host.gni")
import("//build/testing/golden_test.gni")
import("//tools/fidl/fidlc/testdata/info.gni")
if (is_host) {
go_library("gopkg") {
name = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_libfuzzer/..."
deps = [
"//tools/fidl/lib/fidlgen",
"//tools/fidl/lib/fidlgen_cpp",
]
sources = [
"codegen/bits.tmpl",
"codegen/codegen.go",
"codegen/decoder_encoder.tmpl",
"codegen/decoder_encoder_header.tmpl",
"codegen/decoder_encoder_source.tmpl",
"codegen/enum.tmpl",
"codegen/header.tmpl",
"codegen/protocol_decoder_encoders.tmpl",
"codegen/source.tmpl",
"codegen/struct.tmpl",
"codegen/table.tmpl",
"codegen/union.tmpl",
"main.go",
]
}
go_binary("fidlgen_libfuzzer") {
gopackage = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_libfuzzer"
sdk_category = "partner"
deps = [ ":gopkg" ]
}
golden_test("fidlgen_libfuzzer_golden_tests") {
goldens_dir = "goldens"
reformat_goldens_bin = "$root_out_dir/clang-format-wrapper"
reformat_goldens_args =
[ rebase_path("${clang_prefix}/clang-format", root_build_dir) ]
reformat_goldens_inputs = [ "${clang_prefix}/clang-format" ]
deps = [ "//tools/fidl/clang-format-wrapper" ]
entries = []
foreach(info, fidl_testdata_info) {
if (info.denylist + [ "fidlgen_libfuzzer" ] - [ "fidlgen_libfuzzer" ] ==
info.denylist) {
deps += [ "${info.target}_libfuzzer_generate($fidl_toolchain)" ]
gen_dir = "${info.fidl_gen_dir}/${info.target_name}/libfuzzer"
include_path = string_replace(info.library, ".", "/") + "/cpp"
entries += [
{
golden = "${info.name}.h.golden"
generated = "$gen_dir/$include_path/libfuzzer.h"
},
{
golden = "${info.name}.cc.golden"
generated = "$gen_dir/$include_path/libfuzzer.cc"
},
{
golden = "${info.name}_decode_encode.h.golden"
generated = "$gen_dir/$include_path/libfuzzer_decode_encode.h"
},
{
golden = "${info.name}_decode_encode.cc.golden"
generated = "$gen_dir/$include_path/libfuzzer_decode_encode.cc"
},
]
}
}
}
}
install_host_tools("host") {
deps = [ ":fidlgen_libfuzzer" ]
outputs = [ "fidlgen_libfuzzer" ]
}
group("goldens") {
testonly = true
deps = []
foreach(info, fidl_testdata_info) {
if (info.build_denylist + [ "fidlgen_libfuzzer" ] -
[ "fidlgen_libfuzzer" ] == info.build_denylist) {
deps += [ "${info.target}_libfuzzer__golden" ]
}
}
}
group("tests") {
testonly = true
deps = [
":fidlgen_libfuzzer_golden_tests($host_toolchain)",
":goldens",
]
}