blob: ce4533ec02feeca4a72f675bb0942113bd8289f1 [file] [log] [blame]
# 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/python/python_action.gni")
import("//build/python/python_binary.gni")
# Collect a newline-delimited text file of package names from the create-system call.
#
# Arguments:
#
# system_label (GN label)
# Label for the assembled_system() invocation to use, e.g. //build/images/fuchsia.
#
# outputs (list of paths)
# Usual GN meaning, expects a single file to write to.
#
# package_set (string, either "base" or "cache")
# Which package set's metadata to dump into the output.
#
# contents (string, either "name" or "manifest")
# Which field in each package's metadata to extract for the newline-delimited file.
#
# testonly
# visibility
template("package_list_from_assembly") {
assert(
defined(invoker.system_label),
"must define a `system_label` argument which points to an assembled_system() invocation")
assert(defined(invoker.outputs), "must define `outputs`")
assert(defined(invoker.package_set), "must define `package_set` argument")
assert(invoker.package_set == "base" || invoker.package_set == "cache",
"must specify either base or cache package set")
assert(defined(invoker.contents),
"must define a `contents` type for dumping package info")
_assembly_target_dir = get_label_info(invoker.system_label, "target_out_dir")
_assembly_target_name = get_label_info(invoker.system_label, "name")
_images_manifest = "$_assembly_target_dir/$_assembly_target_name/images.json"
python_action(target_name) {
forward_variables_from(invoker,
[
"outputs",
"testonly",
"visibility",
])
binary_label = "//build/assembly/scripts:package_list"
args = [
"--package-set",
invoker.package_set,
"--contents",
invoker.contents,
"--images-manifest",
rebase_path(_images_manifest, root_build_dir),
"--output",
rebase_path(outputs[0], root_build_dir),
]
inputs = [ _images_manifest ]
deps = [ invoker.system_label ]
}
}