| # 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/dist/distribution_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. |
| # |
| # 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 |
| } |
| |
| distribution_manifest_target = |
| "${target_name}_driver_package_manifest_distribution_manifest" |
| distribution_manifest_file = "${target_gen_dir}/${distribution_manifest_target}.distribution_manifest" |
| distribution_manifest(distribution_manifest_target) { |
| deps = invoker.driver_components |
| forward_variables_from(invoker, [ "testonly" ]) |
| outputs = [ "${distribution_manifest_file}" ] |
| } |
| |
| fuchsia_package(target_name) { |
| forward_variables_from(invoker, "*") |
| if (!defined(deps)) { |
| deps = [] |
| } |
| deps += [ ":${distribution_manifest_target}" ] |
| deps += invoker.driver_components |
| is_driver_package = true |
| metadata = { |
| # Used by the assembled_system() template. |
| driver_package_component_files = [ |
| { |
| package_name = package_name |
| distribution_manifest = |
| rebase_path("${distribution_manifest_file}", root_build_dir) |
| }, |
| ] |
| driver_package_component_files_barrier = [] |
| } |
| } |
| } else { |
| group(target_name) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| deps = [ ":$target_name($default_toolchain)" ] |
| } |
| not_needed(invoker, "*") |
| } |
| } |