| # Copyright 2023 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_action.gni") |
| import("//build/bazel/bazel_build_action.gni") |
| import("//build/bazel/bazel_fuchsia_sdk.gni") |
| import("//build/bazel/bazel_inputs.gni") |
| import("//build/bazel/generate_prebuilt_dir_content_hash.gni") |
| import("//build/bazel/logging.gni") |
| import("//build/bazel/remote_services.gni") |
| import("//build/config/fuchsia/platform_version.gni") |
| import("//build/config/fuchsia/target_api_level.gni") |
| import("//build/sdk/config.gni") |
| import("//build/sdk/idk.gni") |
| import("//build/sdk/sdk_collection.gni") |
| |
| # Generate a Bazel SDK directly from the content of ://sdk:bazel_in_tree_idk |
| # and verify that it matches the content of @fuchsia_sdk. This is performed |
| # using Bazel actions, to verify that there are no differences between |
| # the Starlark and Python executions of generated_sdk_build_rules.{bzl,py}. |
| |
| # An IDK collection built by Ninja that is used in a test comparing this against |
| # @fuchsia_sdk. `bazel_in_tree_idk` is just a wrapper around |
| # `in_tree_collection`, which is effectively an IDK. |
| bazel_input_directory("ninja_generated_in_tree_idk_for_test.bazel_input") { |
| testonly = true |
| generator = "//sdk:bazel_in_tree_idk" |
| output_directory = "$root_build_dir/sdk/exported/in_tree_collection" |
| } |
| |
| # Generate a symlink to the @fuchsia_sdk//:BUILD.bazel file to ensure |
| # that repository is rebuilt by Bazel when it is missing (e.g. just |
| # after an `fx gen` call). |
| # |
| # Note that this uses a symlink chain: the Ninja output is a symlink |
| # to a Bazel genrule() target that creates a symlink to the final |
| # file. See https://fxbug.dev/404799660 for context. |
| # |
| # Ninja |
| # obj/build/bazel/bazel_sdk/in_tree_fuchsia_sdk.stamp |
| # | |
| # symlink |
| # | |
| # Bazel v |
| # BAZEL_BIN/build/bazel/bazel_sdk/fuchsia_sdk.stamp |
| # | |
| # symlink |
| # | |
| # v |
| # BAZEL_EXECROOT/external/fuchsia_sdk/BUILD.bazel |
| # |
| # Note: The IDK repository is generated by regenerator.py but contains symlinks |
| # to Ninja artifact locations that may not exist yet. bazel_action() ensures the |
| # targets of those symlinks exist. |
| bazel_action("in_tree_fuchsia_sdk") { |
| command = "build" |
| bazel_targets = [ ":in_tree_fuchsia_sdk" ] |
| final_symlink_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/fuchsia_sdk.stamp" |
| ninja = "$target_name.stamp" |
| }, |
| ] |
| } |
| |
| bazel_build_action("verify_fuchsia_sdk_repository") { |
| testonly = true |
| bazel_target = ":verify_fuchsia_sdk_repository" |
| deps = [ ":ninja_generated_in_tree_idk_for_test.bazel_input" ] |
| copy_outputs = [ |
| { |
| bazel = "{{BAZEL_TARGET_OUT_DIR}}/{{BAZEL_TARGET_NAME}}" |
| ninja = "$target_name.verified" |
| }, |
| ] |
| } |
| |
| # Run the Bazel SDK test suite against the content of the @fuchsia_sdk |
| # repository (in-tree SDK). |
| run_fuchsia_bazel_sdk_tests("bazel_sdk_tests") { |
| target_cpus = [ target_cpu ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":bazel_sdk_tests" ] |
| } |