| # 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/developer/ffx/build/ffx_action.gni") |
| |
| template("update_package") { |
| assert(defined(invoker.partitions), "Need to define partitions") |
| assert(defined(invoker.board_name), "Need to define board_name") |
| assert(defined(invoker.version_file), "Need to define version_file") |
| assert(defined(invoker.epoch), "Need to define epoch") |
| |
| labels = { |
| hermetic_inputs = "${target_name}_hermetic_inputs" |
| ffx_tool = "//src/developer/ffx:ffx_bin($host_toolchain)" |
| } |
| |
| files = { |
| hermetic_inputs = "${target_out_dir}/${target_name}_hermetic_inputs" |
| hermetic_inputs_depfile = |
| "${target_out_dir}/${target_name}_hermetic_inputs.d" |
| outdir = "$target_out_dir/$target_name" |
| gendir = "$outdir/gen" |
| subpackage_blobs_package = "$outdir/subpackage_blobs/meta.far" |
| subpackage_blobs_package_manifest = |
| "$outdir/subpackage_blobs/package_manifest.json" |
| update_package = "$outdir/update.far" |
| update_package_manifest = "$outdir/update_package_manifest.json" |
| update_images_fuchsia_package = "$outdir/update_images_fuchsia.far" |
| update_images_fuchsia_package_manifest = |
| "$outdir/update_images_fuchsia_package_manifest.json" |
| update_images_recovery_package = "$outdir/update_images_recovery.far" |
| update_images_recovery_package_manifest = |
| "$outdir/update_images_recovery_package_manifest.json" |
| update_images_firmware_package = "$outdir/update_images_firmware.far" |
| update_images_firmware_package_manifest = |
| "$outdir/update_images_firmware_package_manifest.json" |
| subpackage_blobs_meta_package = "$gendir/subpackage_blobs/meta/package" |
| subpackage_blobs_abi_revision = |
| "$gendir/subpackage_blobs/meta/fuchsia.abi/abi-revision" |
| update_meta_package = "$gendir/update/meta/package" |
| update_abi_revision = "$gendir/update/meta/fuchsia.abi/abi-revision" |
| update_images_fuchsia_meta_package = |
| "$gendir/update_images_fuchsia/meta/package" |
| update_images_fuchsia_abi_revision = |
| "$gendir/update_images_fuchsia/meta/fuchsia.abi/abi-revision" |
| update_images_recovery_meta_package = |
| "$gendir/update_images_recovery/meta/package" |
| update_images_recovery_abi_revision = |
| "$gendir/update_images_recovery/meta/fuchsia.abi/abi-revision" |
| update_images_firmware_meta_package = |
| "$gendir/update_images_firmware/meta/package" |
| update_images_firmware_abi_revision = |
| "$gendir/update_images_firmware/meta/fuchsia.abi/abi-revision" |
| board = "$gendir/board" |
| epoch = "$gendir/epoch.json" |
| images = "$gendir/images.json.orig" |
| packages = "$gendir/packages.json" |
| update_blob = "$gendir/update.blob.blk" |
| blob_manifest = "$gendir/blob.manifest" |
| blobs_json = "$gendir/blobs.json" |
| } |
| |
| python_action(labels.hermetic_inputs) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| ]) |
| binary_label = |
| "//build/assembly/scripts:hermetic_inputs_from_assembly_outputs" |
| |
| inputs = [ invoker.partitions ] |
| outputs = [ files.hermetic_inputs ] |
| depfile = files.hermetic_inputs_depfile |
| |
| args = [ |
| "--partitions", |
| rebase_path(invoker.partitions, root_build_dir), |
| "--output", |
| rebase_path(files.hermetic_inputs, root_build_dir), |
| "--depfile", |
| rebase_path(files.hermetic_inputs_depfile, root_build_dir), |
| ] |
| |
| if (defined(invoker.system_a) || defined(invoker.system_b) || |
| defined(invoker.system_r)) { |
| args += [ "--system" ] |
| if (defined(invoker.system_a)) { |
| args += [ rebase_path(invoker.system_a, root_build_dir) ] |
| inputs += [ invoker.system_a ] |
| } |
| if (defined(invoker.system_b)) { |
| args += [ rebase_path(invoker.system_b, root_build_dir) ] |
| inputs += [ invoker.system_b ] |
| } |
| if (defined(invoker.system_r)) { |
| args += [ rebase_path(invoker.system_r, root_build_dir) ] |
| inputs += [ invoker.system_r ] |
| } |
| } |
| } |
| |
| ffx_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| ]) |
| if (!defined(deps)) { |
| deps = [] |
| } |
| |
| hermetic_inputs_target = ":${labels.hermetic_inputs}" |
| hermetic_inputs_file = files.hermetic_inputs |
| |
| ffx_tool = "//src/developer/ffx/plugins/assembly:ffx_assembly_tool" |
| ffx_tool_output_name = "ffx-assembly" |
| |
| args = [ |
| "--config", |
| "assembly_enabled=true", |
| "assembly", |
| "create-update", |
| "--partitions", |
| rebase_path(invoker.partitions, root_build_dir), |
| "--outdir", |
| rebase_path(files.outdir, root_build_dir), |
| "--gendir", |
| rebase_path(files.gendir, root_build_dir), |
| "--board-name", |
| invoker.board_name, |
| "--epoch", |
| invoker.epoch, |
| "--version-file", |
| rebase_path(invoker.version_file, root_build_dir), |
| ] |
| |
| if (defined(invoker.rewrite_default_repo)) { |
| args += [ |
| "--rewrite-default-repo", |
| invoker.rewrite_default_repo, |
| ] |
| } |
| |
| outputs = [ |
| files.subpackage_blobs_package, |
| files.subpackage_blobs_package_manifest, |
| files.subpackage_blobs_meta_package, |
| files.subpackage_blobs_abi_revision, |
| files.update_package, |
| files.update_package_manifest, |
| files.update_images_fuchsia_package, |
| files.update_images_fuchsia_package_manifest, |
| files.update_images_recovery_package, |
| files.update_images_recovery_package_manifest, |
| files.update_images_firmware_package, |
| files.update_images_firmware_package_manifest, |
| files.update_meta_package, |
| files.update_abi_revision, |
| files.update_images_fuchsia_meta_package, |
| files.update_images_fuchsia_abi_revision, |
| files.update_images_recovery_meta_package, |
| files.update_images_recovery_abi_revision, |
| files.update_images_firmware_meta_package, |
| files.update_images_firmware_abi_revision, |
| files.board, |
| files.epoch, |
| files.images, |
| files.packages, |
| files.update_blob, |
| files.blob_manifest, |
| files.blobs_json, |
| ] |
| |
| inputs = [ |
| invoker.partitions, |
| invoker.version_file, |
| ] |
| |
| if (defined(invoker.system_a)) { |
| args += [ |
| "--system-a", |
| rebase_path(invoker.system_a, root_build_dir), |
| ] |
| inputs += [ invoker.system_a ] |
| } |
| |
| if (defined(invoker.system_b)) { |
| args += [ |
| "--system-b", |
| rebase_path(invoker.system_b, root_build_dir), |
| ] |
| inputs += [ invoker.system_b ] |
| } |
| |
| if (defined(invoker.system_r)) { |
| args += [ |
| "--system-r", |
| rebase_path(invoker.system_r, root_build_dir), |
| ] |
| inputs += [ invoker.system_r ] |
| } |
| |
| if (defined(invoker.update_package_name)) { |
| args += [ |
| "--update-package-name", |
| invoker.update_package_name, |
| ] |
| } |
| |
| if (defined(invoker.subpackage_blobs_package_name)) { |
| args += [ |
| "--subpackage-blobs-package-name", |
| invoker.subpackage_blobs_package_name, |
| ] |
| } |
| |
| metadata = { |
| # We generated some PackageManifests. We need to declare them, so that |
| # these packages are published into TUF. |
| package_output_manifests = [ |
| files.subpackage_blobs_package_manifest, |
| files.update_package_manifest, |
| files.update_images_fuchsia_package_manifest, |
| files.update_images_recovery_package_manifest, |
| files.update_images_firmware_package_manifest, |
| ] |
| |
| # But we don't want any of our own dependencies to contribute packages to |
| # any package lists created by metadata walks, those packages referenced |
| # in the `packages` file need to be published by publishing the assembly's |
| # base & cache packages (see //build/images/updates/BUILD.gn) |
| # |
| # Ideally, we'd include the assembly packages, and not the recovery image |
| # packages, but we can't which is which from within this template. |
| distribution_entries_barrier = [] |
| package_barrier = [] |
| assembly_package_barrier = [] |
| system_image_package_barrier = [] |
| driver_package_barrier = [] |
| } |
| } |
| } |