| # Copyright 2021 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/compiled_action.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| rustc_binary("parser_bin") { |
| edition = 2018 |
| |
| sources = [ "main.rs" ] |
| |
| source_root = "main.rs" |
| |
| deps = [ |
| "//src/devices/tools/fidlgen_banjo:lib", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:structopt", |
| ] |
| } |
| |
| # Runs the Rust parser against the given FIDL library. |
| template("parsing_test") { |
| assert(defined(invoker.ir), "Need to specify an IR file") |
| |
| compiled_action(target_name) { |
| forward_variables_from(invoker, [ "deps" ]) |
| |
| tool = ":parser_bin" |
| |
| testonly = true |
| |
| inputs = [ invoker.ir ] |
| |
| outputs = [ "$target_gen_dir/$target_name.success.stamp" ] |
| |
| args = [ |
| "--input", |
| rebase_path(inputs[0], root_build_dir), |
| "--stamp", |
| rebase_path(outputs[0], root_build_dir), |
| ] |
| } |
| } |
| |
| all_test_deps = [] |
| foreach(info, fidl_testdata_info) { |
| parsing_test(info.target_name) { |
| deps = [ "${info.target}($fidl_toolchain)" ] |
| ir = "${info.fidl_gen_dir}/${info.target_name}.fidl.json" |
| } |
| all_test_deps += [ ":${info.target_name}" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = all_test_deps |
| } |
| |
| group("parser") { |
| testonly = true |
| deps = [ ":parser_bin" ] |
| } |