| # Copyright 2022 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/components.gni") |
| |
| # Defines a Fuchsia component that contains a host test. |
| # |
| # This template expects to find a CML file named "meta/${test_name}.cml" where |
| # "test_name" is the name of this target. This file is used as the component |
| # manifest for the test. |
| # |
| # Parameters |
| # |
| # test_label (required) |
| # The label of the host test. The template will add the "($host_toolchain)" |
| # parameter. |
| # Type: GN label |
| # |
| # The remaining parameters are forwarded to the fuchsia_component template. |
| template("starnix_host_test_component") { |
| assert(host_os == "linux") |
| assert(defined(invoker.test_label)) |
| |
| test_name = target_name |
| test_label = "${invoker.test_label}($host_toolchain)" |
| |
| resource("${test_name}_resource") { |
| testonly = true |
| out_dir = get_label_info(test_label, "root_out_dir") |
| sources = [ "${out_dir}/${test_name}" ] |
| outputs = [ "data/tests/${test_name}" ] |
| deps = [ test_label ] |
| } |
| |
| fuchsia_component(test_name) { |
| forward_variables_from(invoker, "*", [ "test_label" ]) |
| |
| testonly = true |
| check_references = false |
| manifest = "meta/${test_name}.cml" |
| |
| if (!defined(deps)) { |
| deps = [] |
| } |
| |
| deps += [ ":${test_name}_resource" ] |
| } |
| } |