| # 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. |
| |
| _migration_example_bazel_targets = [ |
| { |
| bazel_label = "//build/beads/.agent/skills/migrating_host_tool_to_bazel/examples/go/after:go_example_bin_migrated" |
| |
| # This copy_outputs is necessary because `go_binary` from |
| # `rules_go` in Bazel places the executable in a |
| # subdirectory of the output directory. |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/go_example_bin_migrated_/go_example_bin_migrated" |
| ninja = "go_example_bin_migrated" |
| }, |
| ] |
| install_host_tool = true |
| }, |
| ] |
| |
| declare_args() { |
| # A list of scopes describing Bazel host targets that are included in the SDK. |
| # |
| # This is a separate because they can be cross-compiled on SDK builders. |
| sdk_host_tool_bazel_targets = [ |
| { |
| bazel_label = "//zircon/tools/merkleroot" |
| }, |
| ] |
| } |
| |
| declare_args() { |
| # A list of scopes describing Bazel host targets that can be built directly |
| # with Bazel, without invoking Ninja. These *cannot* depend on any Ninja |
| # artifact. Schema is: |
| # |
| # bazel_label [string]: A Bazel target label, must begin with @ |
| # |
| # bazel_name [string]: Optional filename of Bazel artifact file, in case |
| # it does not match the label. |
| # |
| # ninja_name [GN path]: Optional filename for Ninja hard-link to Bazel |
| # artifact, which will appear under $NINJA_BUILD_DIR/bazel_artifacts/, |
| # defaults to bazel_name. |
| # |
| # install_host_tool [boolean]: Optional, set to true to make it available |
| # to the `fx host-tool <ninja_name>` command. |
| # |
| default_bazel_root_host_targets = |
| sdk_host_tool_bazel_targets + _migration_example_bazel_targets + [ |
| { |
| bazel_label = |
| "//src/lib/testing/expectation/tool:list_test_expectations" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/list_test_expectations" |
| ninja = "list_test_expectations" |
| }, |
| ] |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/rust_test_parser:rust_test_parser" |
| copy_outputs = [ |
| { |
| bazel = |
| "{{BAZEL_TARGET_OUT_DIR}}/rust_test_parser_/rust_test_parser" |
| ninja = "rust_test_parser" |
| }, |
| ] |
| }, |
| { |
| bazel_label = "//tools/fidl/fidl_api_diff:fidl_api_diff" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/fidl_api_diff_/fidl_api_diff" |
| ninja = "fidl_api_diff" |
| }, |
| ] |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/go_test_parser:go_test_parser" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/go_test_parser_/go_test_parser" |
| ninja = "go_test_parser" |
| }, |
| ] |
| }, |
| { |
| bazel_label = "//tools/staticanalysis/rfcmeta:rfcmeta" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/rfcmeta_/rfcmeta" |
| ninja = "rfcmeta" |
| }, |
| ] |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/debug/covargs:covargs" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/covargs_/covargs" |
| ninja = "covargs" |
| }, |
| ] |
| install_host_tool = true # Required by CI recipe |
| }, |
| { |
| bazel_label = "//tools/debug/symbolize:symbolize" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/symbolize_/symbolize" |
| ninja = "symbolize" |
| }, |
| ] |
| }, |
| |
| # First, a target that verifies that the host toolchains work properly, |
| # i.e. can compile and link C++ and Rust binaries properly. |
| { |
| bazel_label = "//build/bazel/toolchains/tests:build" |
| bazel_name = "build.stamp" |
| ninja_name = "bazel_toolchains_tests_build.stamp" |
| }, |
| { |
| bazel_label = "//src/developer/ffx/tools/efi:ffx-efi" |
| ninja_name = "ffx-efi_bazel_unversioned" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/ffx-efi" |
| ninja = "ffx-efi_bazel_unversioned" |
| }, |
| ] |
| }, |
| { |
| bazel_label = "//build/tools/json_validator:json_validator_valico" |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//build/tools/json_merge" |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//build/tools/formatjson5" |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//build/tools/bazel2gn" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/bazel2gn_/bazel2gn" |
| ninja = "bazel2gn" |
| }, |
| ] |
| }, |
| { |
| bazel_label = "//tools/pretty_serial" |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/mdlint" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/mdlint_/mdlint" |
| ninja = "mdlint" |
| }, |
| ] |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/pkgstats/debugdump:debugdump" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/debugdump_/debugdump" |
| ninja = "debugdump" |
| }, |
| ] |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/debroot:debroot" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/debroot_/debroot" |
| ninja = "debroot" |
| }, |
| ] |
| }, |
| { |
| bazel_label = "//tools/whereiscl:whereiscl" |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/whereiscl_/whereiscl" |
| ninja = "whereiscl" |
| }, |
| ] |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/jq5:jq5" |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/rust_extract" |
| install_host_tool = true |
| }, |
| { |
| bazel_label = "//tools/fidl/fidldoc:fidldoc" |
| install_host_tool = true |
| }, |
| |
| # Various tests that we want to ensure can build correctly. |
| # TODO(https://fxbug.dev/514526401): Run these Bazel tests in CQ. |
| { |
| bazel_label = "//tools/check-licenses:tests" |
| bazel_name = "build.stamp" |
| ninja_name = "tools_check-licenses_stamp_tests.stamp" |
| }, |
| { |
| bazel_label = "//tools/whereiscl:tests" |
| bazel_name = "build.stamp" |
| ninja_name = "tools_whereiscl_stamp_tests.stamp" |
| }, |
| ] |
| |
| # A similar list to extend the list above for custom build configuration |
| # in args.gn. |
| bazel_root_host_targets = [] |
| } |
| |
| # A resolved view of all root bazel targets. This computes the default |
| # argument values of each entries, and augments it with new arguments used |
| # internally by the Fuchsia build: |
| # |
| # - gn_label: The GN label of the target to be used from GN to use its |
| # artifact. |
| # |
| # - ninja_output: The GN path to the artifact visible from the Ninja |
| # build directory (i.e. outside of the Bazel output base). |
| # |
| resolved_bazel_root_targets = [] |
| |
| foreach(_root_target, |
| default_bazel_root_host_targets + bazel_root_host_targets) { |
| if (defined(_root_target.bazel_name)) { |
| _bazel_name = _root_target.bazel_name |
| } else { |
| _bazel_name = get_label_info(_root_target.bazel_label, "name") |
| } |
| |
| if (defined(_root_target.ninja_name)) { |
| _ninja_name = _root_target.ninja_name |
| } else { |
| _ninja_name = _bazel_name |
| } |
| |
| _install_host_tool = |
| defined(_root_target.install_host_tool) && _root_target.install_host_tool |
| |
| resolved_bazel_root_targets += [ |
| { |
| bazel_label = _root_target.bazel_label |
| bazel_name = _bazel_name |
| ninja_name = _ninja_name |
| host_bin_label = "//build/bazel/host:bazel_root_host_tools.${_ninja_name}($host_toolchain)" |
| gn_subtarget_label = "//build/bazel/host:bazel_root_targets.${_ninja_name}($default_toolchain)" |
| install_host_tool = _install_host_tool |
| |
| if (defined(_root_target.copy_outputs)) { |
| copy_outputs = _root_target.copy_outputs |
| } |
| }, |
| ] |
| } |