| # Copyright 2018 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. |
| |
| # Create a response file that lists the content of all fuchsia driver packages |
| # reachable from a given list of deps, with the exception of their meta/ |
| # directories. |
| # |
| # This file is only used to generate a final system image manifest. |
| # |
| # Use get_target_outputs() to get the path to the generated file. |
| # |
| # Parameters: |
| # filter_packages (optional) |
| # If set, indicates how fuchsia_system_package() instances that appear |
| # in the dependency tree are processed. Based on the following values: |
| # |
| # "system_only": Only fuchsia_system_package() instances are allowed in |
| # the tree. A regular fuchsia_package() in the tree is an error, and |
| # their list will be printed by the script for debugging the issue. |
| # |
| # "extras": Error when a fuchsia_system_package() instance that does |
| # not have its 'allowed_in_extra_deps = true' in its definition appears |
| # in the dependency tree. Regular fuchsia_package() instances are |
| # allowed but will be ignored. |
| # |
| # If undefined, the content of all fuchsia_system_package() instances that |
| # appear in the dependency tree will be listed in the output, while |
| # regular fuchsia_package() instances will be ignored. |
| # |
| # Type: string |
| # |
| # deps, testonly, visibility: Usual GN meaning. |
| template("system_image_fuchsia_system_packages") { |
| _system_image_packages_json = "${target_name}_packages" |
| _system_image_packages_json_path = |
| target_gen_dir + "/${target_name}.info.json" |
| |
| # First collect metadata to list all the fini manifest of the fuchsia_package() |
| # instances reachable from invoker.deps. This generates a JSON file which is a list |
| # of scopes whose schema is described in fuchsia_package(). |
| generated_file(_system_image_packages_json) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| visibility = [ ":*" ] |
| deps = invoker.deps |
| outputs = [ _system_image_packages_json_path ] |
| data_keys = [ "system_image_package_info" ] |
| walk_keys = [ "system_image_package_barrier" ] |
| output_conversion = "json" |
| } |
| |
| # Then convert this file to a .system.rsp format that is suitable for the final |
| # system manifest file. It's a succession of lines that look like: |
| # |
| # --entry-manifest=<label> |
| # Specifies the label corresponding to future --entry values after this one. |
| # |
| # --entry=<destination>=<source> |
| # One system manifest entry, format similar to the one described above. |
| # |
| # Note that the script will omit any meta/... content from the input fini manifest |
| # intentionally. |
| action(target_name) { |
| _filter_packages = "none" |
| if (defined(invoker.filter_packages)) { |
| _filter_packages = invoker.filter_packages |
| } |
| |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| script = "//build/images/convert_system_package_info_to_system_rsp.py" |
| sources = [ _system_image_packages_json_path ] |
| outputs = [ target_gen_dir + "/${target_name}.system.rsp" ] |
| depfile = outputs[0] + ".d" |
| args = [ |
| "--input=" + rebase_path(sources[0], root_build_dir), |
| "--output=" + rebase_path(outputs[0], root_build_dir), |
| "--depfile=" + rebase_path(depfile, root_build_dir), |
| "--filter-packages=" + _filter_packages, |
| ] |
| deps = [ ":" + _system_image_packages_json ] |
| } |
| } |