blob: 4ac05247b4ef9aeb38bc86e7bee5507f045af65e [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/assembly/package_list.gni")
import("//build/board.gni")
import("//build/compiled_action.gni")
import("//build/component/component_id_index.gni")
import("//build/config.gni")
import("//build/config/clang/clang.gni")
import("//build/dist/fini_manifest.gni")
import("//build/drivers/driver_manifest.gni")
import("//build/images/args.gni")
import("//build/images/custom_signing.gni")
import("//build/images/paths.gni")
import("//build/images/shell_commands.gni")
import("//build/images/size_checker/size_checker_input.gni")
import("//build/images/vbmeta.gni")
import("//build/images/vboot/vboot.gni")
import("//build/info/info.gni")
import("//build/product.gni")
import("//build/sdk/config.gni")
import("//build/security.gni")
import("//build/zbi/zbi_input.gni")
import("//build/zircon/tools.gni")
assert(current_toolchain == default_toolchain,
"//build/images/* are only valid in the Fuchsia toolchain")
assert(
bootfs_only == use_bringup_assembly,
"use_bringup_assembly is replacing bootfs_only, and MUST always be the same value")
# This is a group that contains the one-and-only assembly implementation. It
# can be used in contexts that need either bringup or the full-fuchsia assembly
# implementation's outputs.
#
# If a target requires the outputs of the full-fuchsia assembly implementation,
# it should directly use it (//build/images/fuchsia).
group("main_assembly") {
testonly = use_bringup_assembly || fuchsia_zbi_testonly
public_deps = [ labels.images ]
}
# Dependencies for all image targets referenced by paver_targets, i.e., the
# images needed by the generated pave scripts.
default_image_deps = [ labels.images ]
board_name_file = "$root_build_dir/board_name"
write_file(board_name_file, "${board_name}")
###
### Zircon Boot Images
###
# Used to populate image_paths.sh with the right values to point to the QEMU kernel.
group("qemu-kernel") {
metadata = {
image_paths = [ "IMAGE_QEMU_KERNEL_RAW=" +
rebase_path(files.qemu_kernel, root_build_dir) ]
}
deps = [ labels.qemu_kernel ]
}
default_image_deps += [ ":qemu-kernel" ]
# This action runs a script that checks all vtables in fuchsia binaries are
# in readonly data.
action("check_vtables_in_rodata") {
testonly = true
hermetic_deps = false
script = "//scripts/clang/check_vtable_rodata.py"
outputs = [ "$root_build_dir/$target_name" ]
depfile = "$root_build_dir/$target_name.d"
# Ensure that all fuchsia binaries listed in `binaries.json` are created
# first.
deps = [ labels.images ]
args = [
# Ignore these specific libunwind symbols for now because these are from
# the libwundind prebuilts used by rust which we do not currently build
# with relative vtables.
"--exclude",
"vtable for libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>",
"--exclude",
"vtable for libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>",
"--readelf",
"$rebased_clang_prefix/llvm-readelf",
# Write to a file.
"-o",
rebase_path(outputs[0], root_build_dir),
# Run in `fuchsia` mode, which looks for `binaries.json` in the provided
# output directory.
"fuchsia",
# Point to the output directory.
rebase_path("$root_build_dir", root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
}
group("fvm.sparse.blk") {
testonly = fuchsia_zbi_testonly
public_deps = [ labels.images ]
}
group("fvm.blob.sparse.blk") {
testonly = fuchsia_zbi_testonly
public_deps = [ labels.images ]
}
group("fvm.fastboot.blk") {
testonly = fuchsia_zbi_testonly
public_deps = [ labels.images ]
}
group("fuchsia") {
testonly = fuchsia_zbi_testonly
public_deps = [ labels.images ]
}
group("fuchsia.vbmeta") {
testonly = fuchsia_zbi_testonly
public_deps = [ labels.images ]
}
# Pseudo-target to record information about the sizes of filesystems assembled
# during the build for later analysis.
# TODO(fxbug.dev/81871): Only include this for builds that generate blobfs
# once this targets is no longer hardcoded in infra.
group("record_filesystem_sizes") {
testonly = true
if (!use_bringup_assembly) {
deps = [ "//build/images/sizes:elf_sizes.json" ]
}
}
default_image_deps += [ "//build/images/flash" ]
# If a GPT image was specified, make it available as a build artifact.
if (gpt_image != "") {
copy("gpt") {
testonly = true
sources = [ rebase_path(gpt_image, root_build_dir) ]
outputs = [ "$root_out_dir/gpt.bin" ]
metadata = {
images = [
{
label = get_label_info(":gpt", "label_with_toolchain")
archive = true
name = "gpt"
path = "gpt.bin"
type = "bin"
},
]
image_paths = [ "IMAGE_GPT=gpt.bin" ]
}
}
default_image_deps += [ ":gpt" ]
}
default_image_deps += [ "//build/images/tools:board_tools" ]
default_image_deps += [ recovery_label ]
# Build the UEFI disk image.
# GCE, a consumer of this image, requires it to be named disk.raw
uefi_disk_path = "$target_out_dir/disk.raw"
mkfs_label = "//zircon/third_party/uapp/mkfs-msdosfs($host_toolchain)"
mkfs_out_dir = get_label_info(mkfs_label, "root_out_dir")
mkfs_bin = "$mkfs_out_dir/mkfs-msdosfs"
if (!use_bringup_assembly) {
fvm_tool_target = "//src/storage/bin/fvm($host_toolchain)"
fvm_tool_path = get_label_info(fvm_tool_target, "root_out_dir") + "/fvm"
}
compiled_action("uefi-disk") {
no_output_dir_leaks = false
deps = [
"zedboot",
"//src/firmware/gigaboot:bootloader(//src/firmware/gigaboot:efi_$target_cpu)",
labels.images,
mkfs_label,
]
testonly = true
tool = "//tools/make-fuchsia-vol"
inputs = [ mkfs_bin ]
bootloader_path = "efi_${target_cpu}/boot${target_cpu}.efi"
if (target_cpu == "arm64") {
bootloader_path = "efi_${target_cpu}/bootaa64.efi"
}
args = [
"-fuchsia-build-dir",
rebase_path("$root_build_dir"),
"-arch",
target_cpu,
"-bootloader",
bootloader_path,
"-resize",
"10000000000", # 10GB
]
if (use_bringup_assembly) {
args += [ "-ramdisk-only" ]
} else {
inputs += [
fvm_tool_path,
files.minfs,
# TODO(fxbug.dev/82077): Switch this to the new path the uefi script is
# switched over to using it (or taking it as an argument).
files.old_blobfs_path,
]
deps += [
"//src/storage/bin/fvm:fvm(//build/toolchain:host_x64)",
labels.images,
]
}
args += [ rebase_path(uefi_disk_path) ]
outputs = [ uefi_disk_path ]
metadata = {
images = [
{
label = get_label_info(":$target_name", "label_with_toolchain")
archive = false
name = "uefi-disk"
path = rebase_path(uefi_disk_path, root_build_dir)
type = "blk"
},
]
}
}
group("images") {
testonly = true
deps = [
":default-images",
"//build/images/archive:build_args_metadata",
]
if (defined(labels.images_netboot)) {
deps += [ labels.images_netboot ]
}
}
# The default-images target is a dependency of the top level default
# target when appropriate, and contains the minimum set of images that
# are typical given the requested build configuration.
group("default-images") {
testonly = true
deps = default_image_deps + [
"//build/images/flash:fastboot_manifest",
"//build/images/flash:flash_script",
"//build/images/tools:fastboot",
]
if (size_checker_input != {
}) {
# Size checks only make sense when use_bringup_assembly is false, since
# they require system images in addition to the ZBI.
deps += [ "size_checker:size_report.json" ]
}
if (recovery_is_zedboot) {
deps += [
"//build/images/archive:paver-script",
"//build/images/archive:zedboot-script",
"//build/images/tools:bootserver",
]
}
if (build_uefi_disk) {
deps += [ ":uefi-disk" ]
}
if (enable_netboot) {
deps += [ "archive:netboot-script" ]
}
# TODO(fxbug.dev/46415): The build graph for "bringup" (use_bringup_assembly) MUST only
# contain one zircon-a metadata target, which means that anything
# reaching fuchsia.zbi must be excluded from the build graph.
if (!use_bringup_assembly) {
deps += [
":record_filesystem_sizes",
"//build/images/updates",
]
deps += [ "//build/images/flash:product_metadata" ]
} else {
deps += [ "//build/images/archive:fastboot-boot-script" ]
}
if (check_vtables_in_rodata) {
deps += [ ":check_vtables_in_rodata" ]
}
if (build_usb_installer) {
deps += [ "//build/installer_images" ]
}
}
generated_file("image_paths") {
testonly = true
outputs = [ "$root_build_dir/image_paths.sh" ]
output_conversion = "list lines"
data_keys = [ "image_paths" ]
deps = [ ":images" ]
}