| # Copyright 2024 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/components/fuchsia_package_archive.gni") |
| |
| # A variant of fuchsia_package_archive also exposes itself in the |
| # `exported_package_archives` build api module. |
| # |
| # Parameters |
| # |
| # package (required) |
| # A fuchsia_package() target defined earlier in the same file. |
| # Type: label |
| # |
| # api_level (optional) |
| # The minimum required API level for the components in this package. |
| # Defaults to -1, denoting an unspecified API level. |
| # Type: int |
| # |
| # testonly |
| # visibility |
| template("exported_fuchsia_package_archive") { |
| if (current_toolchain == default_toolchain) { |
| assert(defined(invoker.package), "package is required") |
| _package_label = invoker.package |
| |
| _api_level = -1 |
| if (defined(invoker.api_level)) { |
| api_level = invoker.api_level |
| } |
| |
| _archive_label = ":${target_name}_archive" |
| fuchsia_package_archive("${target_name}_archive") { |
| forward_variables_from(invoker, "*") |
| } |
| |
| # LINT.IfChange |
| _input_far = get_label_info(_archive_label, "target_out_dir") + "/" + |
| get_label_info(_package_label, "name") + ".far" |
| |
| # LINT.ThenChange(//src/sys/pkg/bin/package-tool/package-tool.gni) |
| |
| # LINT.IfChange |
| _input_package_manifest = |
| get_label_info(_package_label, "target_out_dir") + "/" + |
| get_label_info(_package_label, "name") + "/package_manifest.json" |
| |
| # LINT.ThenChange(//build/components/fuchsia_package.gni) |
| |
| _output_metadata = "$target_out_dir/${target_name}_metadata.json" |
| action(target_name) { |
| forward_variables_from(invoker, "*", [ "package" ]) |
| |
| metadata = { |
| exported_package_archives = |
| [ rebase_path(_output_metadata, root_build_dir) ] |
| } |
| |
| script = "//build/packages/generate_package_archive_metadata.py" |
| |
| inputs = [ |
| _input_far, |
| _input_package_manifest, |
| ] |
| |
| outputs = [ _output_metadata ] |
| |
| args = [ |
| "--far", |
| rebase_path(_input_far, root_build_dir), |
| "--package-manifest", |
| rebase_path(_input_package_manifest, root_build_dir), |
| "--cpu", |
| target_cpu, |
| "--api-level", |
| "$_api_level", |
| "--out", |
| rebase_path(_output_metadata, root_build_dir), |
| ] |
| |
| deps = [ |
| _archive_label, |
| _package_label, |
| ] |
| } |
| } else { |
| group(target_name) { |
| public_deps = [ ":${target_name}($default_toolchain)" ] |
| } |
| } |
| } |