| # Copyright 2019 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. |
| |
| # These rules are only used by the Fuchsia host build |
| # (i.e. generating host executables for testing with the Fuchsia build system). |
| |
| import("build_settings.gni") |
| |
| _is_fuchsia_tree = defined(is_fuchsia_tree) && is_fuchsia_tree |
| if (_is_fuchsia_tree) { |
| import("//build/testing/test_spec.gni") |
| } |
| |
| # A target that provides the GTest main() function for the host. |
| graphics_compute_gtest_main_target = "//src/lib/fxl/test:gtest_main" |
| |
| # A target providing access to Vulkan at compile time when added to deps. |
| # TODO(fxbug.dev/25488): Change this to a more recent upstream. |
| graphics_compute_vulkan_loader_target = "${graphics_compute_dir}/gn/host:vulkan" |
| |
| # NOTE: These definitions are used by those in build_rules.gni. |
| |
| # Accepts same variables as GN executable() rule, as well as: |
| # needs_vulkan: Optional flag. Set to true to add Vulkan dependencies. |
| template("graphics_compute_executable_rule") { |
| executable(target_name) { |
| forward_variables_from(invoker, |
| "*", |
| [ |
| # Avoid clobbering default configs |
| "configs", |
| "needs_vulkan", |
| ]) |
| if (defined(invoker.configs)) { |
| configs += invoker.configs |
| } |
| if (defined(invoker.needs_vulkan) && invoker.needs_vulkan) { |
| if (!defined(deps)) { |
| deps = [] |
| } |
| deps += [ graphics_compute_vulkan_loader_target ] |
| } |
| } |
| } |
| |
| # Accepts same variables as GN executable() rule, as well as: |
| # needs_vulkan: Optional flag. Set to true to add Vulkan dependencies. |
| template("graphics_compute_test_rule") { |
| # Generate the executable |
| _binary_target = "bin_${target_name}" |
| graphics_compute_executable_rule(_binary_target) { |
| testonly = true |
| output_name = invoker.target_name |
| forward_variables_from(invoker, "*", [ "target_name" ]) |
| } |
| |
| _deps = [ ":${_binary_target}" ] |
| |
| # For Fuchsia, ensure the test is visible for 'fx run-host-tests <test_name>' |
| if (_is_fuchsia_tree) { |
| _test_spec_target_name = "${target_name}__test_spec" |
| test_spec(_test_spec_target_name) { |
| target = ":${invoker.target_name}" |
| path = "${root_out_dir}/${invoker.target_name}" |
| } |
| |
| _deps += [ ":${_test_spec_target_name}" ] |
| } |
| |
| group(target_name) { |
| testonly = true |
| deps = _deps |
| } |
| } |