blob: 88ea9d37befc9cf9394634e32212c0e51563cb15 [file]
# Copyright 2025 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")
import("//build/config/fuchsia_cxx_version.gni")
import("//build/test.gni")
# This is an SDK C++ test executable for each supported C++ version.
#
# It will generate multiple targets, each named
# `${target_name}-cxx${cxx_version}`. Then it will create a group depending on
# those targets named `${target_name}`.
#
# Parameters
#
# * cxx_versions
# - Optional: Compile the C++ tests against these C++ versions.
# - Type: list(int)
# - Default: fuchsia_sdk_cxx_supported_versions
#
# See test() for other parameters. Note that `output_name` is specifically
# excluded, because this creates a binary with a different suffix for each
# target.
#
template("sdk_cpp_test") {
_test_deps = []
foreach(cxx_version, invoker.cxx_versions) {
_test_target = "${target_name}-cxx${cxx_version}"
_test_deps += [ ":${_test_target}" ]
test(_test_target) {
forward_variables_from(invoker,
"*",
# explicitly leave out `output_name` to avoid
# collisions.
[ "output_name" ])
configs += [ "//build/config:c++${cxx_version}" ]
}
}
group(target_name) {
testonly = true
deps = _test_deps
}
}
set_defaults("sdk_cpp_test") {
cxx_versions = fuchsia_sdk_cxx_supported_versions
configs = default_executable_configs
}