blob: 86cfe03efe394a6e7fb687a2039ef1328a4f9014 [file] [log] [blame]
# 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
#
# update_package_target (required)
# [string] The target that builds the update package, including the update
# package blobfs archive file.
#
# image_assembler_target (required)
# [string] The target that assembles system images, including the system
# blobfs archive file.
#
# assembly_image_name (required)
# [string] The image_name designated in the system assembly associated with
# image_assembler_target.
#
# goldens (required)
# [list of strings] 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.update_package_target),
"verify_static_pkgs() must specify update_package_target")
assert(defined(invoker.image_assembler_target),
"verify_static_pkgs() must specify image_assembler_target")
assert(defined(invoker.assembly_image_name),
"verify_static_pkgs() must specify assembly_image_name")
assert(defined(invoker.goldens), "verify_static_pkgs() must specify goldens")
update_package_target_out_dir =
get_label_info(invoker.update_package_target, "target_out_dir")
update_package_target_name =
get_label_info(invoker.update_package_target, "name")
update_package_dir =
"$update_package_target_out_dir/$update_package_target_name"
image_assembler_target_out_dir =
get_label_info(invoker.image_assembler_target, "target_out_dir")
assembly_image_name = invoker.assembly_image_name
image_assembler_dir = "$image_assembler_target_out_dir/$assembly_image_name"
files = {
update_package = "$update_package_dir/update.far"
blobfs = [
"$image_assembler_dir/blob.blk",
"$update_package_dir/gen/update.blob.blk",
]
}
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 = [ files.update_package ] + files.blobfs + invoker.goldens
outputs = [ stamp_file ]
args = [
"scrutiny",
"verify",
"--depfile",
rebase_path(depfile, root_build_dir),
"--stamp",
rebase_path(stamp_file, root_build_dir),
"static-pkgs",
"--build-path",
rebase_path(root_build_dir, root_build_dir),
"--update",
rebase_path(files.update_package, root_build_dir),
]
foreach(blobfs, files.blobfs) {
args += [
"--blobfs",
rebase_path(blobfs, root_build_dir),
]
}
foreach(golden, invoker.goldens) {
args += [
"--golden",
rebase_path(golden, root_build_dir),
]
}
if (!defined(invoker.deps)) {
deps = []
}
deps += [
invoker.update_package_target,
invoker.image_assembler_target,
]
}
}