| # Copyright 2018 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/host.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/testing/golden_file.gni") |
| import("//tools/cmc/build/cml.gni") |
| import("//tools/configc/build/config.gni") |
| |
| if (is_host) { |
| rustc_binary("configc") { |
| edition = "2021" |
| name = "configc" |
| |
| deps = [ |
| "//sdk/fidl/fuchsia.component.config:fuchsia.component.config-rustc", |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl-rustc", |
| "//src/lib/assembly/validate_product", |
| "//src/lib/fidl/rust/fidl", |
| "//src/sys/lib/cm_rust", |
| "//src/sys/lib/config_encoder", |
| "//src/sys/pkg/lib/fuchsia-pkg", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:argh", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:serde_json5", |
| "//tools/lib/config_client", |
| "//tools/lib/config_value_file", |
| ] |
| |
| sources = [ |
| "src/client_cpp.rs", |
| "src/client_fidl.rs", |
| "src/client_rust.rs", |
| "src/common.rs", |
| "src/cvf.rs", |
| "src/dump_values.rs", |
| "src/main.rs", |
| "src/validate_package.rs", |
| ] |
| } |
| } |
| |
| install_host_tools("install") { |
| deps = [ ":configc($host_toolchain)" ] |
| |
| outputs = [ "configc" ] |
| } |
| |
| # Config Library Golden Tests |
| cm("config_manifest") { |
| manifest = "goldens/config_manifest.cml" |
| output_name = "config_manifest.cm" |
| config_values_package_path = "goldens/config_values.json5" |
| } |
| |
| fidl_config_client_lib_source("fidl_config_lib") { |
| manifest_outputs = get_target_outputs(":config_manifest") |
| compiled_manifest = manifest_outputs[0] |
| name = "my.config.lib" |
| deps = [ ":config_manifest" ] |
| testonly = true |
| } |
| |
| rust_config_client_lib_source("rust_config_lib") { |
| manifest_outputs = get_target_outputs(":config_manifest") |
| compiled_manifest = manifest_outputs[0] |
| fidl_library_name = "my.config.lib" |
| deps = [ ":config_manifest" ] |
| testonly = true |
| } |
| |
| cpp_config_client_lib_source("cpp_elf_config_lib") { |
| manifest_outputs = get_target_outputs(":config_manifest") |
| compiled_manifest = manifest_outputs[0] |
| fidl_library_name = "my.config.lib" |
| deps = [ ":config_manifest" ] |
| flavor = "elf" |
| testonly = true |
| } |
| |
| cpp_config_client_lib_source("cpp_driver_config_lib") { |
| manifest_outputs = get_target_outputs(":config_manifest") |
| compiled_manifest = manifest_outputs[0] |
| fidl_library_name = "my.config.lib" |
| deps = [ ":config_manifest" ] |
| flavor = "driver" |
| testonly = true |
| } |
| |
| golden_file("fidl_config_lib_golden_test") { |
| golden = "goldens/config.fidl.golden" |
| lib_outputs = get_target_outputs(":fidl_config_lib") |
| current = lib_outputs[0] |
| deps = [ ":fidl_config_lib" ] |
| testonly = true |
| } |
| |
| golden_file("rust_config_lib_golden_test") { |
| golden = "goldens/config.rs.golden" |
| lib_outputs = get_target_outputs(":rust_config_lib") |
| current = lib_outputs[0] |
| deps = [ ":rust_config_lib" ] |
| testonly = true |
| } |
| |
| golden_file("cpp_elf_config_lib_cc_golden_test") { |
| golden = "goldens/config.cc.elf.golden" |
| lib_outputs = get_target_outputs(":cpp_elf_config_lib") |
| current = lib_outputs[0] |
| deps = [ ":cpp_elf_config_lib" ] |
| testonly = true |
| } |
| |
| golden_file("cpp_elf_config_lib_h_golden_test") { |
| golden = "goldens/config.h.elf.golden" |
| lib_outputs = get_target_outputs(":cpp_elf_config_lib") |
| current = lib_outputs[1] |
| deps = [ ":cpp_elf_config_lib" ] |
| testonly = true |
| } |
| |
| golden_file("cpp_driver_config_lib_cc_golden_test") { |
| golden = "goldens/config.cc.driver.golden" |
| lib_outputs = get_target_outputs(":cpp_driver_config_lib") |
| current = lib_outputs[0] |
| deps = [ ":cpp_driver_config_lib" ] |
| testonly = true |
| } |
| |
| golden_file("cpp_driver_config_lib_h_golden_test") { |
| golden = "goldens/config.h.driver.golden" |
| lib_outputs = get_target_outputs(":cpp_driver_config_lib") |
| current = lib_outputs[1] |
| deps = [ ":cpp_driver_config_lib" ] |
| testonly = true |
| } |
| |
| _cm = get_target_outputs(":config_manifest") |
| _cm = _cm[0] |
| cvf("example_values") { |
| cm = _cm |
| value_file = "goldens/config_values.json5" |
| deps = [ ":config_manifest" ] |
| } |
| |
| _cvf = get_target_outputs(":example_values") |
| _cvf = _cvf[0] |
| _dumped_values = "$target_out_dir/dumped_values.json" |
| dump_structured_config("dump_example_values") { |
| cm = _cm |
| cvf = _cvf |
| output = _dumped_values |
| deps = [ |
| ":config_manifest", |
| ":example_values", |
| ] |
| } |
| |
| golden_file("value_dump_golden_test") { |
| golden = "goldens/dumped_values.json.golden" |
| current = _dumped_values |
| deps = [ ":dump_example_values" ] |
| testonly = true |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":cpp_driver_config_lib_cc_golden_test", |
| ":cpp_driver_config_lib_h_golden_test", |
| ":cpp_elf_config_lib_cc_golden_test", |
| ":cpp_elf_config_lib_h_golden_test", |
| ":fidl_config_lib_golden_test", |
| ":rust_config_lib_golden_test", |
| ":value_dump_golden_test", |
| ] |
| } |
| |
| if (is_host) { |
| group("host_tests") { |
| testonly = true |
| deps = [ "tests:fail_validate_without_config" ] |
| } |
| } |