| # Copyright 2024 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 configuration target. This template is useful |
| # for GN product target that can consume the created board directory. |
| # |
| # Parameters |
| # |
| # name (optional) |
| # Name of the board. |
| # Type: string |
| # Default: $target_name |
| # |
| # bazel_board_configuration_target (required) |
| # The Bazel board configuration target to build. |
| # Type: label (from BUILD.bazel) |
| # |
| # deps |
| # metadata |
| # testonly |
| # visibility |
| # |
| template("bazel_board_configuration") { |
| assert(defined(invoker.bazel_board_configuration_target), |
| "bazel_board_configuration_target is required") |
| |
| board_name = target_name |
| if (defined(invoker.name)) { |
| board_name = invoker.name |
| } |
| |
| board_configuration_target = target_name |
| board_configuration_out = "${target_out_dir}/${board_configuration_target}" |
| bazel_target = invoker.bazel_board_configuration_target |
| |
| bazel_build_action(board_configuration_target) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "metadata", |
| "testonly", |
| "visibility", |
| "inputs", |
| "remote_build", |
| ]) |
| |
| bazel_target = bazel_target |
| |
| # Directory outputs are OK because `board_configuration.json` correctly |
| # represents the freshness of all outputs. |
| directory_outputs = [ |
| { |
| bazel_dir = "{{BAZEL_TARGET_OUT_DIR}}/{{BAZEL_TARGET_NAME}}" |
| ninja_dir = board_configuration_target |
| copy_debug_symbols = true |
| tracked_files = [ "board_configuration.json" ] |
| }, |
| ] |
| |
| metadata = { |
| board_input_bundle_sets_barrier = [] |
| board_configs = [ |
| { |
| label = get_label_info(":${board_configuration_target}", |
| "label_with_toolchain") |
| name = board_name |
| cipd_name = board_name |
| outdir = rebase_path(board_configuration_out, root_build_dir) |
| }, |
| ] |
| } |
| } |
| } |