blob: 9da1b6b706b20e8cb40fb88ad332190a9d338337 [file] [log] [blame]
# Copyright 2021 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/fuchsia_package.gni")
import("//build/drivers/driver_manifest.gni")
# Defines a Fuchsia driver package.
# A fuchsia_driver_package is a fuchsia_package but with extra
# metadata so that the drivers inside the package can be collected into a
# Driver Manifest. Normally, these packages will be included in the base_driver_package
# list and included in the Base Driver Manifest.
#
# A driver is a shared library that's placed in the /driver/ directory of the package.
# Drivers are normally built with the `fuchsia_driver` build target.
#
# The fuchsia_driver_package does not need to contain any components, although
# components placed in the package will behave normally.
#
# For more information on a fuchsia_package see:
# //build/components/fuchsia_package.gni
#
# Parameters:
#
# driver_components (required)
# A list of driver components to include in the package.
# Type: list(labels)
#
# package_name (optional)
# The name of the package.
# Type: string
# Default: target_name
#
# disable_elf_binaries_checks (optional)
# Set to true to disable ELF binaries verification checks. Useful
# if your package includes non-Fuchsia ELF binaries, or if some
# of them are unstripped.
# Type: boolean
# Default: false
#
# deps
# testonly
# visibility
template("fuchsia_driver_package") {
if (current_toolchain == default_toolchain) {
assert(
defined(invoker.driver_components) && invoker.driver_components != [],
"`driver_components` must be specified when calling fuchsia_driver_package($target_name)")
package_name = target_name
if (defined(invoker.package_name)) {
package_name = invoker.package_name
}
driver_manifest_target = "${target_name}_driver_package_manifest"
driver_manifest(driver_manifest_target) {
forward_variables_from(invoker, [ "testonly" ])
package_url = "fuchsia-pkg://fuchsia.com/${package_name}"
deps = invoker.driver_components
# We don't want individual package's driver manifests to end up in the image.
# Instead these files will be collected by one `combined_driver_manifest` target.
install_as_config_resource = false
}
fuchsia_package(target_name) {
forward_variables_from(invoker, "*")
if (!defined(deps)) {
deps = []
}
deps += [ ":${driver_manifest_target}" ]
deps += invoker.driver_components
is_driver_package = true
}
} else {
group(target_name) {
forward_variables_from(invoker, [ "testonly" ])
deps = [ ":$target_name($default_toolchain)" ]
}
not_needed(invoker, "*")
}
}