| # 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. |
| |
| import("//build/packages/package_metadata.gni") |
| |
| # |
| # Parameters |
| # |
| # archive (required) |
| # Path to archive containing a package. |
| # |
| # package_name (optional) |
| # Name of the package. |
| # Defaults to the target's name. |
| # |
| # repository (optional) |
| # The repository host name part of the package URL. Defaults to "fuchsia.com". |
| # See https://fuchsia.dev/fuchsia-src/concepts/packages/package_url#repository |
| # for more details. |
| # Type: string |
| # Default: fuchsia.com |
| # |
| # deps (optional) |
| # testonly (optional) |
| # visibility (optional) |
| # Usual GN meanings. |
| # |
| template("prebuilt_package") { |
| pkg_target_name = target_name |
| pkg_name = target_name |
| if (defined(invoker.package_name)) { |
| pkg_name = invoker.package_name |
| } |
| repository = "fuchsia.com" |
| if (defined(invoker.repository)) { |
| repository = invoker.repository |
| } |
| pkg_version = 0 |
| manifest_target_name = target_name + ".manifest" |
| |
| pkg_out_dir = target_out_dir + "/" + pkg_target_name |
| blobs_json = "$pkg_out_dir/blobs.json" |
| package_manifest_json = "$pkg_out_dir/package_manifest.json" |
| blobs_manifest = "$pkg_out_dir/blobs.manifest" |
| blobs_json_path = rebase_path(blobs_json, root_build_dir) |
| |
| unpack_action_name = target_name + ".debug-archive" |
| |
| group(unpack_action_name) { |
| metadata = { |
| prebuilt_packages = [ |
| { |
| archive = invoker.archive |
| if (defined(invoker.package_name)) { |
| package_name = invoker.package_name |
| } |
| }, |
| ] |
| } |
| } |
| |
| metadata_target_name = "${target_name}_metadata" |
| define_package_metadata(metadata_target_name) { |
| package_name = pkg_name |
| snapshot_entry = "$pkg_name/$pkg_version=$blobs_json_path" |
| blob_manifest = blobs_manifest |
| meta_far_merkle_index_entry = |
| "$pkg_name/$pkg_version=" + |
| rebase_path("$pkg_out_dir/meta.far.merkle", root_build_dir) |
| package_output_manifest = package_manifest_json |
| } |
| |
| action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "metadata", |
| "testonly", |
| "visibility", |
| ]) |
| |
| archive = invoker.archive |
| |
| if (defined(visibility)) { |
| visibility += [ ":$manifest_target_name" ] |
| } |
| |
| script = "//build/packages/prebuilt_package.py" |
| |
| meta_merkle = "$pkg_out_dir/meta.far.merkle" |
| pm = "$host_out_dir/pm" |
| |
| args = [ |
| "--pm-tool", |
| rebase_path(pm, root_build_dir), |
| "--name", |
| pkg_name, |
| "--archive", |
| rebase_path(archive, root_build_dir), |
| "--workdir", |
| rebase_path(pkg_out_dir, root_build_dir), |
| "--repository", |
| repository, |
| ] |
| |
| inputs = [ |
| archive, |
| pm, |
| ] |
| |
| outputs = [ |
| blobs_manifest, |
| blobs_json, |
| package_manifest_json, |
| meta_merkle, |
| ] |
| |
| deps = [ |
| ":$metadata_target_name", |
| ":$unpack_action_name($default_toolchain)", |
| "//src/sys/pkg/bin/pm:pm_bin($host_toolchain)", |
| ] |
| if (defined(invoker.deps)) { |
| deps += invoker.deps |
| } |
| |
| # Outputs seem nondeterministic, or contain timestamps. |
| # Specifically (inside PACKAGE.meta): |
| # blobs.manifest |
| # blobs.json |
| # package_manifest.json |
| repeatable = false |
| } |
| |
| group(manifest_target_name) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| public_deps = [ ":$pkg_target_name" ] |
| } |
| } |