blob: 70a3526661610641bae3a66e7b6fe8c2ef721ec4 [file] [log] [blame]
# Copyright 2020 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("distribution_manifest.gni")
# Generates a manifest in the FINI (Fuchsia INI) format.
#
# This format maps a source file to its destination in a container with the
# following line:
# ```
# target=source
# ```
#
# The output of this template is a manifest file that lists all packageable
# elements encountered within `deps`. For more details, see
# //docs/concepts/build_system/internals/manifest_formats.md
#
# Parameters
#
# deps (optional)
# [list of labels] The targets to generate a manifest for.
# See `gn help` for more details.
#
# data_deps, testonly, visibility, metadata (optional)
# See `gn help`.
#
# outputs (optional)
# Singleton list containing the path to the manifest file.
# Defaults to `[ "$target_gen_dir/$target_name.fini" ]`.
template("fini_manifest") {
main_target = target_name
generate_target = "${target_name}_dist"
# Build the name of the output files.
if (defined(invoker.outputs)) {
_outputs = invoker.outputs
assert(_outputs == [ _outputs[0] ],
"Output list must have exactly one element.")
manifest_file = _outputs[0]
} else {
manifest_file = "$target_gen_dir/$target_name.fini"
}
intermediate_file = "$manifest_file.dist"
# Get a JSON manifest of all runtime objects.
distribution_manifest(generate_target) {
forward_variables_from(invoker,
[
"data_deps",
"deps",
# Metadata needs to be added on this target so that
# any barrier it defines is properly reflected in
# the target's deps.
"metadata",
"testonly",
])
visibility = [ ":$main_target" ]
outputs = [ intermediate_file ]
}
# Generate a manifest file with the FINI format.
action(main_target) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
script = "//build/dist/convert_manifest_to_fini.py"
sources = [ intermediate_file ]
outputs = [ manifest_file ]
inputs = [ "//build/dist/distribution_manifest.py" ]
args = [
"--input",
rebase_path(intermediate_file, root_build_dir),
"--output",
rebase_path(manifest_file, root_build_dir),
]
deps = [ ":$generate_target" ]
}
}