| # 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/fidl/toolchain.gni") |
| import("//build/go/go_binary.gni") |
| import("//build/go/go_library.gni") |
| import("//build/host.gni") |
| import("//build/rust/fidl_rust.gni") |
| import("//build/testing/golden_test.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| import("//tools/fidl/lib/fidlgentest/fidlgentest_go_test.gni") |
| |
| if (is_host) { |
| go_library("gopkg") { |
| name = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_rust/..." |
| deps = [ "//tools/fidl/lib/fidlgen" ] |
| sources = [ |
| "codegen/bits.tmpl", |
| "codegen/codegen.go", |
| "codegen/const.tmpl", |
| "codegen/enum.tmpl", |
| "codegen/handle_metadata_wrappers.tmpl", |
| "codegen/ir.go", |
| "codegen/ir_test.go", |
| "codegen/protocol.tmpl", |
| "codegen/result.tmpl", |
| "codegen/service.tmpl", |
| "codegen/sourcefile.tmpl", |
| "codegen/struct.tmpl", |
| "codegen/table.tmpl", |
| "codegen/union.tmpl", |
| "main.go", |
| ] |
| } |
| |
| go_binary("fidlgen_rust") { |
| gopackage = "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_rust" |
| sdk_category = "partner" |
| deps = [ ":gopkg" ] |
| } |
| |
| fidlgentest_go_test("fidlgen_rust_lib_tests") { |
| gopackages = [ "go.fuchsia.dev/fuchsia/tools/fidl/fidlgen_rust/codegen" ] |
| deps = [ |
| ":gopkg", |
| "//third_party/golibs:github.com/google/go-cmp", |
| ] |
| } |
| |
| golden_test("fidlgen_rust_golden_tests") { |
| goldens_dir = "goldens" |
| reformat_goldens_bin = "$rustc_prefix/bin/rustfmt" |
| reformat_goldens_args = [ |
| "--config-path", |
| rebase_path("//rustfmt.toml", root_build_dir), |
| ] |
| reformat_goldens_inputs = [ "//rustfmt.toml" ] |
| deps = [] |
| entries = [] |
| foreach(info, fidl_testdata_info) { |
| if (info.denylist + [ "fidlgen_rust" ] - [ "fidlgen_rust" ] == |
| info.denylist) { |
| deps += [ "${info.target}_rust_generate($fidl_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" |
| }, |
| ] |
| } |
| } |
| } |
| } |
| |
| install_host_tools("host") { |
| deps = [ ":fidlgen_rust" ] |
| outputs = [ "fidlgen_rust" ] |
| } |
| |
| 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)", |
| ] |
| } |