blob: 4b884b95d39bdbd195f9554bc402e1174fae36f2 [file] [log] [blame]
# 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/config/clang/clang.gni")
import("//build/config/fuchsia/bootdata.gni")
import("//build/gn/packages.gni")
import("//build/images/boot.gni")
import("//build/images/manifest.gni")
import("//build/package.gni")
import("//build/sdk/sdk_atom.gni")
import("//garnet/go/src/amber/amber.gni")
###
### Zircon BOOTFS and kernel command-line BOOTDATA images. These are not
### directly usable, but they capture all the Zircon bits and are ready to
### be combined with a system image to make a complete image.
###
declare_args() {
# File containing kernel command line arguments to roll into the
# bootdata image used for booting.
kernel_cmdline_file = ""
# Groups to include from the Zircon /boot manifest into /boot.
# This is either "all" or a comma-separated list of one or more of:
# core -- necessary to boot
# misc -- utilities in /bin
# test -- test binaries in /bin and /test
zircon_boot_groups = "core"
}
declare_args() {
# Groups to include from the Zircon /boot manifest into /system
# (instead of into /boot like Zircon's own bootdata.bin does).
# Should not include any groups that are also in zircon_boot_groups,
# which see. If zircon_boot_groups is "all" then this should be "".
if (zircon_boot_groups == "all") {
zircon_system_groups = ""
} else {
# TODO(mcgrathr): Could default to "" for !is_debug, or "production
# build". Note including "test" here places all of Zircon's tests
# into /system/test, which means that Fuchsia bots run those tests
# too.
zircon_system_groups = "misc,test"
}
}
# image_paths aggregates a list of environment variable style strings of the form:
# IMAGE_{NAME}_{TYPE}=path
# path is relative to $root_build_dir.
# This will be written out at generation time and is later consumed by
# //scripts and various tools to find the relevant images.
# TYPE can be: SPARSE (sparse FVM), RAW (block image for any FS), ZBI (bootable
# zircon image), RAM (ramdisk without kernel), VBOOT (bootable zircon image
# with a vboot signature).
image_paths = []
if (zircon_boot_groups == "all") {
assert(zircon_system_groups == "",
"zircon_boot_groups already has everything")
} else {
assert(zircon_system_groups != "all" && zircon_system_groups != "core",
"zircon_system_groups cannot include core (or all)")
}
# Generate the manifest of pure Zircon components going into /boot.
generate_manifest("boot.manifest") {
visibility = [ ":*" ]
zircon_groups = zircon_boot_groups
args = []
}
boot_manifest_outputs = get_target_outputs(":boot.manifest")
boot_manifest = boot_manifest_outputs[0]
boot_build_id_map = boot_manifest_outputs[1]
# Generate a BOOTDATA container of the compressed BOOTFS image for /boot.
# It only has to be compressed once, and then this container is combined
# with more BOOTDATA below to make specific images for booting.
bootdata("boot") {
visibility = [ ":*" ]
boot = true
deps = [
":boot.manifest",
]
inputs = [
boot_manifest,
]
}
# Inject fixed kernel command-line arguments maintained in the source tree.
bootdata_cmdline("cmdline") {
visibility = [ ":*" ]
inputs = [
"cmdline.txt",
]
}
# Let the build configuration choose some extra fixed command-line arguments.
if (kernel_cmdline_file != "") {
bootdata_cmdline("extra_cmdline") {
visibility = [ ":*" ]
inputs = [
kernel_cmdline_file,
]
}
}
# This makes the complete Zircon BOOTDATA image (sans the kernel itself).
# This includes the /boot filesystem and the fixed kernel command line
# settings from the build (cmdline.txt and build argument
# `kernel_cmdline_file`).
bootdata("bootdata") {
deps = [
":boot",
":cmdline",
]
if (kernel_cmdline_file != "") {
deps += [ ":extra_cmdline" ]
}
inputs = []
foreach(label, deps) {
inputs += get_target_outputs(label)
}
}
###
### Fuchsia system image. This aggregates contributions from all the
### package() targets enabled in the build.
###
pm_binary_label = "//garnet/go/src/pm:pm_bin($host_toolchain)"
pm_out_dir = get_label_info(pm_binary_label, "root_out_dir")
pm_binary = "$pm_out_dir/pm"
# This just runs `pm -k $system_package_key genkey` if the file doesn't exist.
# Every package() target depends on this.
action("system_package_key_check") {
visibility = [ "*" ]
deps = [
pm_binary_label,
]
outputs = [
"$target_out_dir/system_package_key_check_ok.stamp",
]
script = "//build/gn_run_binary.sh"
inputs = [
"system_package_key_check.py",
pm_binary,
]
args =
[ clang_prefix ] + rebase_path(inputs + outputs + [ system_package_key ])
}
# The pkgsvr index is a manifest mapping `package_name/package_version` to
# the merkleroot of the package's meta.far file.
pkgsvr_index = "$target_out_dir/pkgsvr_index"
action("pkgsvr_index") {
visibility = [ ":system_image.manifest", ":update_packages.manifest" ]
testonly = true
script = "manifest.py"
args = [ "--contents" ]
outputs = [
"$target_out_dir/$target_name",
]
args += [ "--output=" + rebase_path(outputs[0], root_build_dir) ]
sources = []
deps = []
foreach(pkg_label, package_targets) {
# Find the response file written by package().
pkg_target_name = get_label_info(pkg_label, "name")
pkg_target_out_dir = get_label_info(pkg_label, "target_out_dir")
pkg_rspfile = "$pkg_target_out_dir/${pkg_target_name}.pkgsvr_index.rsp"
deps += [ "${pkg_label}.pkgsvr_index.rsp" ]
sources += [ pkg_rspfile ]
args += [ "@" + rebase_path(pkg_rspfile, root_build_dir) ]
}
}
# The system_image "package" manifest is everything that appears in /system.
generate_manifest("system_image.manifest") {
visibility = [ ":*" ]
testonly = true
# First we take the /boot manifest as a "dummy". This means that its
# libraries are used to resolve references from binaries going into
# the output manifest (below) with the assumption that they'll be
# available to dynamic linking at runtime, but none of the files from
# the /boot manifest actually go into the output.
dummy_deps = [ ":boot.manifest" ]
# Collect whatever we want from Zircon that didn't go into /boot.
zircon_groups = zircon_system_groups
# Now each package() target in the build contributes manifest entries.
# For system_image packages, these contain binaries that need their
# references resolved from the auxiliary manifests or /boot (above).
args = []
deps = []
sources = []
foreach(pkg_label, package_targets) {
# Find the response file written by package().
pkg_target_name = get_label_info(pkg_label, "name")
pkg_target_out_dir = get_label_info(pkg_label, "target_out_dir")
pkg_system_rsp = "$pkg_target_out_dir/${pkg_target_name}.system.rsp"
deps += [ pkg_label ]
sources += [ pkg_system_rsp ]
args += [ "@" + rebase_path(pkg_system_rsp, root_build_dir) ]
}
args += [ "--entry-manifest=" +
get_label_info(":$target_name", "label_no_toolchain") ]
# Add the meta/package JSON file that makes this the "system_image" package.
json = "system_meta_package.json"
sources += [ json ]
args += [ "--entry=meta/package=" + rebase_path(json, root_build_dir) ]
# Add the static packages (pkgsvr) index.
deps += [ ":pkgsvr_index" ]
sources += [ pkgsvr_index ]
args += [ "--entry=data/static_packages=" +
rebase_path(pkgsvr_index, root_build_dir) ]
# Add pkgsvr, required to serve a system image package.
pkgsvr_binary_label = "//garnet/go/src/pmd:pkgsvr_bin"
deps += [ pkgsvr_binary_label ]
sources += [ get_label_info(pkgsvr_binary_label, "root_out_dir") + "/pkgsvr" ]
}
system_manifest_outputs = get_target_outputs(":system_image.manifest")
system_manifest = system_manifest_outputs[0]
system_build_id_map = system_manifest_outputs[1]
# Generate, sign, and seal the system_image package file.
pm_build_package("system_image.meta") {
visibility = [ ":*" ]
testonly = true
manifest = ":system_image.manifest"
}
# Now generate the blob manifest. This lists all the source files
# that need to go into the blobfs image. That is everything from the
# system_image manifest, everything from each package manifest, and
# all the synthesized meta.far files.
blob_manifest = "$root_build_dir/blob.manifest"
action("blob.manifest") {
visibility = [ ":*" ]
testonly = true
deps = [
":system_image.manifest",
":system_image.meta",
]
outputs = [
blob_manifest,
]
inputs = [
system_manifest,
]
script = "manifest.py"
args = [ "@{{response_file_name}}" ]
response_file_contents = [
"--sources",
"--output=" + rebase_path(blob_manifest, root_build_dir),
"--manifest=" + rebase_path(system_manifest, root_build_dir),
"--entry=system_image/meta.far=" +
rebase_path("$target_out_dir/system_image.meta/meta.far",
root_build_dir),
]
foreach(pkg_label, package_targets) {
pkg_target_name = get_label_info(pkg_label, "name")
pkg_target_out_dir = get_label_info(pkg_label, "target_out_dir")
pkg_blob_rsp = "$pkg_target_out_dir/${pkg_target_name}.blob.rsp"
deps += [ "${pkg_label}.blob.rsp" ]
inputs += [ pkg_blob_rsp ]
response_file_contents +=
[ "@" + rebase_path(pkg_blob_rsp, root_build_dir) ]
}
}
# Pack up all the blobs!
zircon_tool_action("blob.blk") {
visibility = [
":fvm.blk",
":fvm.sparse.blk",
]
testonly = true
deps = [
":blob.manifest",
]
blob_image_path = "$images_dir/$target_name"
outputs = [
blob_image_path,
]
inputs = [
blob_manifest,
]
tool = "blobfs"
args = [
rebase_path(blob_image_path),
"create",
"--manifest",
rebase_path(blob_manifest, root_build_dir),
]
}
blob_raw_image_path = get_target_outputs(":blob.blk")
image_paths += [ "IMAGE_BLOB_RAW=" + rebase_path(blob_raw_image_path[0], root_build_dir) ]
# Calculate the merkleroots that go into the kernel command line switches.
zircon_tool_action("system_image_merkleroots") {
visibility = [ ":*" ]
testonly = true
outputs = [
"$target_out_dir/$target_name",
]
pkgsvr_binary_label = "//garnet/go/src/pmd:pkgsvr_bin"
deps = [
":system_image.meta",
pkgsvr_binary_label,
]
sources = [
get_label_info(pkgsvr_binary_label, "root_out_dir") + "/pkgsvr",
"$target_out_dir/system_image.meta/meta.far",
]
tool = "merkleroot"
args = [ "-o" ] + rebase_path(outputs + sources, root_build_dir)
}
# Massage that into the kernel command line text for
# zircon.system.blob-init and zircon.system.blob-init-arg.
action("system_image_cmdline.txt") {
visibility = [ ":*" ]
testonly = true
outputs = [
"$target_out_dir/$target_name",
]
deps = [
":system_image_merkleroots",
]
sources = get_target_outputs(":system_image_merkleroots")
script = "system_image_cmdline.py"
args = rebase_path(outputs + sources, root_build_dir)
}
# Package that command line up as BOOTDATA.
bootdata_cmdline("system_image_cmdline") {
visibility = [ ":*" ]
testonly = true
deps = [
":system_image_cmdline.txt",
]
inputs = get_target_outputs(":system_image_cmdline.txt")
}
# Combine the /boot, /system, and package build ID maps into one.
action("ids.txt") {
testonly = true
deps = [
":boot.manifest",
":system_image.manifest",
]
sources = [
boot_build_id_map,
system_build_id_map,
]
foreach(pkg_label, package_targets) {
# Find the ids.txt file written by package().
manifest = get_label_info(pkg_label, "label_no_toolchain") + ".manifest"
manifest_target_name = get_label_info(manifest, "name")
manifest_target_out_dir = get_label_info(manifest, "target_out_dir")
deps += [ manifest ]
sources += [ "$manifest_target_out_dir/${manifest_target_name}.ids.txt" ]
}
script = "/usr/bin/sort"
outputs = [
"$root_out_dir/ids.txt",
]
args = [
"-u",
"-o",
] + rebase_path(outputs + sources, root_build_dir)
}
###
### Complete images for booting and installing the whole system.
###
declare_args() {
# The size of the minfs data partition image to create. Normally this image
# is added to FVM, and can therefore expand as needed. It must be at least
# 10mb (the default) in order to be succesfully initialized.
data_image_size = "10m"
# The size in bytes of the FVM partition image to create. Normally this is
# computed to be just large enough to fit the blob and data images. The
# default value is "", which means to size based on inputs. Specifying a size
# that is too small will result in build failure.
fvm_image_size = ""
# Build boot images that prefer Zedboot over local boot.
always_zedboot = false
}
template("generate_fvm") {
zircon_tool_action(target_name) {
visibility = [ ":*" ]
forward_variables_from(invoker, [ "testonly" ])
tool = "fvm"
outputs = [
invoker.output_name,
]
sources = []
deps = invoker.deps
foreach(label, deps) {
sources += get_target_outputs(label)
}
args = rebase_path(outputs, root_build_dir) + invoker.args +
rebase_path(sources, root_build_dir)
}
}
fvm_create_args = [ "create" ]
fvm_sparse_args = [
"sparse",
"--compress",
"lz4",
]
# fvm.blk creates a non-sparse FVM partition image containing the blob
# partition produced by blob.blk. fvm.blk is primarily invoked and used
# by the qemu run, via `fx run-fvm`.
generate_fvm("fvm.blk") {
testonly = true
output_name = "$images_dir/fvm.blk"
deps = [
":blob.blk",
]
args = fvm_create_args
if (fvm_image_size != "") {
args += [
"--length",
fvm_image_size,
]
}
args += [ "--blob" ]
}
fvm_raw_image_path = get_target_outputs(":fvm.blk")
image_paths += [ "IMAGE_FVM_RAW=" + rebase_path(fvm_raw_image_path[0], root_build_dir) ]
# fvm.sparse.blk creates a sparse FVM partition image containing the blob
# partition produced by blob.blk. fvm.sparse.blk is primarily invoked and
# used by the paver boot, via `fx boot-paver`.
generate_fvm("fvm.sparse.blk") {
testonly = true
output_name = "$images_dir/fvm.sparse.blk"
deps = [
":blob.blk",
]
args = fvm_sparse_args + [ "--blob" ]
}
fvm_sparse_image_path = get_target_outputs(":fvm.sparse.blk")
image_paths += [ "IMAGE_FVM_SPARSE=" + rebase_path(fvm_sparse_image_path[0], root_build_dir) ]
# data.blk creates an empty but initialized minfs data partition.
# The partition is included in fvm.data.sparse.blk.
zircon_tool_action("data.blk") {
tool = "minfs"
data_image_path = "$target_out_dir/$target_name"
outputs = [
data_image_path,
]
args = [
rebase_path(data_image_path, root_build_dir) + "@${data_image_size}",
"create",
]
}
data_raw_image_path = get_target_outputs(":data.blk")
image_paths += [ "IMAGE_DATA_RAW=" + rebase_path(data_raw_image_path[0], root_build_dir) ]
# fmv.data.sparse.blk is an FVM image containing only data.blk. It is
# used to pave new data partitions to a device.
generate_fvm("fvm.data.sparse.blk") {
output_name = "$images_dir/fvm.data.sparse.blk"
deps = [
":data.blk",
]
args = fvm_sparse_args + [ "--data" ]
}
data_fvm_raw_image_path = get_target_outputs(":fvm.data.sparse.blk")
image_paths += [ "IMAGE_DATA_FVM_RAW=" + rebase_path(data_fvm_raw_image_path[0], root_build_dir) ]
# This packs up Zircon with the command line to enable /system.
bootdata("bootdata-blob") {
visibility = [ ":*" ]
testonly = true
deps = [
":bootdata",
":system_image_cmdline",
]
inputs = []
foreach(label, deps) {
inputs += get_target_outputs(label)
}
}
bootdata_image_path = get_target_outputs(":bootdata-blob")
image_paths += [ "IMAGE_BOOT_RAM=" + rebase_path(bootdata_image_path[0], root_build_dir) ]
# This packs up the kernel itself with bootdata-blob (above). This can be
# booted directly from a partition by a Zircon-compatible boot loader and
# will find blobfs dynamically on storage.
bootdata("zircon-boot-blob") {
visibility = [ ":*" ]
testonly = true
inputs = [
"${zircon_build_dir}/zircon.bin",
]
deps = [
":bootdata-blob",
]
}
zircon_bin_image_path = get_target_outputs(":zircon-boot-blob")
image_paths += [ "IMAGE_ZIRCON_ZBI=" + rebase_path(zircon_bin_image_path[0], root_build_dir) ]
# This packs (compressed) fvm.blk into BOOTDATA_RAMDISK format,
# used by the netboot-* targets below.
bootdata_ramdisk("bootdata-fvm") {
visibility = [ ":*" ]
testonly = true
deps = [
":fvm.blk",
]
inputs = []
foreach(label, deps) {
inputs += get_target_outputs(label)
}
}
# This packs up a single BOOTDATA container that includes fvm.blk as a
# RAMDISK image. This can be used for network booting the full system
# without using any real storage. The system decompresses the fvm.blk
# image into memory and then sees that RAM disk just as if it were a
# real disk on the device.
bootdata("netboot") {
testonly = true
deps = [
":bootdata-blob",
":bootdata-fvm",
]
inputs = []
foreach(label, deps) {
inputs += get_target_outputs(label)
}
}
netboot_ram_image_path = get_target_outputs(":netboot")
image_paths += [ "IMAGE_NETBOOT_RAM=" + rebase_path(netboot_ram_image_path[0], root_build_dir) ]
# This packs the kernel itself with netboot (above). This can be booted
# directly from a partition by a Zircon-compatible boot loader and will
# find blobfs directly in the RAMDISK.
bootdata("zircon-netboot") {
visibility = [ ":*" ]
testonly = true
inputs = [
"${zircon_build_dir}/zircon.bin",
]
deps = [
":netboot",
]
}
netboot_zbi_image_path = get_target_outputs(":zircon-netboot")
image_paths += [ "IMAGE_NETBOOT_ZBI=" + rebase_path(netboot_zbi_image_path[0], root_build_dir) ]
# ChromeOS vboot images.
vboot("zircon") {
testonly = true
deps = [
":bootdata-blob",
]
}
zircon_vboot_image_path = get_target_outputs(":zircon.vboot")
image_paths += [ "IMAGE_ZIRCON_VBOOT=" + rebase_path(zircon_vboot_image_path[0], root_build_dir) ]
if (target_cpu != "arm64") {
# EFI ESP images.
esp("local") {
testonly = true
if (always_zedboot) {
cmdline = "zedboot/efi_cmdline.txt"
} else {
cmdline = "efi_local_cmdline.txt"
}
zircon_bin = "${zircon_build_dir}/zircon.bin"
# XXX(raggi): this path is shared with //build/images/BUILD.gn.
zedboot_bin = "$root_out_dir/zedboot.bin"
bootdatas = get_target_outputs(":bootdata-blob")
bootdata_bin = bootdatas[0]
deps = [
":bootdata-blob",
"zedboot:zedboot.bin",
]
}
esp_image_path = get_target_outputs(":local.esp.blk")
image_paths += [ "IMAGE_ESP_RAW=" + rebase_path(esp_image_path[0], root_build_dir) ]
}
# The installer needs all images except for fvm.blk (it has fvm.sparse.blk):
installer_images = [
"fvm.sparse.blk",
"fvm.data.sparse.blk",
"zircon.vboot",
]
installer_zedboot_images = [ "zedboot.vboot" ]
if (target_cpu != "arm64") {
installer_images += [ "local.esp.blk" ]
installer_zedboot_images += [ "zedboot.esp.blk" ]
}
installer_label = "//garnet/bin/installer:install-fuchsia"
installer_out_dir = get_label_info(installer_label, "root_out_dir")
installer_path = "$installer_out_dir/install-fuchsia"
action("installer.manifest") {
script = "manifest.py"
outputs = [
"$target_out_dir/installer.manifest",
]
args = [
"--output=" + rebase_path(outputs[0], root_build_dir),
"--output-cwd=" + rebase_path(target_out_dir, root_build_dir),
"--entry=install-fuchsia=" + rebase_path(installer_path, root_build_dir),
]
foreach(image, installer_images + installer_zedboot_images) {
args += [ "--entry=${image}=" +
rebase_path("$images_dir/$image", root_build_dir) ]
}
}
# installer.blk is a minfs partition image that includes all of the
# images required to install a Fuchsia build.
zircon_tool_action("installer") {
testonly = true
tool = "minfs"
deps = [
":installer.manifest",
installer_label,
]
outputs = [
"$images_dir/installer.blk",
]
sources = []
foreach(image, installer_images) {
deps += [ ":$image" ]
sources += [ "$images_dir/$image" ]
}
foreach(image, installer_zedboot_images) {
deps += [ "zedboot:$image" ]
sources += [ "$images_dir/$image" ]
}
args = [
rebase_path(outputs[0], root_build_dir),
"create",
"--manifest",
]
args += rebase_path(get_target_outputs(":installer.manifest"), root_build_dir)
}
installer_image_path = get_target_outputs(":installer")
image_paths += [ "IMAGE_INSTALLER_RAW=" + rebase_path(installer_image_path[0], root_build_dir) ]
# TODO(mcgrathr): Temporary until scripts and recipes get updated.
board = "qemu"
if (target_cpu == "x64") {
board = "pc"
}
copy("bootdata-blob-${board}.bin") {
testonly = true
outputs = [
"$root_out_dir/bootdata-blob-${board}.bin",
]
sources = [
"$root_out_dir/bootdata-blob.bin",
]
deps = [
":bootdata-blob",
]
}
if (target_cpu == "x64") {
copy("local-${board}.esp.blk") {
testonly = true
outputs = [
"$images_dir/local-${board}.esp.blk",
]
sources = [
"$images_dir/local.esp.blk",
]
deps = [
":local.esp.blk",
]
}
copy("zircon-${board}.vboot") {
testonly = true
outputs = [
"$images_dir/zircon-${board}.vboot",
]
sources = [
"$images_dir/zircon.vboot",
]
deps = [
":zircon.vboot",
]
}
}
group("legacy-images") {
visibility = [ ":images" ]
testonly = true
deps = [
":bootdata-blob-${board}.bin",
]
if (target_cpu == "x64") {
deps += [
":local-${board}.esp.blk",
":zircon-${board}.vboot",
]
}
}
group("images") {
testonly = true
deps = [
":fvm.blk",
":fvm.data.sparse.blk",
":fvm.sparse.blk",
":ids.txt",
":legacy-images",
":zircon-boot-blob",
":zircon.vboot",
"zedboot",
]
if (target_cpu != "arm64") {
deps += [ ":local.esp.blk" ]
}
}
# See definition of images_paths for purpose.
write_file("$root_build_dir/image_paths.sh", image_paths)
###
### Amber updates.
###
# update_packages.manifest contains the same entries as the pkgsvr_index but
# additionally includes the system_image package.
action("update_packages.manifest") {
visibility = [ ":update.manifest" ]
testonly = true
script = "manifest.py"
outputs = [ "$target_out_dir/$target_name" ]
args = [
"--contents",
"--output",
rebase_path(outputs[0], root_build_dir),
]
deps = []
sources = []
deps += [ ":system_image.meta" ]
args += [ "--entry=system_image/0=" + rebase_path("$target_out_dir/system_image.meta/meta.far.merkle", root_build_dir)]
foreach(pkg_label, package_targets) {
# Find the response file written by package().
pkg_target_name = get_label_info(pkg_label, "name")
pkg_target_out_dir = get_label_info(pkg_label, "target_out_dir")
pkg_rspfile = "$pkg_target_out_dir/${pkg_target_name}.pkgsvr_index.rsp"
deps += [ "${pkg_label}.pkgsvr_index.rsp" ]
sources += [ pkg_rspfile ]
args += [ "@" + rebase_path(pkg_rspfile, root_build_dir) ]
}
}
# The update package manifest contains the pkgsvr_index and the target system kernel images.
action("update.manifest") {
visibility = [ ":*" ]
testonly = true
script = "manifest.py"
outputs = [ "$target_out_dir/$target_name" ]
args = [ "--output=" + rebase_path(outputs[0], root_build_dir) ]
sources = []
deps = []
# Add the meta/package JSON file that makes this the "update" package.
json = "update_package.json"
sources += [ json ]
args += [ "--entry=meta/package=" + rebase_path(json, root_build_dir) ]
update_package_manifest_label = ":update_packages.manifest"
update_package_manifests = get_target_outputs(update_package_manifest_label)
update_package_manifest = update_package_manifests[0]
deps += [ update_package_manifest_label ]
args += [ "--entry=packages=" + rebase_path(update_package_manifest, root_build_dir) ]
# TODO(raggi): reconcile what kernel images should be included, instead of
# simply including all of them.
if (target_cpu != "arm64") {
efi_label = ":local.esp.blk"
deps += [ efi_label ]
efi_image = get_target_outputs(efi_label)
args += [ "--entry=efi=" + rebase_path(efi_image[0], root_build_dir) ]
}
# TODO(raggi): include ZBI as well here once it is ready.
vboot_label = ":zircon.vboot"
deps += [ vboot_label ]
vboot_image = get_target_outputs(vboot_label)
args += [ "--entry=kernc=" + rebase_path(vboot_image[0], root_build_dir) ]
}
pm_build_package("update.meta") {
visibility = [ ":*" ]
testonly = true
manifest = ":update.manifest"
}
# XXX(raggi): The following manifests retain the "meta/" files, resulting in
# them being added as blobs, which they should not be. A likely better solution
# here is to teach pm_build_package to produce either a blob manifest or a
# manifest.py --contents compatible response file that excludes these files.
action("update.sources.manifest") {
visibility = [ ":*" ]
testonly = true
script = "manifest.py"
deps = [ ":update.manifest" ]
outputs = [ "$target_out_dir/update.sources.manifest" ]
update_manifests = get_target_outputs(deps[0])
args = [
"--sources",
"--output=" + rebase_path(outputs[0], root_build_dir),
"--manifest=" + rebase_path(update_manifests[0])
]
}
zircon_tool_action("update.blobs.manifest") {
testonly = true
visibility = [ ":amber_publish_blobs" ]
tool = "merkleroot"
deps = [
":update.sources.manifest",
]
outputs = [
"$target_out_dir/$target_name",
]
inputs = get_target_outputs(deps[0])
args = [
"-m",
rebase_path(outputs[0]),
"@" + rebase_path(inputs[0]),
]
}
# The amber index is the pkgsvr index, but naming each meta.far file instead of
# its merkleroot. Additionally the amber_index has the system package itself,
# and the system update package.
amber_index = "$target_out_dir/amber_index"
action("amber_index") {
visibility = [ ":amber_publish_index" ]
testonly = true
script = "manifest.py"
args = [ "--absolute" ]
outputs = [
"$target_out_dir/$target_name",
]
args += [ "--output=" + rebase_path(outputs[0], root_build_dir) ]
sources = []
deps = []
foreach(pkg_label, package_targets) {
# Find the response file written by package().
pkg_target_name = get_label_info(pkg_label, "name")
pkg_target_out_dir = get_label_info(pkg_label, "target_out_dir")
pkg_rspfile = "$pkg_target_out_dir/${pkg_target_name}.amber_index.rsp"
deps += [ "${pkg_label}.amber_index.rsp" ]
sources += [ pkg_rspfile ]
args += [ "@" + rebase_path(pkg_rspfile, root_build_dir) ]
}
system_image_meta_dir = get_label_info(":system_image.meta", "target_out_dir") + "/system_image.meta"
system_image_meta_far = system_image_meta_dir + "/meta.far"
args += [ "--entry", "system_image/0=" + rebase_path(system_image_meta_far, root_build_dir) ]
deps += [ ":system_image.meta" ]
update_meta_dir = get_label_info(":update.meta", "target_out_dir") + "/update.meta"
update_meta_far = update_meta_dir + "/meta.far"
args += [ "--entry", "update/0=" + rebase_path(update_meta_far, root_build_dir) ]
deps += [ ":update.meta" ]
}
# The blob.manifest that drives blob.blk is just a flat list of files.
# blob_merkleroot.manifest is a manifest file of "HEXDIGITS=FILENAME"
# lines. Note that this repeats all the same merkleroot computations
# that blobfs does while building blob.blk, which is wasteful if the
# build is doing both (though the computations can go in parallel and
# filesystem caching should mitigate the cost of reading the files
# twice). If we're always going to build blob.blk, we could teach
# blobfs to emit this manifest on the side rather than recomputing it
# here. But if someone tells ninja to build `updates` without `images`,
# then this computation alone should be faster than building blob.blk.
zircon_tool_action("blob_merkleroot.manifest") {
testonly = true
visibility = [ ":amber_publish_blobs" ]
tool = "merkleroot"
deps = [
":blob.manifest",
]
outputs = [
"$target_out_dir/$target_name",
]
inputs = [
blob_manifest,
]
args = [
"-m",
rebase_path(outputs[0]),
"@" + rebase_path(blob_manifest),
]
}
# Populate the repository directory with content ID-named copies.
action("amber_publish_blobs") {
testonly = true
outputs = [
"$amber_repository_dir.stamp",
]
deps = [
":blob_merkleroot.manifest",
":update.blobs.manifest",
]
inputs = []
foreach(dep, deps) {
inputs += get_target_outputs(dep)
}
script = "manifest.py"
args = [
"--copytree",
"--output=" + rebase_path(amber_repository_blobs_dir),
"--stamp=" + rebase_path("$amber_repository_dir.stamp"),
]
foreach(manifest, inputs) {
args += [ "--manifest=" + rebase_path(manifest, root_build_dir) ]
}
}
# Sign and publish the package index.
amber_publish("amber_publish_index") {
testonly = true
deps = [
":amber_index",
]
inputs = [
amber_index,
]
}
group("updates") {
testonly = true
deps = [
":amber_publish_blobs",
":amber_publish_index",
":ids.txt",
]
}
# SDK
sdk_atom("fvm.blk_sdk") {
domain = "image"
name = "fvm.blk"
category = "partner"
testonly = true
files = [
{
source = "$images_dir/fvm.blk"
dest = "fvm.blk"
}
]
non_sdk_deps = [
":fvm.blk",
]
}
sdk_atom("bootdata-blob.bin_sdk") {
domain = "image"
name = "bootdata-blob.bin"
category = "partner"
testonly = true
files = [
{
source = "$root_out_dir/bootdata-blob.bin"
dest = "bootdata-blob.bin"
}
]
non_sdk_deps = [
":bootdata-blob",
]
}
# TODO(alainv): Add dependency to zircon.bin when such a target exists.
sdk_atom("zircon.bin_sdk") {
domain = "image"
name = "zircon.bin"
category = "partner"
testonly = true
files = [
{
source = "${zircon_build_dir}/zircon.bin"
dest = "zircon.bin"
}
]
}
sdk_atom("zircon.vboot_sdk") {
domain = "image"
name = "zircon.vboot"
category = "partner"
testonly = true
files = [
{
source = "$images_dir/zircon.vboot"
dest = "zircon.vboot"
}
]
non_sdk_deps = [
":zircon.vboot",
]
}
if (target_cpu != "arm64") {
sdk_atom("local.esp.blk_sdk") {
domain = "image"
name = "local.esp.blk"
category = "partner"
testonly = true
files = [
{
source = "$images_dir/local.esp.blk"
dest = "local.esp.blk"
}
]
non_sdk_deps = [
":local.esp.blk",
]
}
}
sdk_atom("fvm.sparse.blk_sdk") {
domain = "image"
name = "fvm.sparse.blk"
category = "partner"
testonly = true
files = [
{
source = "$images_dir/fvm.sparse.blk"
dest = "fvm.sparse.blk"
}
]
non_sdk_deps = [
":fvm.sparse.blk",
]
}