| # Copyright 2019 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/host.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/testing/golden_files.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| if (is_host) { |
| cargo_manifest_dir = rebase_path(".", root_build_dir) |
| |
| rustc_binary("fidlgen_rust_next") { |
| edition = "2021" |
| sources = [ |
| "src/config.rs", |
| "src/ident_ext.rs", |
| "src/main.rs", |
| "src/templates/alias.rs", |
| "src/templates/bits.rs", |
| "src/templates/compat/bits.rs", |
| "src/templates/compat/enum.rs", |
| "src/templates/compat/mod.rs", |
| "src/templates/compat/protocol.rs", |
| "src/templates/compat/reserved.rs", |
| "src/templates/compat/struct.rs", |
| "src/templates/compat/table.rs", |
| "src/templates/compat/union.rs", |
| "src/templates/compound_identifier.rs", |
| "src/templates/const.rs", |
| "src/templates/constant.rs", |
| "src/templates/context.rs", |
| "src/templates/denylist.rs", |
| "src/templates/doc_string.rs", |
| "src/templates/enum.rs", |
| "src/templates/filters.rs", |
| "src/templates/library.rs", |
| "src/templates/mod.rs", |
| "src/templates/natural_type.rs", |
| "src/templates/prim.rs", |
| "src/templates/protocol.rs", |
| "src/templates/reserved.rs", |
| "src/templates/service.rs", |
| "src/templates/struct.rs", |
| "src/templates/table.rs", |
| "src/templates/union.rs", |
| "src/templates/wire_type.rs", |
| ] |
| deps = [ |
| "//third_party/rust_crates:argh", |
| "//third_party/rust_crates:askama", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json", |
| "//tools/fidl/fidl_ir", |
| "//tools/fidl/fidl_ir/fidl_ir_util", |
| ] |
| inputs = [ |
| "askama.toml", |
| "templates/alias.askama", |
| "templates/bits.askama", |
| "templates/compat.askama", |
| "templates/compat/bits.askama", |
| "templates/compat/enum.askama", |
| "templates/compat/protocol.askama", |
| "templates/compat/struct.askama", |
| "templates/compat/table.askama", |
| "templates/compat/union.askama", |
| "templates/const.askama", |
| "templates/enum.askama", |
| "templates/library.askama", |
| "templates/protocol.askama", |
| "templates/service.askama", |
| "templates/struct.askama", |
| "templates/table.askama", |
| "templates/union.askama", |
| ] |
| rustenv = [ "CARGO_MANIFEST_DIR=${cargo_manifest_dir}" ] |
| with_unit_tests = true |
| } |
| |
| golden_files("fidlgen_rust_next_golden_tests") { |
| testonly = true |
| |
| deps = [] |
| comparisons = [] |
| foreach(info, fidl_testdata_info) { |
| if (info.denylist + [ "fidlgen_rust_next" ] - [ "fidlgen_rust_next" ] == |
| info.denylist) { |
| deps += [ "${info.target}_rust_next_generate($fidl_toolchain)" ] |
| _library_underscore = string_replace(info.library, ".", "_") |
| comparisons += [ |
| { |
| golden = "goldens/${info.name}.rs.golden" |
| candidate = "${info.fidl_gen_dir}/${info.target_name}/rust_next/fidl_next_${_library_underscore}.rs" |
| }, |
| ] |
| } |
| } |
| } |
| } |
| |
| install_host_tools("host") { |
| deps = [ ":fidlgen_rust_next" ] |
| outputs = [ "fidlgen_rust_next" ] |
| } |
| |
| 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_next" ] - |
| [ "fidlgen_rust_next" ] == info[denylist_key]) { |
| deps += [ "${info.target}_rust_next" ] |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fidlgen_rust_next_golden_tests($host_toolchain)", |
| ":fidlgen_rust_next_test($host_toolchain)", |
| ":goldens", |
| ":goldens($host_toolchain)", |
| "examples/calculator:tests", |
| ] |
| } |