| # 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/rust/fidl_rust.gni") |
| import("//build/rust/toolchain.gni") |
| import("//build/testing/golden_test.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| go_library("gopkg") { |
| name = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_rust/..." |
| deps = [ |
| "//tools/fidl/lib/fidlgen", |
| "//tools/fidl/lib/fidlgentest", |
| ] |
| sources = [ |
| "codegen/bits.tmpl.go", |
| "codegen/codegen.go", |
| "codegen/const.tmpl.go", |
| "codegen/enum.tmpl.go", |
| "codegen/handle_metadata_wrappers.tmpl.go", |
| "codegen/ir.go", |
| "codegen/ir_test.go", |
| "codegen/protocol.tmpl.go", |
| "codegen/result.tmpl.go", |
| "codegen/service.tmpl.go", |
| "codegen/sourcefile.tmpl.go", |
| "codegen/struct.tmpl.go", |
| "codegen/table.tmpl.go", |
| "codegen/union.tmpl.go", |
| "main.go", |
| ] |
| } |
| |
| go_binary("fidlgen_rust") { |
| gopackage = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_rust" |
| sdk_category = "partner" |
| deps = [ ":gopkg" ] |
| } |
| |
| install_host_tools("host") { |
| deps = [ ":fidlgen_rust" ] |
| outputs = [ "fidlgen_rust" ] |
| } |
| |
| if (is_host) { |
| fidlc_target = "//tools/fidl/fidlc($host_toolchain)" |
| |
| go_test("fidlgen_rust_lib_tests") { |
| gopackages = [ "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_rust/codegen" ] |
| |
| fidlc_binary = get_label_info(fidlc_target, "root_out_dir") + "/fidlc" |
| args = [ |
| "--fidlc", |
| rebase_path(fidlc_binary, root_build_dir), |
| ] |
| |
| deps = [ |
| ":gopkg", |
| "//third_party/golibs:github.com/google/go-cmp", |
| ] |
| non_go_deps = [ ":copy_fidlc" ] |
| } |
| |
| host_test_data("copy_fidlc") { |
| sources = [ get_label_info(fidlc_target, "root_out_dir") + "/fidlc" ] |
| deps = [ fidlc_target ] |
| } |
| } |
| |
| rustfmt = rebase_path("$fidl_rust_tools_dir/bin/rustfmt", root_build_dir) |
| rustfmt_config = rebase_path("//rustfmt.toml", root_build_dir) |
| |
| golden_test("fidlgen_rust_golden_tests") { |
| goldens_dir = "goldens" |
| reformat_goldens_command = "'${rustfmt}' --config-path '${rustfmt_config}'" |
| deps = [] |
| entries = [] |
| foreach(info, fidl_testdata_info) { |
| if (info.denylist + [ "fidlgen_rust" ] - [ "fidlgen_rust" ] == |
| info.denylist) { |
| deps += [ "${info.target}_rust_generate($rust_toolchain)" ] |
| library_underscore = string_replace(info.library, ".", "_") |
| entries += [ |
| { |
| golden = "${info.name}.rs.golden" |
| generated = "${info.fidl_gen_dir}/${info.target_name}/fidl_${library_underscore}.rs" |
| }, |
| ] |
| } |
| } |
| } |
| |
| 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_rust" ] - [ "fidlgen_rust" ] == |
| info[denylist_key]) { |
| deps += [ "${info.target}-rustc" ] |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fidlgen_rust_golden_tests($host_toolchain)", |
| ":fidlgen_rust_lib_tests($host_toolchain)", |
| ":goldens", |
| ":goldens($host_toolchain)", |
| ] |
| } |