| # 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_files.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| if (is_host) { |
| go_library("codegen") { |
| source_dir = "codegen" |
| deps = [ "//tools/fidl/lib/fidlgen_cpp" ] |
| sources = [ |
| "codegen.go", |
| "driver/file_natural_messaging_header.tmpl", |
| "driver/file_natural_messaging_source.tmpl", |
| "driver/file_unified_header.tmpl", |
| "driver/file_wire_header.tmpl", |
| "driver/file_wire_messaging_header.tmpl", |
| "driver/file_wire_messaging_source.tmpl", |
| "driver/fragment_method_client_impl_async_buffer.tmpl", |
| "driver/fragment_method_client_impl_oneway.tmpl", |
| "driver/fragment_method_client_impl_oneway_buffer.tmpl", |
| "driver/fragment_method_client_impl_sync.tmpl", |
| "driver/fragment_method_completer_base.tmpl", |
| "driver/fragment_method_unownedresult.tmpl", |
| "driver/fragment_protocol_caller.tmpl", |
| "driver/fragment_protocol_client_impl.tmpl", |
| "driver/fragment_protocol_event_sender.tmpl", |
| "file_common_types_header.tmpl", |
| "file_common_types_source.tmpl", |
| "file_hlcpp_conversion.tmpl", |
| "file_markers.tmpl", |
| "file_natural_messaging_header.tmpl", |
| "file_natural_messaging_source.tmpl", |
| "file_natural_ostream_header.tmpl", |
| "file_natural_ostream_source.tmpl", |
| "file_natural_types_header.tmpl", |
| "file_natural_types_source.tmpl", |
| "file_test_base.tmpl", |
| "file_type_conversions_header.tmpl", |
| "file_type_conversions_source.tmpl", |
| "file_unified_header.tmpl", |
| "file_wire_header.tmpl", |
| "file_wire_messaging_header.tmpl", |
| "file_wire_messaging_source.tmpl", |
| "file_wire_test_base.tmpl", |
| "file_wire_types_header.tmpl", |
| "file_wire_types_source.tmpl", |
| "fragment_alias.tmpl", |
| "fragment_bits.tmpl", |
| "fragment_const.tmpl", |
| "fragment_enum.tmpl", |
| "fragment_method_client_impl_async.tmpl", |
| "fragment_method_client_impl_async_buffer.tmpl", |
| "fragment_method_client_impl_oneway.tmpl", |
| "fragment_method_client_impl_oneway_buffer.tmpl", |
| "fragment_method_client_impl_sync.tmpl", |
| "fragment_method_completer_base.tmpl", |
| "fragment_method_event.tmpl", |
| "fragment_method_request.tmpl", |
| "fragment_method_response.tmpl", |
| "fragment_method_result.tmpl", |
| "fragment_method_types.tmpl", |
| "fragment_method_unownedresult.tmpl", |
| "fragment_protocol.tmpl", |
| "fragment_protocol_caller.tmpl", |
| "fragment_protocol_client_impl.tmpl", |
| "fragment_protocol_details.tmpl", |
| "fragment_protocol_dispatcher.tmpl", |
| "fragment_protocol_event_handler.tmpl", |
| "fragment_protocol_event_sender.tmpl", |
| "fragment_protocol_interface.tmpl", |
| "fragment_service.tmpl", |
| "fragment_struct.tmpl", |
| "fragment_table.tmpl", |
| "fragment_union.tmpl", |
| "natural_struct.tmpl", |
| "natural_table.tmpl", |
| "natural_union.tmpl", |
| ] |
| } |
| |
| go_library("main") { |
| deps = [ |
| ":codegen", |
| "//tools/fidl/lib/fidlgen_cpp", |
| ] |
| sources = [ "main.go" ] |
| } |
| |
| go_binary("fidlgen_cpp") { |
| library = ":main" |
| sdk_category = "partner" |
| sdk_name = "fidlgen_cpp" |
| } |
| |
| # TODO(https://fxbug.dev/42160879): Remove once Bazel SDK uses the non-experimental name. |
| go_binary("fidlgen_cpp_experimental_driver_only_toolchain") { |
| library = ":main" |
| sdk_category = "partner" |
| sdk_name = "fidlgen_cpp_experimental_driver_only_toolchain" |
| } |
| |
| golden_files("fidlgen_cpp_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_cpp" ] - [ "fidlgen_cpp" ] == |
| info.denylist) { |
| deps += [ "${info.target}_cpp_generate($fidl_toolchain)" ] |
| _gen_dir = "${info.fidl_gen_dir}/${info.target_name}/cpp" |
| _include_path = "fidl/${info.library}/cpp" |
| comparisons += [ |
| { |
| golden = "goldens/${info.name}_wire.h.golden" |
| candidate = "$_gen_dir/$_include_path/wire.h" |
| }, |
| { |
| golden = "goldens/${info.name}_wire_test_base.h.golden" |
| candidate = "$_gen_dir/$_include_path/wire_test_base.h" |
| }, |
| { |
| golden = "goldens/${info.name}_markers.h.golden" |
| candidate = "$_gen_dir/$_include_path/markers.h" |
| }, |
| { |
| golden = "goldens/${info.name}_common_types.h.golden" |
| candidate = "$_gen_dir/$_include_path/common_types.h" |
| }, |
| { |
| golden = "goldens/${info.name}_common_types.cc.golden" |
| candidate = "$_gen_dir/$_include_path/common_types.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_wire_types.h.golden" |
| candidate = "$_gen_dir/$_include_path/wire_types.h" |
| }, |
| { |
| golden = "goldens/${info.name}_wire_types.cc.golden" |
| candidate = "$_gen_dir/$_include_path/wire_types.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_wire_messaging.h.golden" |
| candidate = "$_gen_dir/$_include_path/wire_messaging.h" |
| }, |
| { |
| golden = "goldens/${info.name}_wire_messaging.cc.golden" |
| candidate = "$_gen_dir/$_include_path/wire_messaging.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_natural_types.h.golden" |
| candidate = "$_gen_dir/$_include_path/natural_types.h" |
| }, |
| { |
| golden = "goldens/${info.name}_natural_types.cc.golden" |
| candidate = "$_gen_dir/$_include_path/natural_types.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_natural_ostream.h.golden" |
| candidate = "$_gen_dir/$_include_path/natural_ostream.h" |
| }, |
| { |
| golden = "goldens/${info.name}_natural_ostream.cc.golden" |
| candidate = "$_gen_dir/$_include_path/natural_ostream.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_natural_messaging.h.golden" |
| candidate = "$_gen_dir/$_include_path/natural_messaging.h" |
| }, |
| { |
| golden = "goldens/${info.name}_natural_messaging.cc.golden" |
| candidate = "$_gen_dir/$_include_path/natural_messaging.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_test_base.h.golden" |
| candidate = "$_gen_dir/$_include_path/test_base.h" |
| }, |
| { |
| golden = "goldens/${info.name}_type_conversions.h.golden" |
| candidate = "$_gen_dir/$_include_path/type_conversions.h" |
| }, |
| { |
| golden = "goldens/${info.name}_type_conversions.cc.golden" |
| candidate = "$_gen_dir/$_include_path/type_conversions.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_hlcpp_conversion.h.golden" |
| candidate = "$_gen_dir/$_include_path/hlcpp_conversion.h" |
| }, |
| { |
| golden = "goldens/${info.name}_fidl.h.golden" |
| candidate = "$_gen_dir/$_include_path/fidl.h" |
| }, |
| { |
| golden = "goldens/${info.name}_driver_wire.h.golden" |
| candidate = "$_gen_dir/$_include_path/driver/wire.h" |
| }, |
| { |
| golden = "goldens/${info.name}_driver_wire_messaging.h.golden" |
| candidate = "$_gen_dir/$_include_path/driver/wire_messaging.h" |
| }, |
| { |
| golden = "goldens/${info.name}_driver_wire_messaging.cc.golden" |
| candidate = "$_gen_dir/$_include_path/driver/wire_messaging.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_driver_natural_messaging.h.golden" |
| candidate = "$_gen_dir/$_include_path/driver/natural_messaging.h" |
| }, |
| { |
| golden = "goldens/${info.name}_driver_natural_messaging.cc.golden" |
| candidate = "$_gen_dir/$_include_path/driver/natural_messaging.cc" |
| }, |
| { |
| golden = "goldens/${info.name}_driver_fidl.h.golden" |
| candidate = "$_gen_dir/$_include_path/driver/fidl.h" |
| }, |
| ] |
| } |
| } |
| } |
| } |
| |
| install_host_tools("host") { |
| deps = [ ":fidlgen_cpp" ] |
| outputs = [ "fidlgen_cpp" ] |
| } |
| |
| 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_cpp" ] - [ "fidlgen_cpp" ] == |
| info[denylist_key]) { |
| deps += [ "${info.target}_cpp" ] |
| if (is_fuchsia) { |
| deps += [ |
| "${info.target}_cpp", |
| "${info.target}_cpp", |
| ] |
| } |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":goldens", |
| ":goldens($host_toolchain)", |
| ] |
| deps += [ ":fidlgen_cpp_golden_tests($host_toolchain)" ] |
| } |