| # 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/fidl/toolchain.gni") |
| import("//build/go/go_binary.gni") |
| import("//build/go/go_library.gni") |
| import("//build/host.gni") |
| import("//build/testing/golden_files.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| if (is_host) { |
| go_library("codegen") { |
| source_dir = "codegen" |
| deps = [ |
| "//tools/fidl/lib/fidlgen", |
| "//tools/fidl/lib/fidlgen_cpp", |
| ] |
| sources = [ |
| "codegen.go", |
| "coding_tables.tmpl", |
| "header.tmpl", |
| "implementation.tmpl", |
| "proxies_and_stubs_protocol.tmpl", |
| "proxies_and_stubs_service.tmpl", |
| "test_base.tmpl", |
| "types_alias.tmpl", |
| "types_bits.tmpl", |
| "types_const.tmpl", |
| "types_enum.tmpl", |
| "types_protocol.tmpl", |
| "types_struct.tmpl", |
| "types_table.tmpl", |
| "types_union.tmpl", |
| ] |
| } |
| |
| go_library("coding_tables") { |
| source_dir = "coding_tables" |
| deps = [ |
| "//third_party/golibs:golang.org/x/exp", |
| "//tools/fidl/lib/fidlgen", |
| ] |
| sources = [ "ir.go" ] |
| } |
| |
| go_library("main") { |
| deps = [ |
| ":codegen", |
| ":coding_tables", |
| "//tools/fidl/lib/fidlgen", |
| ] |
| sources = [ "main.go" ] |
| } |
| |
| go_binary("fidlgen_hlcpp") { |
| library = ":main" |
| sdk_category = "partner" |
| } |
| |
| golden_files("fidlgen_hlcpp_golden_tests") { |
| testonly = true |
| |
| formatter = { |
| script = "$root_out_dir/clang-format-wrapper" |
| inputs = [ "${clang_prefix}/clang-format" ] |
| args = [ rebase_path(inputs[0], root_build_dir) ] |
| deps = [ "//tools/fidl/clang-format-wrapper" ] |
| } |
| |
| deps = [] |
| comparisons = [] |
| foreach(info, fidl_testdata_info) { |
| if (info.denylist + [ "fidlgen_hlcpp" ] - [ "fidlgen_hlcpp" ] == |
| info.denylist) { |
| deps += [ "${info.target}_hlcpp_generate($fidl_toolchain)" ] |
| _gen_dir = "${info.fidl_gen_dir}/${info.target_name}/hlcpp" |
| _include_path = string_replace(info.library, ".", "/") + "/cpp" |
| comparisons += [ |
| { |
| golden = "goldens/${info.name}.h.golden" |
| candidate = "$_gen_dir/$_include_path/fidl.h" |
| }, |
| { |
| golden = "goldens/${info.name}.cc.golden" |
| candidate = "$_gen_dir/$_include_path/fidl.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_test_base.h.golden" |
| candidate = "$_gen_dir/$_include_path/fidl_test_base.h" |
| }, |
| { |
| golden = "goldens/${info.name}_tables.c.golden" |
| candidate = "$_gen_dir/$_include_path/tables.c" |
| }, |
| ] |
| } |
| } |
| } |
| } |
| |
| install_host_tools("host") { |
| deps = [ ":fidlgen_hlcpp" ] |
| outputs = [ "fidlgen_hlcpp" ] |
| } |
| |
| group("goldens") { |
| testonly = true |
| |
| denylist_key = "device_build_denylist" |
| if (is_host) { |
| denylist_key = "host_build_denylist" |
| } |
| |
| deps = [] |
| foreach(info, fidl_testdata_info) { |
| if (info[denylist_key] + [ "fidlgen_hlcpp" ] - [ "fidlgen_hlcpp" ] == |
| info[denylist_key]) { |
| deps += [ "${info.target}_hlcpp" ] |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fidlgen_hlcpp_golden_tests($host_toolchain)", |
| ":goldens", |
| ":goldens($host_toolchain)", |
| ] |
| } |