blob: bae11c3736c4b4df5f54532105c29bd1c20a64da [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/go/go_binary.gni")
import("//build/go/go_library.gni")
import("//build/go/go_test.gni")
import("//build/host.gni")
import("//build/testing/host_test_data.gni")
import("//zircon/tools/fidl/testdata/targets.gni")
go_library("gopkg") {
name = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_hlcpp/..."
deps = [
"//garnet/go/src/fidl/compiler/backend/cpp",
"//garnet/go/src/fidl/compiler/backend/types",
]
sources = [
"codegen/codegen.go",
"codegen/codegen_test.go",
"codegen/header.tmpl.go",
"codegen/implementation.tmpl.go",
"codegen/natural_types_bits.tmpl.go",
"codegen/natural_types_const.tmpl.go",
"codegen/natural_types_enum.tmpl.go",
"codegen/natural_types_protocol.tmpl.go",
"codegen/natural_types_struct.tmpl.go",
"codegen/natural_types_table.tmpl.go",
"codegen/natural_types_union.tmpl.go",
"codegen/proxies_and_stubs_protocol.tmpl.go",
"codegen/proxies_and_stubs_service.tmpl.go",
"codegen/test_base.tmpl.go",
"main.go",
]
}
go_binary("fidlgen_hlcpp") {
gopackage = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_hlcpp"
sdk_category = "partner"
deps = [ ":gopkg" ]
}
install_host_tools("host") {
deps = [ ":fidlgen_hlcpp" ]
outputs = [ "fidlgen_hlcpp" ]
}
# TODO(fxbug.dev/45483): Remove once all SDK customers are using HLCPP backend
# directly.
go_binary("fidlgen") {
gopackage = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_hlcpp"
sdk_category = "partner"
deps = [ ":gopkg" ]
}
if (is_host) {
go_test("fidlgen_hlcpp_test") {
gopackages = [ "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_hlcpp/codegen" ]
args = [
"--test_data_dir",
rebase_path("$root_out_dir/test_data/fidlgen", root_build_dir),
"--clang-format",
rebase_path("$root_out_dir/test_data/fidlgen_hlcpp", root_build_dir),
]
deps = [
":gopkg",
"//garnet/go/src/fidl/compiler/backend/typestest",
]
non_go_deps = [ ":clang_format" ]
}
host_test_data("clang_format") {
sources = [ "//prebuilt/third_party/clang/$host_platform/bin/clang-format" ]
outputs = [ "$root_out_dir/test_data/fidlgen_hlcpp/{{source_file_part}}" ]
}
}
group("goldens") {
testonly = true
# Keep this in sync with hlcpp_denylist in fidlgen_libfuzzer/BUILD.gn.
denylist = [
# TODO(fxbug.dev/62520): Insert enum/bits <-> primitive conversions.
"//zircon/tools/fidl/testdata:fidl.test.consts",
# TODO(fxbug.dev/62533): Fix many issues.
"//zircon/tools/fidl/testdata:fidl.test.handles",
]
deps = []
foreach(target, fidl_testdata_targets - denylist) {
deps += [ "${target}_hlcpp" ]
}
}
group("tests") {
testonly = true
deps = [
":fidlgen_hlcpp_test($host_toolchain)",
":goldens",
":goldens($host_toolchain)",
]
}