| # 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}`. It does not create a target for |
| # `${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") { |
| foreach(cxx_version, invoker.cxx_versions) { |
| _test_target = "${target_name}-cxx${cxx_version}" |
| test(_test_target) { |
| forward_variables_from( |
| invoker, |
| "*", |
| # explicitly leave out `output_name` to avoid collisions. |
| [ "output_name" ]) |
| |
| configs += [ "//build/config:c++${cxx_version}" ] |
| } |
| } |
| } |
| |
| set_defaults("sdk_cpp_test") { |
| cxx_versions = fuchsia_sdk_cxx_supported_versions |
| configs = default_executable_configs |
| } |