| # Copyright 2026 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/python/python_action.gni") |
| import("//build/python/python_binary.gni") |
| |
| if (is_host) { |
| python_binary("verify_build_commands") { |
| testonly = true |
| main_source = "verify_build_commands.py" |
| sources = [ |
| "//build/api/ninja_artifacts.py", |
| "//build/bazel/scripts/bazel_build_args.py", |
| "//build/bazel/scripts/build_utils.py", |
| "//build/beads/scripts/build_command_query_utils.py", |
| "//build/beads/scripts/gn_runner.py", |
| "//build/beads/scripts/normalize_rustc_args.py", |
| "//build/beads/scripts/shell_utils.py", |
| ] |
| } |
| |
| python_action("verify_build_commands_for_example") { |
| # This runs `bazel aquery`, which will block if other Bazel commands are |
| # running. So use the same pool as other Bazel actions to avoid conflicts. |
| pool = "//:console($default_toolchain)" |
| |
| testonly = true |
| binary_label = ":verify_build_commands" |
| outputs = [ "${target_out_dir}/verify_build_commands_for_example.stamp" ] |
| |
| _ninja_outputs_json = "${root_build_dir}/ninja_outputs.json" |
| _manifest = "//build/beads/verifications/targets_to_compare.json" |
| args = [ |
| "--fuchsia_dir", |
| rebase_path("//", root_build_dir), |
| "--build_dir", |
| rebase_path(root_build_dir, root_build_dir), |
| "--ninja_outputs_json", |
| rebase_path(_ninja_outputs_json, root_build_dir), |
| "--ninja_bin", |
| rebase_path("//prebuilt/third_party/ninja/${host_platform}/ninja", |
| root_build_dir), |
| "--manifest", |
| rebase_path(_manifest, root_build_dir), |
| "--temp_dir", |
| rebase_path("${target_gen_dir}", root_build_dir), |
| "--stamp", |
| rebase_path(outputs[0], root_build_dir), |
| ] |
| inputs = [ |
| _ninja_outputs_json, |
| "//prebuilt/third_party/ninja/${host_platform}/ninja", |
| _manifest, |
| |
| # Any build file changes should trigger rerunning this action. |
| "rust/BUILD.gn", |
| "rust/BUILD.bazel", |
| ] |
| deps = [ |
| "//:ninja_outputs_json(${default_toolchain})", |
| "//build/beads/verifications/rust:rust_example_bin", |
| "//build/beads/verifications/rust:rust_example_lib", |
| ] |
| |
| # This action runs GN, Ninja, and Bazel queries, and it's very difficult |
| # to list all the files it might read. |
| hermetic_deps = false |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [] |
| if (select_variant == []) { |
| # Avoid running command comparison in variant builds for now. Variant |
| # build have non-trivial toolchain redirection logic, which makes it hard |
| # to determine the actual toolchain to run GN queries on to retrieve |
| # command lines. |
| deps += [ ":verify_build_commands_for_example" ] |
| } |
| } |
| } |