| # 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("//tools/cmc/build/cmc.gni") |
| |
| # Generates a component manifest for a test. |
| # |
| # Good enough for simple unit tests and not a whole lot more. |
| # For use only by other templates in this directory. |
| # |
| # Parameters |
| # |
| # deps |
| # metadata |
| # visibility |
| template("fuchsia_test_component_manifest") { |
| invoker_deps = [] |
| if (defined(invoker.deps)) { |
| invoker_deps = invoker.deps |
| } |
| |
| if (defined(invoker.metadata)) { |
| metadata_target = "${target_name}_metadata" |
| group(metadata_target) { |
| forward_variables_from(invoker, [ "metadata" ]) |
| testonly = true |
| visibility = [ ":*" ] |
| } |
| invoker_deps += [ ":$metadata_target" ] |
| } |
| |
| # Collect `program` part with its own barrier, |
| # since executables may depend on other executables. |
| program_target = "${target_name}_program" |
| generated_file(program_target) { |
| deps = invoker_deps |
| data_keys = [ "test_component_manifest_program" ] |
| walk_keys = [ "test_component_manifest_program_barrier" ] |
| outputs = [ "$target_out_dir/${target_name}.json" ] |
| output_conversion = "json" |
| testonly = true |
| visibility = [ ":*" ] |
| } |
| |
| # Collect any other manifest elements |
| other_target = "${target_name}_other" |
| generated_file(other_target) { |
| deps = invoker_deps |
| data_keys = [ "test_component_manifest_cml" ] |
| walk_keys = [ "test_component_manifest_barrier" ] |
| outputs = [ "$target_out_dir/${target_name}.json" ] |
| output_conversion = "json" |
| testonly = true |
| visibility = [ ":*" ] |
| } |
| |
| cmc_merge(target_name) { |
| forward_variables_from(invoker, [ "visibility" ]) |
| testonly = true |
| output_name = invoker.target_name + ".cml" |
| deps = [ |
| ":$other_target", |
| ":$program_target", |
| ] |
| sources = [] |
| foreach(dep, deps) { |
| sources += get_target_outputs(dep) |
| } |
| testonly = true |
| } |
| } |