| # Copyright 2022 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/assembly/bazel_product_bundle.gni") |
| import("//build/bazel/assembly/verify_assembly_configs.gni") |
| import("//build/images/args.gni") |
| import("//build/images/custom_signing.gni") |
| import("//build/product.gni") |
| import("//build/testing/verify_files_match.gni") |
| |
| # Only do drivers lists comparison when both GN and Bazel assembly are done in |
| # the same build. |
| _should_compare_driver_lists = |
| !use_bazel_images_only && bazel_product_bundle_target != "" && has_board |
| |
| _should_compare_tests_manifests = |
| !use_bazel_images_only && bazel_product_bundle_target != "" |
| |
| if (is_fuchsia) { |
| if (_should_compare_driver_lists) { |
| import("//build/drivers/check_included_drivers.gni") |
| |
| check_included_drivers("bazel_drivers_check") { |
| testonly = true |
| deps = [ bazel_product_bundle_target ] |
| } |
| |
| action("compare_drivers_lists") { |
| testonly = true |
| |
| _gn_drivers_list = get_label_info("//:drivers-check", "target_gen_dir") + |
| "/drivers-check_metadata_output" |
| _bazel_drivers_list = |
| get_label_info(":bazel_drivers_check", "target_gen_dir") + |
| "/bazel_drivers_check_metadata_output" |
| _output = "${target_out_dir}/diff" |
| |
| inputs = [ |
| _gn_drivers_list, |
| _bazel_drivers_list, |
| ] |
| outputs = [ _output ] |
| |
| script = "//build/bazel/assembly/diff_drivers_lists.py" |
| args = [ |
| "--drivers-list1", |
| rebase_path(_gn_drivers_list, root_build_dir), |
| "--drivers-list2", |
| rebase_path(_bazel_drivers_list, root_build_dir), |
| "--output", |
| rebase_path(_output, root_build_dir), |
| ] |
| |
| deps = [ |
| ":bazel_drivers_check_metadata_check", |
| "//:drivers-check_metadata_check", |
| ] |
| } |
| } |
| |
| if (_should_compare_tests_manifests) { |
| import("//build/config/build_api_module.gni") |
| |
| build_api_module("bazel_assembly_verification_tests_manifest_gn") { |
| testonly = true |
| data_keys = [ "tests" ] |
| walk_keys = [ "tests_barrier" ] |
| deps = [ "//build/images:main_assembly" ] |
| } |
| |
| build_api_module("bazel_assembly_verification_tests_manifest_bazel") { |
| testonly = true |
| data_keys = [ "tests" ] |
| walk_keys = [ "tests_barrier" ] |
| deps = [ bazel_product_bundle_target ] |
| } |
| |
| verify_files_match("compare_tests_manifests") { |
| testonly = true |
| first = |
| "${root_build_dir}/bazel_assembly_verification_tests_manifest_gn.json" |
| second = "${root_build_dir}/bazel_assembly_verification_tests_manifest_bazel.json" |
| display_text_diff_on_failure = true |
| deps = [ |
| ":bazel_assembly_verification_tests_manifest_bazel", |
| ":bazel_assembly_verification_tests_manifest_gn", |
| ] |
| } |
| } |
| } |
| |
| verify_assembly_configs("verify_assembly_configs") { |
| product_configs = [ |
| { |
| name = "zedboot_product_config" |
| gn_target = "//products/zedboot" |
| bazel_target = "//products/zedboot" |
| }, |
| ] |
| |
| # Avoid building board configs in both GN and Bazel. |
| board_configs = [] |
| } |
| |
| if (is_host) { |
| group("host_tests") { |
| testonly = true |
| |
| deps = [ |
| # Verifications tests depends on bazel_actions, which requires default |
| # toolchain. |
| ":verify_assembly_configs($default_toolchain)", |
| "product_configurations:host_tests", |
| ] |
| |
| if (_should_compare_driver_lists) { |
| # Driver lists comparison depends on GN assembly, which requires default |
| # toolchain. |
| deps += [ ":compare_drivers_lists($default_toolchain)" ] |
| } |
| |
| if (_should_compare_tests_manifests) { |
| deps += [ ":compare_tests_manifests($default_toolchain)" ] |
| } |
| } |
| } |