| # 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/fuchsia/zbi.gni") |
| import("//build/config/fuchsia/zircon.gni") |
| import("//build/images/manifest.gni") |
| import("//build/package.gni") |
| import("//garnet/build/pkgfs.gni") |
| |
| guest_packages = [ |
| get_label_info("//build/images:shell-commands", "label_no_toolchain"), |
| get_label_info("//garnet/bin/appmgr", "label_no_toolchain"), |
| get_label_info("//garnet/bin/guest/integration:guest_integration_tests_utils", |
| "label_no_toolchain"), |
| get_label_info("//garnet/bin/guest/pkg/zircon_guest:services_config", |
| "label_no_toolchain"), |
| get_label_info("//garnet/bin/run", "label_no_toolchain"), |
| get_label_info("//garnet/bin/sysmgr", "label_no_toolchain"), |
| get_label_info("//garnet/bin/trace", "label_no_toolchain"), |
| get_label_info("//garnet/bin/vsock_service:vsock_service", |
| "label_no_toolchain"), |
| get_label_info(pkgfs_package_label, "label_no_toolchain"), |
| ] |
| |
| # The pkgsvr index is a manifest mapping `package_name/package_version` to |
| # the merkleroot of the package's meta.far file. |
| action("pkgsvr_index") { |
| visibility = [ ":*" ] |
| testonly = true |
| script = "//build/images/manifest.py" |
| args = [ "--contents" ] |
| outputs = [ |
| "$target_out_dir/$target_name", |
| ] |
| args += [ "--output=" + rebase_path(outputs[0], root_build_dir) ] |
| sources = [] |
| deps = [] |
| foreach(pkg_label, guest_packages) { |
| # 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) ] |
| } |
| } |
| |
| boot_manifest = "$target_out_dir/boot.manifest" |
| generate_manifest("guest.manifest") { |
| visibility = [ ":*" ] |
| testonly = true |
| |
| bootfs_manifest = boot_manifest |
| bootfs_zircon_groups = "misc,test" |
| |
| args = [] |
| deps = [] |
| sources = [] |
| foreach(pkg_label, guest_packages) { |
| # 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) ] |
| } |
| |
| json = "guest_meta_package.json" |
| sources += [ json ] |
| args += [ "--entry=meta/package=" + rebase_path(json, root_build_dir) ] |
| |
| # Add the static packages (pkgsvr) index. |
| deps += [ ":pkgsvr_index" ] |
| pkgsvr_index = "$target_out_dir/pkgsvr_index" |
| sources += [ pkgsvr_index ] |
| args += [ "--entry=data/static_packages=" + |
| rebase_path(pkgsvr_index, root_build_dir) ] |
| } |
| |
| # Generate, sign, and seal the package file. |
| pm_build_package("guest.meta") { |
| visibility = [ ":*" ] |
| testonly = true |
| manifest = ":guest.manifest" |
| } |
| |
| guest_blob_manifest = "$root_build_dir/guest_blob.manifest" |
| action("guest_blob.manifest") { |
| visibility = [ ":*" ] |
| testonly = true |
| deps = [ |
| ":guest.manifest", |
| ":guest.meta", |
| ] |
| outputs = [ |
| guest_blob_manifest, |
| ] |
| depfile = guest_blob_manifest + ".d" |
| guest_manifest_outputs = get_target_outputs(":guest.manifest") |
| guest_manifest = guest_manifest_outputs[0] |
| inputs = [ |
| guest_manifest, |
| ] |
| script = "//build/images/blob_manifest.py" |
| args = [ "@{{response_file_name}}" ] |
| response_file_contents = [ |
| "--depfile=" + rebase_path(depfile, root_build_dir), |
| "--output=" + rebase_path(guest_blob_manifest, root_build_dir), |
| "--input=" + |
| rebase_path("$target_out_dir/guest.meta/blobs.json", root_build_dir), |
| ] |
| foreach(pkg_label, guest_packages) { |
| pkg_target_name = get_label_info(pkg_label, "name") |
| pkg_target_out_dir = get_label_info(pkg_label, "target_out_dir") |
| pkg_blobs_rsp = "$pkg_target_out_dir/${pkg_target_name}.blobs.rsp" |
| deps += [ "${pkg_label}.blobs.rsp" ] |
| inputs += [ pkg_blobs_rsp ] |
| response_file_contents += |
| [ "@" + rebase_path(pkg_blobs_rsp, root_build_dir) ] |
| } |
| } |
| |
| zircon_tool_action("guest_blob.blk") { |
| visibility = [ ":*" ] |
| testonly = true |
| deps = [ |
| ":guest_blob.manifest", |
| ] |
| blob_image_path = "$target_out_dir/$target_name" |
| outputs = [ |
| blob_image_path, |
| ] |
| depfile = blob_image_path + ".d" |
| inputs = [ |
| guest_blob_manifest, |
| ] |
| tool = "blobfs" |
| args = [ |
| "--depfile", |
| rebase_path(blob_image_path, root_build_dir), |
| "create", |
| "--manifest", |
| rebase_path(guest_blob_manifest, root_build_dir), |
| ] |
| } |
| |
| zircon_tool_action("guest_fvm") { |
| testonly = true |
| fvm = "$root_out_dir/guest_fvm.blk" |
| outputs = [ |
| fvm, |
| ] |
| tool = "fvm" |
| sources = [] |
| deps = [ |
| ":guest_blob.blk", |
| ] |
| foreach(label, deps) { |
| sources += get_target_outputs(label) |
| } |
| args = [ |
| rebase_path(fvm, root_build_dir), |
| "create", |
| "--blob", |
| ] + rebase_path(sources, root_build_dir) |
| } |
| |
| # Generate the /boot/config/devmgr file. |
| action("devmgr_config.txt") { |
| visibility = [ ":*" ] |
| testonly = true |
| script = "//build/images/manifest.py" |
| outputs = [ |
| "$target_out_dir/$target_name", |
| ] |
| pkgfs = "bin/" + pkgfs_binary_name |
| pkgfs_label = pkgfs_package_label + ".meta" |
| pkgfs_pkg_out_dir = get_label_info(pkgfs_label, "target_out_dir") + "/" + |
| get_label_info(pkgfs_label, "name") |
| pkgfs_blob_manifest = "$pkgfs_pkg_out_dir/meta/contents" |
| system_image_merkleroot = "$target_out_dir/guest.meta/meta.far.merkle" |
| |
| deps = [ |
| ":guest.manifest", |
| ":guest.meta", |
| pkgfs_label, |
| ] |
| sources = [ |
| boot_manifest, |
| pkgfs_blob_manifest, |
| system_image_merkleroot, |
| ] |
| |
| args = [ |
| "--output=" + rebase_path(outputs[0], root_build_dir), |
| |
| # Start with the fixed options. |
| "--entry=devmgr.require-system=true", |
| |
| # Add the pkgfs command line, embedding the merkleroot of the system image. |
| "--contents", |
| "--rewrite=*=zircon.system.pkgfs.cmd={target}+{source}", |
| "--entry=${pkgfs}=" + rebase_path(system_image_merkleroot, root_build_dir), |
| "--no-contents", |
| "--reset-rewrite", |
| |
| # Embed the pkgfs blob manifest with the "zircon.system.pkgfs.file." |
| # prefix on target file names. |
| "--rewrite=*=zircon.system.pkgfs.file.{target}={source}", |
| "--manifest=" + rebase_path(pkgfs_blob_manifest, root_build_dir), |
| "--reset-rewrite", |
| "--include=bin/devhost", |
| "--rewrite=bin/devhost=devhost.asan.strict=false", |
| "--manifest=" + rebase_path(boot_manifest, root_build_dir), |
| ] |
| } |
| |
| zbi("guest") { |
| testonly = true |
| deps = [ |
| ":devmgr_config.txt", |
| ":guest.manifest", |
| ] |
| inputs = [ |
| "${zircon_build_dir}/zircon.zbi", |
| boot_manifest, |
| ] |
| manifest = [ |
| { |
| outputs = [ |
| "config/devmgr", |
| ] |
| sources = get_target_outputs(":devmgr_config.txt") |
| }, |
| ] |
| cmdline = [] |
| cmdline_inputs = [] |
| } |