| # Copyright 2021 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/python/python_action.gni") |
| import("//src/sys/pkg/bin/package-tool/package-tool.gni") |
| |
| # Creates a Fuchsia Package for an Assembly Input Bundle. For the format |
| # of the created package, see the AssemblyInputBundle documentation at: |
| # //build/python/modules/assembly/assembly_input_bundle.py |
| # |
| # Parameters |
| # |
| # manifest |
| # [path] The path to the FINI manifest created by the assembly input bundle |
| # |
| # package_name (optional; default: target_name) |
| # [string] The name of the package, if not $target_name |
| # |
| # package_outdir (optional; default: target_out_dir) |
| # [path] A different directory to write the bundle into, if not to write it |
| # to '$target_out_dir/$bundle_name'. |
| # |
| # GN usual meanings |
| # deps, testonly, visibility |
| # |
| template("assembly_input_bundle_package") { |
| assert(defined(invoker.manifest), |
| "A manifest path must be specified: " + |
| get_label_info(target_name, "label_with_toolchain")) |
| |
| package_outdir = target_out_dir |
| if (defined(invoker.package_outdir)) { |
| package_outdir = invoker.package_outdir |
| } |
| |
| package_name = target_name |
| if (defined(invoker.bundle_name)) { |
| package_name = invoker.package_name |
| } |
| |
| labels = { |
| package_manifest_creation = "${target_name}.creation_manifest.fini" |
| package = target_name |
| } |
| |
| files = { |
| meta_package_file = "$package_outdir/meta_package" |
| creation_manifest = "$package_outdir/creation_manifest.fini" |
| } |
| |
| # Build a package PackageBuildManifest that includes the contents in |
| # |invoker.manifest| and a generated meta/package file. |
| python_action(labels.package_manifest_creation) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| ]) |
| visibility = [ ":${labels.package}" ] |
| binary_label = "//build/assembly/scripts:assembly_input_bundle_tool" |
| inputs = [ invoker.manifest ] |
| outputs = [ |
| files.creation_manifest, # must be the first output, for passing to |
| # package_tool_package_build |
| files.meta_package_file, |
| ] |
| args = [ |
| "generate-package-creation-manifest", |
| "--name", |
| package_name, |
| "--contents-manifest", |
| rebase_path(invoker.manifest, root_build_dir), |
| "--meta-package", |
| rebase_path(files.meta_package_file, root_build_dir), |
| "--output", |
| rebase_path(files.creation_manifest, root_build_dir), |
| ] |
| } |
| |
| package_tool_package_build(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| ]) |
| package_name = package_name |
| package_out_dir = package_outdir |
| manifest = ":${labels.package_manifest_creation}" |
| metadata = { |
| if (defined(invoker.metadata)) { |
| forward_variables_from(invoker.metadata, "*") |
| } |
| |
| # These are a bunch of barriers to make sure that if this target gets |
| # included anywhere, it's dependencies don't end up getting gathered |
| # in metadata walks. |
| distribution_entries_barrier = [] |
| package_barrier = [] |
| assembly_package_barrier = [] |
| driver_package_barrier = [] |
| system_image_package_barrier = [] |
| system_image_extra_package_manifest_barrier = [] |
| test_component_manifest_barrier = [] |
| test_component_manifest_program_barrier = [] |
| } |
| } |
| } |