| # 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, data_deps |
| # - Optional: The targets to generate a manifest for. See generated_file(). |
| # - Default: [] |
| # - Type: list(label) |
| # |
| # * outputs |
| # - Optional: Singleton list containing the path to the manifest file. |
| # - Default: [ "$target_gen_dir/$target_name.fini" ] |
| # - Type: list(path) |
| # |
| # * prefix |
| # - Optional: Path prefix for destination paths in the manifest. |
| # If this is not "", then it's prepended with a "/" separator. |
| # - Default: "" |
| # - Type: path |
| # |
| # * testonly, visibility, metadata |
| # - Optional: See `gn help`. |
| 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", |
| "prefix", |
| "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" ] |
| } |
| } |