blob: 1c5922ddee082861170ca11f381a2ee91a738735 [file] [log] [blame]
# 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/images/args.gni")
import("//build/images/supports_fastboot_fvm.gni")
import("//build/product.gni")
import("//src/storage/fshost/generated_fshost_config.gni")
import("//zircon/kernel/phys/qemu.gni")
# This centralizes the definition of a bunch of labels and files used in the
# various //build/images/**/BUILD.gn files.
flash_manifest_version = 3
# These are the common assembly-related labels.
labels = {
if (use_bazel_images_only) {
# For now only Fuchsia images built by Bazel are useful.
assembly_name = "fuchsia"
if (bazel_assembly_targets != []) {
# Make `bazel_assembly_targets` take precedence to aid soft transition.
#
# TODO(jayzhuang): Remove this if block when `bazel_assembly_targets` is
# removed.
assert(
bazel_assembly_targets == [ bazel_assembly_targets[0] ],
"bazel_assembly_targets should define exactly one element when use_bazel_images_only=true")
images = bazel_assembly_targets[0]
} else {
assert(
bazel_product_bundle_target != "",
"bazel_product_bundle_prefix and bazel_product_bundle_board must be set to use Bazel assembly")
images = bazel_product_bundle_target
}
# Path to the `package_tool_package_manifest_list_create` target defined in
# `bazel_product_bundle`.
bazel_package_manifests_list = "${images}_package_manifests_list"
} else if (use_bringup_assembly) {
images = "//build/images/bringup(${default_toolchain})"
assembly_name = "bringup"
} else {
_images_without_toolchain = "//build/images/fuchsia"
images = "${_images_without_toolchain}(${default_toolchain})"
assembly_name = "fuchsia"
fuchsia_netboot = "${_images_without_toolchain}:netboot"
meta_packages = "${_images_without_toolchain}:fuchsia.meta_packages"
}
zedboot_images = "//build/images/zedboot"
_qemu_deps = qemu_boot_shim.deps
assert(_qemu_deps == [ _qemu_deps[0] ])
qemu_kernel = _qemu_deps[0]
}
supports_flashing_fxfs =
fxfs_blob && fxfs_partition != "" && !use_bringup_assembly
# These are the common assembly-related files.
files = {
if (use_bazel_images_only) {
bazel_target_name = get_label_info(labels.images, "name")
images_outdir = get_label_info(labels.images, "target_gen_dir") +
"/${bazel_target_name}/product_bundle"
assembly_outdir = images_outdir + "/system_a"
bazel_package_manifests_list =
get_label_info(labels.images, "target_out_dir") +
"/${bazel_target_name}/manifests/package_manifests.list"
} else {
images_outdir = get_label_info(labels.images, "target_out_dir")
assembly_outdir = images_outdir + "/${labels.assembly_name}"
}
zedboot_assembly_outdir =
get_label_info(labels.zedboot_images, "target_out_dir") + "/zedboot"
if (!use_bringup_assembly) {
blobfs = "${assembly_outdir}/blob.blk"
if (fxfs_blob) {
fxfs = "${assembly_outdir}/fxfs.blk"
} else {
fvm = "${assembly_outdir}/fvm.blk"
fvm_sparse = "${assembly_outdir}/fvm.sparse.blk"
}
if (fvm_partition != "" && include_fvm_blob_sparse) {
fvm_blob_sparse = "${assembly_outdir}/fvm.blob.sparse.blk"
}
if (supports_fastboot_fvm) {
fvm_fastboot = "${assembly_outdir}/fvm.fastboot.blk"
}
base_package_names = "$root_build_dir/base_packages.list"
cache_package_names = "$root_build_dir/cache_packages.list"
universe_package_names = "$root_build_dir/universe_packages.list"
manifests_from_metadata =
"$root_build_dir/package_manifests_from_metadata.list"
# TODO(https://fxbug.dev/98480) move these to image-relative paths along with tools' usages
base_package_manifests = "$root_build_dir/base_package_manifests.list"
cache_package_manifests = "$root_build_dir/cache_package_manifests.list"
universe_package_manifests =
"$root_build_dir/universe_package_manifests.list"
# TODO(https://fxbug.dev/123120): Audit and add the following paths when
# only Bazel assembly is enabled.
if (!use_bazel_images_only) {
flash_manifest = "${images_outdir}/flash_manifest/flash.json"
}
}
if (use_gigaboot) {
esp = "${root_out_dir}/fuchsia.esp.blk"
}
_image_suffix = "zbi"
if (sign_zbi) {
_image_suffix = "zbi.signed"
}
# The zbi and vbmeta created by assembly
zbi = "${assembly_outdir}/${labels.assembly_name}.${_image_suffix}"
vbmeta = "${assembly_outdir}/${labels.assembly_name}.vbmeta"
if (use_bazel_images_only) {
# Final image and vbmeta are not copied to root in Bazel assembly.
final_zbi = zbi
final_vbmeta = vbmeta
} else {
# Final output image and vbmeta (the files at the above paths are copied here)
final_zbi = "${root_out_dir}/" + rebase_path(zbi, assembly_outdir)
final_vbmeta = "${root_out_dir}/" + rebase_path(vbmeta, assembly_outdir)
}
# Recovery output image and vbmeta
if (recovery_is_zedboot) {
_recovery_outdir = zedboot_assembly_outdir
recovery_zbi = "${zedboot_assembly_outdir}/zedboot.${_image_suffix}"
recovery_vbmeta = "${zedboot_assembly_outdir}/zedboot.vbmeta"
} else if (recovery_is_recovery_eng) {
_recovery_outdir = root_out_dir
recovery_zbi = "${root_out_dir}/obj/build/images/recovery/recovery-eng/recovery-eng.${_image_suffix}"
recovery_vbmeta = "${root_out_dir}/obj/build/images/recovery/recovery-eng/recovery-eng.vbmeta"
} else if (recovery_is_recovery_fastboot) {
_recovery_outdir = root_out_dir
recovery_zbi = "${root_out_dir}/obj/build/images/recovery/recovery-fastboot/recovery-fastboot.${_image_suffix}"
recovery_vbmeta = "${root_out_dir}/obj/build/images/recovery/recovery-fastboot/recovery-fastboot.vbmeta"
} else {
# The standard recovery image and vbmeta locations.
_recovery_outdir = root_out_dir
recovery_zbi = "${root_out_dir}/recovery.${_image_suffix}"
recovery_vbmeta = "${root_out_dir}/recovery.vbmeta"
}
final_recovery_zbi =
"${root_out_dir}/" + rebase_path(recovery_zbi, _recovery_outdir)
final_recovery_vbmeta =
"${root_out_dir}/" + rebase_path(recovery_vbmeta, _recovery_outdir)
installer_zbi = "${root_out_dir}/obj/build/images/recovery/recovery-installer/recovery-installer.${_image_suffix}"
installer_vbmeta = "${root_out_dir}/obj/build/images/recovery/recovery-installer/recovery-installer.vbmeta"
qemu_kernel = qemu_boot_shim.path
}