blob: 16120af0117b7466b2f505fd405fbf5a164deef3 [file] [log] [blame]
# 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 platform build.
import("//build/package.gni")
import("//build/test/test_package.gni")
import("//third_party/vulkan_loader_and_validation_layers/layers/layers.gni")
import("build_settings.gni")
# A target providing access to Vulkan at compile time when added to deps.
# TODO(SPN-14): Change this to a more recent upstream.
graphics_compute_vulkan_loader_target =
"//third_party/vulkan_loader_and_validation_layers:vulkan"
# Generate an executable for the graphics compute project.
# This also generates a Fuchsia package for it, using a default .cmx file
# that can be overriden by providing a "meta" argument.
#
# Expect all variables supported by the Fuchsia package() template.
#
template("graphics_compute_executable") {
_binary_name = "bin_${target_name}"
executable(_binary_name) {
forward_variables_from(invoker,
"*",
[
"loadable_modules",
"meta",
"resources",
"target_name",
])
output_name = invoker.target_name
}
package(target_name) {
forward_variables_from(invoker, "*")
if (!defined(deps)) {
deps = []
}
deps += [ ":${_binary_name}" ]
binary = target_name
if (!defined(meta)) {
meta = [
{
path =
rebase_path("${graphics_compute_dir}/gn/meta/default_package.cmx")
dest = "$target_name.cmx"
},
]
}
}
}
# Generate a Vulkan-based executable for the graphics compute project.
# Compared to graphics_compute_executable(), this adds Vulkan dependencies
# automatically to the executable and its Fuchsia package.
#
template("graphics_compute_vulkan_executable") {
graphics_compute_executable(target_name) {
forward_variables_from(invoker, "*")
if (!defined(deps)) {
deps = []
}
deps += [ graphics_compute_vulkan_loader_target ]
if (!defined(public_deps)) {
public_deps = []
}
public_deps += vulkan_validation_layers.public_deps
if (!defined(loadable_modules)) {
loadable_modules = []
}
loadable_modules += vulkan_validation_layers.loadable_modules
if (!defined(resources)) {
resources = []
}
resources = vulkan_validation_layers.resources
if (!defined(meta)) {
meta = [
{
path =
rebase_path("${graphics_compute_dir}/gn/meta/vulkan_package.cmx")
dest = "$target_name.cmx"
},
]
}
}
}
# NOTE: DO NOT CALL DIRECTLY, use graphics_compute_unittest_package() instead.
#
# Accepts the same variables as graphics_compute_unittests_package()
#
template("graphics_compute_unittest_package_rule") {
_package_name = get_label_info(target_name, "name")
# Generate the binary test program that will end up in the package.
_package_binary = "bin_${_package_name}"
executable(_package_binary) {
testonly = true
forward_variables_from(invoker,
"*",
[
"tests",
"target_name",
])
if (!defined(deps)) {
deps = []
}
deps += invoker.tests
deps += [
# This version sets up logging appropriately for Fuchsia on startup.
"//src/lib/fxl/test:gtest_main",
]
}
unittest_package(target_name) {
forward_variables_from(invoker, "*", [ "tests" ])
tests = [
{
name = _package_binary
},
]
deps = [
":${_package_binary}",
]
}
}