| # Copyright 2021 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/dev.gni") |
| import("//src/developer/ffx/build/ffx_action.gni") |
| |
| # Check the static pkgs list against a golden file. |
| # |
| # The target that generates 'zbi' needs to be added to deps. |
| # |
| # Parameters |
| # |
| # zbi |
| # Required: Path to the ZBI image. |
| # zbi_target |
| # Required: The target to build the 'zbi'. |
| # blobfs_manifest |
| # Required: Path to the blobfs manifest file. |
| # blobfs_manifest_target: |
| # Required: The target to build the 'blobfs_manifest'. |
| # goldens |
| # Required: Path to a list of golden files that contain golden static pkgs |
| # list in the format of one static pkg name per line. The actual static |
| # pkgs list must match either one of the goldens. There should be only one |
| # golden file in this list for normal case and two golden files, one for |
| # the old golden file, one for the new golden file during a soft |
| # transition. |
| # deps, public_deps, data_deps (optional) |
| # Usual GN meaning. |
| |
| template("verify_static_pkgs") { |
| assert(defined(invoker.zbi), "verify_static_pkgs() must specify zbi") |
| assert(defined(invoker.zbi_target), |
| "verify_static_pkgs() must specify zbi_target") |
| assert(defined(invoker.blobfs_manifest), |
| "verify_static_pkgs() must specify blobfs_manifest") |
| assert(defined(invoker.blobfs_manifest_target), |
| "verify_static_pkgs() must specify blobfs_manifest_target") |
| assert(defined(invoker.goldens), "verify_static_pkgs() must specify goldens") |
| |
| ffx_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "deps", |
| "public_deps", |
| "data_deps", |
| "visibility", |
| ]) |
| |
| no_output_dir_leaks = false |
| |
| stamp_file = "$target_gen_dir/$target_name.verified" |
| depfile = "$target_gen_dir/$target_name.d" |
| |
| inputs = [ |
| invoker.zbi, |
| invoker.blobfs_manifest, |
| ] + invoker.goldens |
| |
| outputs = [ stamp_file ] |
| |
| args = [ |
| "scrutiny", |
| "verify", |
| "static-pkgs", |
| "--build-path", |
| rebase_path(root_build_dir), |
| "--zbi", |
| rebase_path(invoker.zbi, root_build_dir), |
| "--blobfs-manifest", |
| rebase_path(invoker.blobfs_manifest, root_build_dir), |
| "--stamp", |
| rebase_path(stamp_file, root_build_dir), |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| ] |
| foreach(golden, invoker.goldens) { |
| args += [ |
| "--golden", |
| rebase_path(golden, root_build_dir), |
| ] |
| } |
| if (!defined(invoker.deps)) { |
| deps = [] |
| } |
| |
| deps += [ |
| invoker.zbi_target, |
| invoker.blobfs_manifest_target, |
| ] |
| } |
| } |