| # 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/dist/distribution_manifest.gni") |
| |
| # Define a set of files that should be placed in BootFS. |
| # |
| # NOTE: This template specifically defines bootfs files for inclusion |
| # with the Assembly Input Bundles. |
| # |
| # NOTE: It CAN ONLY be used as a dependency of an AIB. It CANNOT be |
| # used as a dependency of any binary, package, or group. |
| # |
| # NOTE: Eventually, this template will be replaced with fuchsia_package once all |
| # the bootfs files have moved to packages. |
| # |
| # Params: |
| # |
| # As normal: |
| # deps, testonly |
| # |
| # NOTE: Visibility is restricted to `//bundles/assembly/*`, and cannot be |
| # overridden. |
| template("bootfs_files_for_assembly") { |
| labels = { |
| distribution_entries = "$target_name.distribution_entries" |
| bootfs_distribution_entries = "$target_name.bootfs_distribution_entries" |
| } |
| files = { |
| bootfs_distribution_entries = |
| "$target_out_dir/$target_name.bootfs_distribution_entries.dist" |
| } |
| |
| # Step 1. Collect all the bootfs files. |
| distribution_manifest(labels.distribution_entries) { |
| # Intentionally, do not forward data_deps, because resource.gni adds |
| # data_deps to the distribution_entries_barrier, and we would like to |
| # prevent transitive dependencies. |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| ]) |
| } |
| |
| # Step 2. Rebase all the meta/something files onto bootfs/meta/something. |
| # This ensures that these files are not shoved into a meta.far and lost. |
| action(labels.bootfs_distribution_entries) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| script = "//build/assembly/scripts/bootfs_distribution_manifest.py" |
| |
| _distribution_manifest_outputs = |
| get_target_outputs(":${labels.distribution_entries}") |
| inputs = _distribution_manifest_outputs |
| outputs = [ files.bootfs_distribution_entries ] |
| deps = [ ":${labels.distribution_entries}" ] |
| |
| args = [ |
| "--input", |
| rebase_path(inputs[0], root_build_dir), |
| "--output", |
| rebase_path(outputs[0], root_build_dir), |
| ] |
| } |
| |
| # Step 3. Declare the above distribution manifest as walkable to a |
| # fuchsia_package. All the entries will be picked up in one of the AIB |
| # templates. |
| distribution_entries_file(target_name) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| assert(!defined(invoker.visibility), |
| "The bootfs_files_for_assembly() template sets its own visibility") |
| |
| # The targets created by this template can only be used with assembly input |
| # bundles. |
| visibility = [ |
| ":*", |
| "//bundles/assembly/*", |
| ] |
| |
| deps = [ ":${labels.bootfs_distribution_entries}" ] |
| file = files.bootfs_distribution_entries |
| } |
| } |