| # Copyright 2024 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. | |
| # Declares a C/C++ executable that's a test binary | |
| # | |
| # This disables some otherwise-global optimization settings that are | |
| # unnecessary on for most test executables. | |
| # | |
| # Parameters | |
| # | |
| # * disable_lto | |
| # - Optional: disables LTO during the linking of the test executable | |
| # - Type: boolean | |
| # - Default: true | |
| template("cc_test_executable") { | |
| executable(target_name) { | |
| forward_variables_from(invoker, | |
| "*", | |
| [ | |
| "disable_lto", | |
| # params requiring special forwarding behavior | |
| "testonly", | |
| "visibility", | |
| ]) | |
| forward_variables_from(invoker, | |
| [ | |
| "testonly", | |
| "visibility", | |
| ]) | |
| if (defined(invoker.disable_lto)) { | |
| disable_lto = invoker.disable_lto | |
| } else { | |
| disable_lto = true | |
| } | |
| # Like other test executables, emit symbolizer markup from sanitizers on | |
| # Linux hosts. | |
| if (!defined(deps)) { | |
| deps = [] | |
| } | |
| deps += [ "//build/config:test_executable_deps" ] | |
| if (disable_lto && !is_gcc) { | |
| if (!defined(configs)) { | |
| configs = [] | |
| } | |
| configs += [ "//build/config/lto:no-fat-lto-objects-linking" ] | |
| } | |
| } | |
| } | |
| set_defaults("cc_test_executable") { | |
| configs = default_executable_configs | |
| } |