blob: ebe3762579a92a9f5738c96d54a3503e6042d236 [file] [log] [blame] [edit]
# Copyright 2025 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.
# Generates a product_bundles.json file as a build_api_module, but depending on
# it will not build all the product bundles.
#
# Parameters:
#
# deps (required)
# The dependency graph to walk to find all the product bundles.
#
template("product_bundles_json") {
assert(defined(invoker.deps), "deps is a required parameter")
# Ensure this template is only used in approved locations.
# This ensures that they are resolved by gn-gen.
# See root_patterns in the //.gn file.
_valid_dirs = [ "//:*" ]
if (!label_matches(":$target_name", _valid_dirs)) {
assert(
false,
"product_bundles_json can only be used in these directories: $_valid_dirs")
}
files = {
metadata = "${root_build_dir}/product_bundles_metadata.json"
output = "${root_build_dir}/product_bundles.json"
}
generated_file("${target_name}_metadata") {
testonly = true
data_keys = [ "product_bundles" ]
walk_keys = [ "product_bundles_barrier" ]
deps = invoker.deps
outputs = [ files.metadata ]
output_conversion = "json"
}
# This action pretends to generate product_bundles.json even though the above
# action generates it. This allows us to depend on this below action without
# building all the product bundles.
#
# The output of the above action gets copied to product_bundles.json in
# regenerator.py.
action(target_name) {
testonly = true
script = "//build/scripts/no_op.sh"
outputs = [ files.output ]
args = rebase_path(outputs, root_build_dir)
metadata = {
build_api_modules = [ "product_bundles" ]
build_api_client_info = [ "product_bundles=product_bundles.json" ]
}
}
}