| # Copyright 2025 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/bazel/bazel_build_action.gni") |
| |
| # A GN wrapper for a Bazel board input bundle set target. This template is |
| # useful for GN board targets that consume the created BIB set directory. |
| # |
| # Parameters |
| # |
| # name (optional) |
| # Name of the board input bundle set. |
| # Type: string |
| # Default: $target_name |
| # |
| # bazel_board_input_bundle_set_target (required) |
| # The Bazel board input bundle set target to build. |
| # Type: label (from BUILD.bazel) |
| # |
| # deps |
| # metadata |
| # testonly |
| # visibility |
| # |
| template("bazel_board_input_bundle_set") { |
| assert(defined(invoker.bazel_board_input_bundle_set_target), |
| "bazel_board_input_bundle_set_target is required") |
| |
| bib_set_name = target_name |
| if (defined(invoker.name)) { |
| bib_set_name = invoker.name |
| } |
| |
| board_input_bundle_set_target = target_name |
| board_input_bundle_set_out = |
| "${target_out_dir}/${board_input_bundle_set_target}" |
| bazel_target = invoker.bazel_board_input_bundle_set_target |
| |
| bazel_build_action(board_input_bundle_set_target) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "metadata", |
| "testonly", |
| "visibility", |
| "inputs", |
| "remote_build", |
| ]) |
| |
| bazel_target = bazel_target |
| |
| # Directory outputs are OK because `board_input_bundle.json` correctly |
| # represents the freshness of all outputs. |
| directory_outputs = [ |
| { |
| bazel_dir = "{{BAZEL_TARGET_OUT_DIR}}/{{BAZEL_TARGET_NAME}}" |
| ninja_dir = board_input_bundle_set_target |
| tracked_files = [ "board_input_bundle_set.json" ] |
| }, |
| ] |
| |
| metadata = { |
| board_input_bundle_sets_barrier = [] |
| board_input_bundle_sets = [ |
| { |
| label = get_label_info(":${board_input_bundle_set_target}", |
| "label_with_toolchain") |
| name = bib_set_name |
| cipd_name = bib_set_name |
| outdir = rebase_path(board_input_bundle_set_out, root_build_dir) |
| }, |
| ] |
| } |
| } |
| } |