| # Copyright 2019 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/compare_image_assembly_configs.gni") |
| import("//build/assembly/compare_json_list.gni") |
| import("//build/assembly/generated_image_assembly_config.gni") |
| import("//build/assembly/generated_images_config.gni") |
| import("//build/assembly/hermetic_inputs_for_image_assembly.gni") |
| import("//build/assembly/legacy_assembly_input_bundle.gni") |
| import("//build/component/component_id_index.gni") |
| import("//build/config.gni") |
| import("//build/drivers/driver_manifest.gni") |
| import("//build/images/fvm.gni") |
| import("//build/images/shell_commands.gni") |
| import("//build/info/info.gni") |
| import("//build/packages/package_metadata.gni") |
| import("//build/zircon/tools.gni") |
| import("//src/developer/ffx/build/ffx_action.gni") |
| import("//src/storage/fshost/generated_fshost_config.gni") |
| |
| # Assembles a Fuchsia system. |
| # |
| # Given base, cache, and universe packages, assembles a Fuchsia system |
| # containing those packages. |
| # |
| # Parameters: |
| # |
| # image_name (optional; default: target_name) |
| # [string] A name to use for naming all outputs and generated files, instead |
| # of $target_name. |
| # |
| # output_dir (optional; default: target_out_dir) |
| # [string] The output directory into which the final system ZBI is written. |
| # |
| # output_name (optional; default: <target_name>.zbi) |
| # [string] The name of the final system ZBI file. |
| # |
| # testonly (optional) |
| # [bool] Usual GN meanings. |
| # |
| # Product parameters: |
| # |
| # product_assembly_config_file (optional) |
| # [file] A path to a product assembly config file. If not specified, a |
| # placeholder file will be generated and used. |
| # |
| # product_assembly_config_dep (optional) |
| # [label] A label for the above product assembly config, if it's the output |
| # of a build action. |
| # |
| # base_packages (required) |
| # [list of labels] The packages to include in the base package set. |
| # |
| # base_driver_packages (optional) |
| # [list of labels] The driver packages to include in the base package set. |
| # |
| # cache_packages (optional) |
| # [list of labels] The packages to cache in the images. |
| # |
| # universe_packages (optional) |
| # [list of labels] The packages to build in addition to the base and cache |
| # sets. These packages do not contribute to the produced images directly, |
| # however they may contribute to the config-data and shell-commands meta |
| # packages. |
| # |
| # meta_packages (optional) |
| # [list of labels] The packages to build in addition to the base and cache |
| # sets, but are base_packages themselves. These are packages that contain |
| # files that are generated based on other packages in the base, cache, |
| # and/or universe sets, and therefore cannot be part of those sets directly, |
| # or a GN dependency cycle will result. |
| # |
| # bootfs_labels (required) |
| # [list of labels] The objects installed on the bootfs partition of the |
| # generated ZBI. |
| # |
| # bootfs_package_labels (optional) |
| # [list of labels] The packages installed on the bootfs partition of the |
| # generated ZBI as meta.fars and content-id'd blobs. |
| # |
| # system_image_deps (optional) |
| # [list of labels] The objects installed in the system image. |
| # |
| # devmgr_config (default: []) |
| # [list of strings] List of arguments to add to /boot/config/devmgr. |
| # These arguments come after synthesized arguments to configure blobfs. |
| # |
| # fshost_config (default: {}) |
| # [scope] Arguments to add to fshost's configuration. These |
| # arguments come before other arguments set by build args. |
| # |
| # cmdline (optional) |
| # [list of strings] Kernel command line text. |
| # |
| # cmdline_deps (optional) |
| # [list of labels] Dependencies with metadata including additional kernel |
| # command arguments to add to the ZBI. |
| # |
| # include_component_id_index (default: false) |
| # [bool] Collect and merges a component id index from the base |
| # package set. |
| # |
| # include_shell_commands (default: true) |
| # [bool] Whether to include shell commands. Should be set to false for |
| # build without shell access. |
| # |
| # include_config_data (default: true) |
| # [bool] Whether to create a config_data package for the assembly or not. |
| # |
| # base_package_name (optional; default: "system_image") |
| # [string] The name to give the base package. For prime builds this |
| # should be "system_image_prime", so that the package does not override the |
| # non-prime package during publishing. |
| # |
| # Board parameters: |
| # |
| # assembly_compress_blobs (default: true) |
| # [boolean] Whether the blobs added to the blobfs image should be compressed. |
| # |
| # assembly_blob_layout_format (default: "compact") |
| # [string] The format blobfs should store blobs in. The valid values are "deprecated_padded" and |
| # "compact". The deprecated padded format is supported only for Astro devices and will be |
| # removed in the future (it wastes space). |
| # |
| # check_production_tag (default: false) |
| # [bool] Whether to check there is no non_production_tag dependencies. |
| # |
| # Board: MinFS parameters: |
| # |
| # minfs_minimum_data_bytes, minfs_maximum_bytes (optional) |
| # [int] Size options for minfs to pass to the fvm tool. |
| # |
| # Board: BlobFS parameters |
| # |
| # blobfs_minimum_inodes, blobfs_minimum_data_bytes, blobfs_maximum_bytes, blobfs_maximum_contents_size (optional) |
| # [int] Size options for blobfs to pass to the fvm tool. |
| # |
| # Board: FVM parameters |
| # |
| # generate_fvm (optional; default: true) |
| # [bool] Whether to generate a FVM image. |
| # |
| # assembly_include_account_in_fvm (optional; default: false) |
| # [bool] Whether to include an account partition in the FVM image. |
| # |
| # ramdisk_fvm_in_zbi (optional) |
| # [bool] Whether the FVM should be embedded into the ZBI as a ramdisk. |
| # |
| # assembly_fvm_slice_size (optional; default: 1048576) |
| # [int] The slice size of the FVM. |
| # |
| # fvm_truncate_to_length (optional) |
| # [int] The precise size to make the (non-sparse) FVM image. See |
| # documentation of the `--length` parameter of the `fvm` binary host tool |
| # for details. |
| # |
| # Board: ZBI arguments |
| # |
| # zbi_name (optional; default: target_name) |
| # [string] The name to give the ZBI in the out directory. |
| # Typically: fuchsia, recovery, etc. |
| # |
| # zbi_signing_script (optional) |
| # [path] Location of script to use to sign the ZBI. |
| # |
| # zbi_signing_args (optional) |
| # [list of strings] Arguments to pass to the signing script. |
| # |
| # zbi_signing_script_deps (optional) |
| # [list of labels] Dependencies needed by the signing script. |
| # |
| template("assembled_system") { |
| assert(defined(invoker.base_packages), "Need to define base_packages") |
| assert(defined(invoker.bootfs_labels), "Need to define bootfs_labels") |
| |
| if (defined(invoker.product_assembly_config_dep)) { |
| assert( |
| invoker.product_assembly_config_dep != "", |
| "'product_assembly_config_dep' cannot be an empty string. Don't provide a value if it is not being used.") |
| assert(defined(invoker.product_assembly_config_file), |
| "Need to define a 'product_assembly_config_file'.") |
| } |
| if (defined(invoker.product_assembly_config_file)) { |
| assert( |
| invoker.product_assembly_config_file != "", |
| "'product_assembly_config_file' cannot be an empty string. Don't provide a value if it is not being used.") |
| } |
| |
| fvm_tool_target = "//src/storage/bin/fvm($host_toolchain)" |
| fvm_tool_path = get_label_info(fvm_tool_target, "root_out_dir") |
| fvm_tool_path += "/fvm" |
| |
| # This should be removed once all clients are no longer supplying board_name. |
| not_needed(invoker, [ "board_name" ]) |
| |
| image_name = target_name |
| if (defined(invoker.image_name)) { |
| image_name = invoker.image_name |
| } |
| |
| base_package_name = "system_image" |
| if (defined(invoker.base_package_name)) { |
| base_package_name = invoker.base_package_name |
| } |
| |
| # Internal labels used for Image Assembly. |
| labels = { |
| base_packages_group = "${image_name}.base_packages" |
| cache_packages_group = "${image_name}.cache_packages" |
| meta_packages_group = "${image_name}.meta_packages" |
| all_packages_group = "${image_name}.packages" |
| legacy_assembly_input_bundle = "${image_name}.legacy_input_bundle" |
| if (defined(invoker.product_assembly_config_dep)) { |
| product_assembly_config_deps = [ invoker.product_assembly_config_dep ] |
| } else { |
| product_assembly_config_deps = [] |
| } |
| image_assembly_config = "${image_name}.image_assembly_config" |
| image_assembly_inputs = "${image_name}.image_assembly_inputs" |
| compare_image_assembly_configs = |
| "${image_name}.compare_image_assembly_configs" |
| images_config = "${image_name}.images_config" |
| product_assembler = "${image_name}.product_assembler" |
| image_assembler = "${image_name}.image_assembler" |
| copy_vbmeta = "${image_name}.copy_vbmeta" |
| copy_zbi = "${image_name}.copy_zbi" |
| copy_zbi_signed = "${image_name}.copy_zbi_signed" |
| copy_zbi_manifest = "${image_name}.copy_zbi_manifest" |
| copy_images = "${image_name}.copy_images" |
| config_data = "${image_name}.config-data" |
| shell_commands = "${image_name}.shell_commands" |
| fshost_config = "${image_name}.fshost_config" |
| compare_command_logs = "${image_name}.compare_command_logs" |
| compare_images_manifests = "${image_name}.compare_images_manifests" |
| platform_aib = "//build/assembly" |
| } |
| |
| # Intermediate files produced for Image Assembly. |
| files = { |
| if (defined(invoker.product_assembly_config_file)) { |
| product_assembly_config = invoker.product_assembly_config_file |
| } else { |
| product_assembly_config = "//build/assembly/empty_product_config.json" |
| } |
| image_assembly_config = |
| "$target_out_dir/${image_name}.image_assembly_config.json" |
| image_assembly_inputs = |
| "$target_out_dir/${image_name}.image_assembly_inputs" |
| |
| images_config = "$target_out_dir/${image_name}.images_config.json" |
| |
| outdir = "$target_out_dir/$image_name" |
| gendir = "$outdir/gen" |
| |
| legacy_assembly_input_bundle_manifest = |
| "${outdir}/legacy/assembly_config.json" |
| platform_aib_dir = get_label_info(labels.platform_aib, "target_out_dir") |
| emulator_aib_manifest = |
| "$platform_aib_dir/emulator_support/assembly_config.json" |
| |
| # This file is created implicitly by ffx assembly product, so this is the |
| # path that it's expected to be found at, not the path that it's to be |
| # written to. |
| regenerated_image_assembly_config = "${outdir}/image_assembly.json" |
| config_data_manifest = "${outdir}/config_data/package_manifest.json" |
| compare_image_assembly_configs = |
| "${outdir}/compare_image_assembly_configs.verified" |
| |
| bootfs_files = "${gendir}/bootfs_files.list" |
| devmgr_config = "${gendir}/devmgr_config.txt" |
| zbi = "${outdir}/${image_name}.zbi" |
| zbi_signed = "${zbi}.signed" |
| vbmeta = "${outdir}/${image_name}.vbmeta" |
| minfs = "${outdir}/data.blk" |
| blobfs = "${outdir}/blob.blk" |
| fvm = "${outdir}/fvm.blk" |
| fvm_sparse = "${outdir}/fvm.sparse.blk" |
| fvm_blob_sparse = "${outdir}/fvm.blob.sparse.blk" |
| fvm_fastboot_tmp = "${outdir}/fvm.fastboot.tmp.blk" |
| fvm_fastboot = "${outdir}/fvm.fastboot.blk" |
| |
| base_package = "${outdir}/base/meta.far" |
| base_package_manifest = "${outdir}/base/package_manifest.json" |
| base_package_merkle = "${outdir}/base/base.merkle" |
| |
| packages = "${outdir}/packages.json" |
| zbi_manifest = "${gendir}/zbi.json" |
| blobfs_manifest = "${gendir}/blob.manifest" |
| blobs_json = "${gendir}/blobs.json" |
| bootfs_packages = "${gendir}/data/bootfs_packages" |
| static_packages = "${gendir}/${base_package_name}/data/static_packages" |
| cache_packages = "${gendir}/${base_package_name}/data/cache_packages.json" |
| base_meta_package = "${gendir}/${base_package_name}/meta/package" |
| base_pkg_abi_revision = |
| "${gendir}/${base_package_name}/meta/fuchsia.abi/abi-revision" |
| images_manifest = "${outdir}/images.json" |
| |
| image_command_log = "${gendir}/command_log.json" |
| |
| # Determine which ZBI we are shipping. |
| zbi_final = zbi |
| if (defined(invoker.zbi_signing_script)) { |
| zbi_final = zbi_signed |
| } |
| } |
| |
| _base_packages = invoker.base_packages |
| _base_driver_packages = [] |
| _cache_packages = [] |
| _universe_packages = [] |
| _meta_packages = [] |
| if (defined(invoker.base_driver_packages)) { |
| _base_driver_packages = invoker.base_driver_packages |
| } |
| _base_packages += _base_driver_packages |
| |
| if (defined(invoker.cache_packages)) { |
| _cache_packages = invoker.cache_packages |
| } |
| if (defined(invoker.universe_packages)) { |
| _universe_packages = invoker.universe_packages |
| } |
| if (defined(invoker.meta_packages)) { |
| _meta_packages = invoker.meta_packages |
| } |
| |
| generate_fvm = true |
| if (defined(invoker.generate_fvm)) { |
| generate_fvm = invoker.generate_fvm |
| } |
| |
| system_image_deps = [] |
| if (defined(invoker.system_image_deps) && generate_fvm) { |
| system_image_deps += invoker.system_image_deps |
| } else { |
| not_needed(invoker, [ "system_image_deps" ]) |
| } |
| |
| embed_fvm_in_zbi = false |
| if (defined(invoker.ramdisk_fvm_in_zbi)) { |
| embed_fvm_in_zbi = invoker.ramdisk_fvm_in_zbi && generate_fvm |
| } |
| |
| devmgr_config = [] |
| if (defined(invoker.devmgr_config)) { |
| devmgr_config = invoker.devmgr_config |
| } |
| |
| fshost_config = { |
| } |
| if (defined(invoker.fshost_config)) { |
| fshost_config = invoker.fshost_config |
| } |
| |
| include_shell_commands = true |
| if (defined(invoker.include_shell_commands)) { |
| include_shell_commands = invoker.include_shell_commands |
| } |
| |
| # Generate the base driver manifest file that lists all available drivers |
| # collected from _base_driver_packages dependency tree. This manifest file |
| # will be included in the driver-manager-base-config package. |
| base_driver_manifest_label = "${image_name}.base-driver-manifest" |
| combined_driver_manifest(base_driver_manifest_label) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| manifest_name = "base-driver-manifest.json" |
| deps = _base_driver_packages |
| } |
| |
| # The driver-manager-base-config package is read by Driver Manager to |
| # discover where the base drivers are located. |
| driver_manager_base_config_label = "${image_name}.driver-manager-base-config" |
| fuchsia_package(driver_manager_base_config_label) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| package_name = "driver-manager-base-config" |
| deps = [ ":${base_driver_manifest_label}" ] |
| } |
| _meta_packages += [ ":${driver_manager_base_config_label}" ] |
| |
| # TODO(fxbug.dev/81290): Construct the shell commands package in the Image |
| # Assembler. |
| if (include_shell_commands) { |
| shell_commands(labels.shell_commands) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| package_name = "shell-commands" |
| deps = _base_packages + _cache_packages + _universe_packages |
| } |
| _meta_packages += [ ":${labels.shell_commands}" ] |
| } else { |
| not_needed([ "_universe_packages" ]) |
| } |
| |
| component_id_index_dep = [] |
| component_id_index_config_data_dep = [] |
| include_component_index = defined(invoker.include_component_id_index) && |
| invoker.include_component_id_index |
| if (include_component_index) { |
| # For details, see //docs/development/components/component_id_index.md#system-assembly |
| component_id_index_config("${image_name}.component_id_index_config") { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| |
| # collect and merge component ID indices from the base set. |
| deps = _base_packages |
| |
| metadata = { |
| package_barrier = [] |
| } |
| } |
| |
| component_id_index_dep = [ ":${image_name}.component_id_index_config" ] |
| component_id_index_config_data_dep = |
| [ ":${image_name}.component_id_index_config-config-data" ] |
| _meta_packages += component_id_index_dep |
| } |
| |
| include_config_data = true |
| if (defined(invoker.include_config_data)) { |
| include_config_data = invoker.include_config_data |
| } |
| if (include_config_data) { |
| config_package(labels.config_data) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| package_name = "config-data" |
| deps = _base_packages + _universe_packages + _cache_packages + |
| component_id_index_config_data_dep |
| } |
| _meta_packages += [ ":${labels.config_data}" ] |
| } |
| |
| generated_fshost_config(labels.fshost_config) { |
| options = fshost_config |
| if (embed_fvm_in_zbi) { |
| fvm_ramdisk = true |
| } |
| } |
| |
| # Create GN groups for each of the package sets. |
| group(labels.base_packages_group) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| public_deps = _base_packages |
| } |
| |
| group(labels.cache_packages_group) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| public_deps = _cache_packages |
| } |
| |
| # The group of generated packages that contain files that depend on metadata |
| # walks of the base/cache/universe package sets and therefore cannot be part |
| # of those package sets. |
| group(labels.meta_packages_group) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| public_deps = _meta_packages |
| } |
| |
| ####### |
| # Build the images using the Image Assembler. |
| # |
| |
| generated_image_assembly_config(labels.image_assembly_config) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| |
| output_path = files.image_assembly_config |
| kernel_image = "//zircon/kernel" |
| |
| base_packages = [] |
| if (generate_fvm) { |
| base_packages = _base_packages |
| base_packages += _meta_packages |
| cache_packages = _cache_packages |
| } |
| |
| boot_args = devmgr_config |
| |
| # Search for BootFS packages in these targets. |
| bootfs_package_labels = [] |
| if (defined(invoker.bootfs_package_labels)) { |
| bootfs_package_labels += invoker.bootfs_package_labels |
| } |
| |
| # Search for BootFS files in these targets. |
| bootfs_labels = invoker.bootfs_labels |
| bootfs_labels += component_id_index_dep |
| bootfs_labels += [ "//zircon/kernel" ] |
| bootfs_labels += [ ":${labels.fshost_config}" ] |
| |
| # Only builds with an FVM need base-resolver/pkg-cache-resolver. |
| if (generate_fvm) { |
| bootfs_labels += [ "//src/sys/base-resolver:bootfs" ] |
| } |
| |
| # If not building an FVM, then put the driver_manager config into bootfs |
| if (!generate_fvm) { |
| bootfs_labels += [ ":${driver_manager_base_config_label}" ] |
| } |
| |
| extra_base_deps = system_image_deps |
| |
| # Search for the Kernel cmdline in the BootFS dependencies. |
| cmdline_deps = invoker.bootfs_labels |
| if (defined(invoker.cmdline_deps)) { |
| cmdline_deps += invoker.cmdline_deps |
| } |
| if (defined(invoker.cmdline)) { |
| cmdline = invoker.cmdline |
| } |
| } |
| |
| generated_images_config(labels.images_config) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| "zbi_signing_script", |
| "zbi_signing_args", |
| "minfs_maximum_bytes", |
| "minfs_minimum_data_bytes", |
| "blobfs_maximum_bytes", |
| "blobfs_minimum_data_bytes", |
| "blobfs_maximum_contents_size", |
| "blobfs_minimum_inodes", |
| "fvm_truncate_to_length", |
| ]) |
| |
| output_path = files.images_config |
| zbi_name = "${image_name}" |
| fvm_reserved_slices = fvm_reserved_slices |
| generate_fvm = generate_fvm |
| |
| fvm_slice_size = 1048576 |
| if (defined(invoker.assembly_fvm_slice_size)) { |
| fvm_slice_size = invoker.assembly_fvm_slice_size |
| } |
| |
| blob_layout_format = "compact" |
| if (defined(invoker.assembly_blob_layout_format)) { |
| blob_layout_format = invoker.assembly_blob_layout_format |
| } |
| |
| compress_blobs = true |
| if (defined(invoker.assembly_compress_blobs)) { |
| compress_blobs = invoker.assembly_compress_blobs |
| } |
| |
| if (defined(invoker.assembly_include_account_in_fvm)) { |
| empty_account_partition = invoker.assembly_include_account_in_fvm |
| } |
| } |
| |
| check_production_tag = false |
| if (defined(invoker.check_production_tag)) { |
| check_production_tag = invoker.check_production_tag |
| } |
| |
| # Create the legacy assembly input bundle for the above-generated image |
| # assembly configuration. |
| legacy_assembly_input_bundle(labels.legacy_assembly_input_bundle) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| image_assembly_label = ":${image_name}" |
| bundles_dir = files.outdir |
| include_config_data = generate_fvm |
| create_package = defined(invoker.create_legacy_aib_package) && |
| invoker.create_legacy_aib_package |
| create_package_archive = defined(invoker.create_legacy_aib_archive) && |
| invoker.create_legacy_aib_archive |
| } |
| |
| # Run product assembly. |
| ffx_action(labels.product_assembler) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| |
| # TODO(fxbug.dev/77290) - Add depfile support and then remove the following |
| hermetic_deps = false |
| |
| args = [ |
| "--config", |
| "assembly_enabled=true", |
| "assembly", |
| "product", |
| "--product", |
| rebase_path(files.product_assembly_config, root_build_dir), |
| "--input-bundles-dir", |
| rebase_path(files.platform_aib_dir, root_build_dir), |
| "--legacy-bundle-dir", |
| rebase_path(files.outdir, root_build_dir), |
| "--outdir", |
| rebase_path(files.outdir, root_build_dir), |
| ] |
| |
| deps = [ |
| ":${labels.legacy_assembly_input_bundle}", |
| labels.platform_aib, |
| ] + labels.product_assembly_config_deps |
| |
| inputs = [ |
| files.emulator_aib_manifest, |
| files.legacy_assembly_input_bundle_manifest, |
| files.product_assembly_config, |
| ] |
| |
| outputs = [ files.regenerated_image_assembly_config ] |
| |
| # If there isn't an FVM, there won't be a config-data package, and so it |
| # won't be created by product assembly (it won't have any config data in |
| # the legacy or common configs.) |
| if (generate_fvm) { |
| outputs += [ files.config_data_manifest ] |
| } |
| } |
| |
| # Validate that the generated image assembly configuration matches the |
| # legacy + the product assembly configuration. |
| compare_image_assembly_configs(labels.compare_image_assembly_configs) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| deps = [ |
| ":${labels.image_assembly_config}", |
| ":${labels.product_assembler}", |
| ] + labels.product_assembly_config_deps |
| legacy_image_assembly_config = files.image_assembly_config |
| generated_image_assembly_config = files.regenerated_image_assembly_config |
| product_assembly_config = files.product_assembly_config |
| } |
| |
| hermetic_inputs_for_image_assembly(labels.image_assembly_inputs) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| deps = [ |
| ":${labels.images_config}", |
| ":${labels.product_assembler}", |
| ] |
| |
| image_assembly_config = files.regenerated_image_assembly_config |
| images_config = files.images_config |
| output = files.image_assembly_inputs |
| } |
| |
| ffx_action(labels.image_assembler) { |
| no_output_dir_leaks = false |
| |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| metadata = { |
| # We insert these barriers to prevent the dependencies of these images |
| # from leaking into images "higher up" in the dependency chain. |
| package_barrier = [] |
| config_package_barrier = [] |
| distribution_entries_barrier = [] |
| |
| if (defined(invoker.metadata)) { |
| forward_variables_from(invoker.metadata, "*") |
| } |
| |
| if (generate_fvm) { |
| package_output_manifests = [ files.base_package_manifest ] |
| } |
| } |
| |
| hermetic_inputs_target = ":${labels.image_assembly_inputs}" |
| hermetic_inputs_file = files.image_assembly_inputs |
| |
| args = [ |
| "--config", |
| "assembly_enabled=true", |
| "assembly", |
| "create-system", |
| "--image-assembly-config", |
| rebase_path(files.regenerated_image_assembly_config, root_build_dir), |
| "--images", |
| rebase_path(files.images_config, root_build_dir), |
| "--base-package-name", |
| "$base_package_name", |
| "--gendir", |
| rebase_path(files.gendir, root_build_dir), |
| "--outdir", |
| rebase_path(files.outdir, root_build_dir), |
| ] |
| |
| if (embed_fvm_in_zbi) { |
| args += [ |
| "--mode", |
| "fvm-in-zbi", |
| ] |
| } else if (!generate_fvm) { |
| args += [ |
| "--mode", |
| "bootfs", |
| ] |
| } |
| |
| deps = [] |
| if (defined(invoker.deps)) { |
| deps += invoker.deps |
| } |
| deps += [ |
| ":${labels.images_config}", |
| ":${labels.product_assembler}", |
| ] |
| |
| # Set the deps needed in order to run the zbi_signing_script |
| if (defined(invoker.zbi_signing_script_deps)) { |
| deps += invoker.zbi_signing_script_deps |
| } |
| |
| inputs = [ |
| files.images_config, |
| files.regenerated_image_assembly_config, |
| ] |
| if (defined(invoker.inputs)) { |
| inputs += invoker.inputs |
| } |
| |
| outputs = [ |
| files.bootfs_files, |
| files.devmgr_config, |
| files.zbi, |
| files.zbi_manifest, |
| files.packages, |
| files.bootfs_packages, |
| files.image_command_log, |
| files.images_manifest, |
| ] |
| |
| if (defined(invoker.zbi_signing_script)) { |
| outputs += [ files.zbi_signed ] |
| } |
| |
| if (use_vbmeta) { |
| outputs += [ files.vbmeta ] |
| } |
| |
| # Base package dependencies and outputs, if this configuration uses them. |
| if (generate_fvm) { |
| deps += [ |
| blobfs_tool_target, |
| fvm_tool_target, |
| ] |
| |
| inputs += [ |
| blobfs_tool_path, |
| fvm_tool_path, |
| ] |
| |
| outputs += [ |
| # In the outdir. |
| files.base_package, |
| files.base_package_manifest, |
| files.base_package_merkle, |
| files.minfs, |
| files.blobfs, |
| files.fvm, |
| files.fvm_sparse, |
| files.fvm_blob_sparse, |
| |
| # In the gendir. |
| files.blobfs_manifest, |
| files.blobs_json, |
| files.static_packages, |
| files.cache_packages, |
| files.base_meta_package, |
| files.base_pkg_abi_revision, |
| ] |
| |
| if (fvm_emmc_partition_size != false || |
| fvm_ftl_nand_block_count != false) { |
| outputs += [ files.fvm_fastboot ] |
| if (fvm_ftl_nand_block_count != false) { |
| outputs += [ files.fvm_fastboot_tmp ] |
| } |
| } |
| } |
| |
| if (check_production_tag) { |
| assert_no_deps = [ "//build/validate:non_production_tag" ] |
| } |
| } |
| |
| ####### |
| # Optionally, copy the resulting ZBI to the specified directory. |
| # |
| |
| if (defined(invoker.output_dir)) { |
| assert( |
| invoker.output_dir != target_out_dir, |
| "The specified output directory must be different from the default target_out_dir") |
| |
| # The output name is the same as the original file by default. |
| # Otherwise, it takes the output_name, and strips any extension. |
| output_name = "${image_name}" |
| if (defined(invoker.output_name)) { |
| parts = string_split(invoker.output_name, ".") |
| output_name = parts[0] |
| } |
| |
| copy(labels.copy_zbi) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| sources = [ files.zbi ] |
| outputs = [ "${invoker.output_dir}/${output_name}.zbi" ] |
| deps = [ ":${labels.image_assembler}" ] |
| } |
| |
| copy(labels.copy_zbi_manifest) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| sources = [ files.zbi_manifest ] |
| outputs = [ "${invoker.output_dir}/${output_name}.zbi.json" ] |
| deps = [ ":${labels.image_assembler}" ] |
| } |
| |
| if (defined(invoker.zbi_signing_script)) { |
| copy(labels.copy_zbi_signed) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| sources = [ files.zbi_signed ] |
| outputs = [ "${invoker.output_dir}/${output_name}.zbi.signed" ] |
| deps = [ ":${labels.image_assembler}" ] |
| } |
| } |
| |
| if (use_vbmeta) { |
| copy(labels.copy_vbmeta) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| sources = [ files.vbmeta ] |
| outputs = [ "${invoker.output_dir}/${output_name}.vbmeta" ] |
| deps = [ ":${labels.image_assembler}" ] |
| } |
| } |
| |
| group(labels.copy_images) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| public_deps = [ |
| ":${labels.copy_zbi_manifest}", |
| ":${labels.copy_zbi}", |
| ] |
| if (defined(invoker.zbi_signing_script)) { |
| public_deps += [ ":${labels.copy_zbi_signed}" ] |
| } |
| if (use_vbmeta) { |
| public_deps += [ ":${labels.copy_vbmeta}" ] |
| } |
| } |
| } |
| |
| ####### |
| # Check the golden files. |
| # |
| # TODO(fxbug.dev/101283): These checks are no longer a part of |
| # `assembled_system()`. Remove `not_needed(...)` once all build configurations |
| # no longer specify scrutiny verifier configuration. |
| |
| not_needed(invoker, |
| [ |
| "cmdline_goldens", |
| "bootfs_goldens", |
| "static_pkgs_goldens", |
| "route_sources_config", |
| ]) |
| |
| group(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| |
| # public_deps is used, so that the outputs of these dependencies are |
| # available to external targets. |
| public_deps = [ |
| ":${labels.compare_image_assembly_configs}", |
| ":${labels.image_assembler}", |
| ":${labels.image_assembly_config}", |
| ":${labels.images_config}", |
| ] |
| if (defined(invoker.output_dir)) { |
| public_deps += [ ":${labels.copy_images}" ] |
| } |
| |
| metadata = { |
| # Assemblies have some defined packages, such as the base package. |
| # This barrier prevents a Assembly#1 from including a depending Assembly#2 |
| # packages in the package sets (base, cache, system) for Assembly#1. |
| assembly_package_barrier = [] |
| |
| assembly_inputs_barrier = [] |
| } |
| } |
| } |