| # 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/bits.tmpl.go", |
| "codegen/codegen.go", |
| "codegen/codegen_test.go", |
| "codegen/const.tmpl.go", |
| "codegen/enum.tmpl.go", |
| "codegen/header.tmpl.go", |
| "codegen/implementation.tmpl.go", |
| "codegen/protocol.tmpl.go", |
| "codegen/service.tmpl.go", |
| "codegen/struct.tmpl.go", |
| "codegen/table.tmpl.go", |
| "codegen/test_base.tmpl.go", |
| "codegen/union.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/55889): Escape "union" keyword. |
| "//zircon/tools/fidl/testdata:fidl.test.union", |
| |
| # 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", |
| ] |
| |
| if (host_toolchain == current_toolchain) { |
| denylist += [ |
| # TODO(fxbug.dev/62576): Add ifdefs to that handles compile on host. |
| "//zircon/tools/fidl/testdata:fidl.test.encapsulatedstructs", |
| "//zircon/tools/fidl/testdata:fidl.test.handlesintypes", |
| "//zircon/tools/fidl/testdata:fidl.test.nullable", |
| "//zircon/tools/fidl/testdata/type_aliases:example", |
| "//zircon/tools/fidl/testdata/type_aliases:someotherlibrary", |
| ] |
| } |
| |
| deps = [] |
| foreach(target, fidl_testdata_targets - denylist) { |
| deps += [ "${target}_hlcpp" ] |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fidlgen_hlcpp_test($host_toolchain)", |
| ":goldens", |
| ":goldens($host_toolchain)", |
| ] |
| } |