blob: 973ca92a7daeadd0760e0a8e8181e53a8694c6d4 [file] [log] [blame]
# 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 test binary built with a specific toolchain.
#
# 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 test.
# Type: GN label
# test_toolchain (required)
# The toolchain to use to build the test, e.g. //build/toolchain:linux_x64.
# parameter.
# Type: string
# test_binary (optional)
# The name of the binary produced by test_label. Defaults to target_name.
# Type: string
#
# The remaining parameters are forwarded to the fuchsia_component template.
template("starnix_toolchain_test_component") {
assert(defined(invoker.test_label))
assert(defined(invoker.test_toolchain))
if (defined(invoker.test_binary)) {
test_binary = invoker.test_binary
} else {
test_binary = target_name
}
test_label = "${invoker.test_label}(${invoker.test_toolchain})"
resource("${target_name}_resource") {
testonly = true
out_dir = get_label_info(test_label, "root_out_dir")
sources = [ "${out_dir}/${test_binary}" ]
outputs = [ "data/tests/${test_binary}" ]
deps = [ test_label ]
}
fuchsia_test_component(target_name) {
forward_variables_from(invoker, "*", [ "test_label" ])
testonly = true
check_references = false
manifest = "meta/${target_name}.cml"
if (!defined(deps)) {
deps = []
}
deps += [ ":${target_name}_resource" ]
}
}