| # 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/components.gni") |
| import("//build/config.gni") |
| import("//src/sys/core/build/core_shard.gni") |
| import("//src/virtualization/buildtools/linux_paths.gni") |
| import("//src/virtualization/buildtools/romfs_image.gni") |
| |
| declare_args() { |
| # If `true`, adds additional testonly content to extras.img, which will be |
| # built and mounted inside the container at /mnt/chromeos. |
| termina_extras_tests = true |
| |
| # If `true`, all block devices that would normally load as READ_WRITE will |
| # be loaded as VOLATILE_WRITE. This is useful when working on changes to |
| # the linux kernel as crashes and panics can sometimes corrupt the images. |
| termina_volatile_block = false |
| |
| # Point this to the location of external files to be included as extras |
| termina_user_extras = [] |
| |
| # Whether to use Fxfs for the stateful image |
| termina_fxfs_stateful_image = false |
| |
| # Default stateful image size (40GiB). |
| # |
| # If you change this value you will need to rebuild the guest partition using |
| # 'guest wipe termina' for the new size to take effect. |
| termina_stateful_partition_size_bytes = 42949672960 |
| |
| # If 'true', bundle the container image with the termina_guest_manager package |
| # and use that to initialize the linux container. |
| # |
| # If this is 'false', no container image will be bundled and instead the |
| # container will be downloaded by the target at runtime. This makes the build |
| # smaller but requires the target device to have a functional internet |
| # connection at runtime. |
| termina_hermetic_bootstrap = false |
| } |
| |
| fuchsia_component_manifest("manifest") { |
| component_name = "termina_guest_manager" |
| manifest = "meta/termina_guest_manager.cml" |
| } |
| |
| fuchsia_structured_config_values("default_config") { |
| cm_label = ":manifest" |
| values = { |
| if (termina_fxfs_stateful_image) { |
| stateful_partition_type = "block-file" |
| } else { |
| stateful_partition_type = "fvm" |
| } |
| |
| stateful_partition_size = termina_stateful_partition_size_bytes |
| additional_read_only_mounts = [] |
| start_container_runtime = true |
| |
| # Empty strings here will pull the container from the internet. |
| if (termina_hermetic_bootstrap) { |
| container_rootfs_path = "/mnt/shared/rootfs.tar.xz" |
| container_metadata_path = "/mnt/shared/lxd.tar.xz" |
| } else { |
| container_rootfs_path = "" |
| container_metadata_path = "" |
| } |
| } |
| } |
| |
| fuchsia_structured_config_cpp_elf_lib("termina_config") { |
| cm_label = ":manifest" |
| } |
| |
| extras_image = "$target_out_dir/linux/termina_extras.img" |
| resource("extras_img") { |
| sources = [ extras_image ] |
| outputs = [ "data/{{source_file_part}}" ] |
| deps = [ ":extras" ] |
| if (termina_extras_tests) { |
| testonly = true |
| } |
| } |
| |
| source_set("lib") { |
| sources = [ |
| "block_devices.cc", |
| "block_devices.h", |
| "crash_listener.h", |
| "guest.cc", |
| "guest.h", |
| "log_collector.cc", |
| "log_collector.h", |
| "ports.h", |
| "termina_guest_manager.cc", |
| "termina_guest_manager.h", |
| ] |
| |
| public_deps = [ |
| ":termina_config", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_hlcpp", |
| "//sdk/fidl/fuchsia.hardware.block.volume:fuchsia.hardware.block.volume_hlcpp", |
| "//sdk/fidl/fuchsia.ui.app:fuchsia.ui.app_hlcpp", |
| "//sdk/fidl/fuchsia.ui.scenic:fuchsia.ui.scenic_hlcpp", |
| "//sdk/fidl/fuchsia.virtualization:fuchsia.virtualization_hlcpp", |
| "//sdk/fidl/fuchsia.wayland:fuchsia.wayland_hlcpp", |
| "//sdk/lib/fit-promise", |
| "//sdk/lib/sys/cpp", |
| "//src/lib/fsl", |
| "//src/lib/fxl", |
| "//src/lib/storage/block_client/cpp", |
| "//src/lib/storage/vfs/cpp", |
| "//src/virtualization/bin/guest_manager:lib", |
| "//src/virtualization/lib/grpc", |
| "//src/virtualization/lib/guest_config", |
| "//src/virtualization/third_party/vm_tools:vm_cc_proto", |
| "//third_party/grpc:grpc++", |
| "//third_party/protobuf:protobuf_lite", |
| "//zircon/system/ulib/async:async-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-default", |
| "//zircon/system/ulib/fdio-caller", |
| "//zircon/system/ulib/fzl", |
| "//zircon/system/ulib/trace-provider", |
| "//zircon/system/ulib/zx", |
| ] |
| |
| defines = [] |
| if (termina_volatile_block) { |
| defines += [ "USE_VOLATILE_BLOCK" ] |
| } |
| if (termina_fxfs_stateful_image) { |
| assert(!defined(data_filesystem_format) || data_filesystem_format == "fxfs", |
| "data_filesystem_format is set to something other than fxfs") |
| } |
| } |
| |
| romfs_image("extras") { |
| if (termina_extras_tests) { |
| testonly = true |
| |
| deps = [ |
| "//src/graphics/examples:vkcube-on-wayland(${linux_exe_toolchain})", |
| "//src/graphics/lib/compute/radix_sort/platforms/vk/tests(${linux_exe_toolchain})", |
| "//src/graphics/lib/compute/spinel/platforms/vk/tests/spinel_vk_bench:spinel-vk-bench(${linux_exe_toolchain})", |
| "//src/graphics/lib/compute/tools/bench/platforms/vk:bench-vk(${linux_exe_toolchain})", |
| "//src/graphics/lib/gbm:gbm_test(${linux_exe_toolchain})", |
| "//src/graphics/lib/magma/tests/integration:virtmagma_conformance_tests(${linux_exe_toolchain})", |
| "//src/graphics/lib/magma/tests_linux/unit_tests:virtmagma_image_tests(${linux_exe_toolchain})", |
| "//src/graphics/lib/magma/tests_linux/unit_tests:virtmagma_unit_tests(${linux_exe_toolchain})", |
| "//src/graphics/lib/magma/tests_linux/unit_tests:virtmagma_vulkan_unit_tests(${linux_exe_toolchain})", |
| "//src/lib/vulkan:vulkaninfo(${linux_exe_toolchain})", |
| ] |
| |
| inputs = [ |
| "${linux_exe_path}/virtmagma_vulkan_unit_tests", |
| "${linux_exe_path}/virtmagma_conformance_tests", |
| "${linux_exe_path}/cube-wayland", |
| "${linux_exe_path}/vulkaninfo", |
| "${linux_exe_path}/virtmagma_image_tests", |
| "${linux_exe_path}/virtmagma_unit_tests", |
| "${linux_exe_path}/radix-sort-vk-bench", |
| "${linux_exe_path}/spinel-vk-bench", |
| "${linux_exe_path}/bench-vk", |
| "${linux_exe_path}/gbm_test", |
| ] |
| |
| if (termina_hermetic_bootstrap) { |
| inputs += [ |
| "//prebuilt/virtualization/packages/termina_guest/container/${target_cpu}/lxd.tar.xz", |
| "//prebuilt/virtualization/packages/termina_guest/container/${target_cpu}/rootfs.tar.xz", |
| ] |
| } |
| |
| if (current_cpu == "x64") { |
| deps += [ "//src/graphics/tests/vkgbm(${linux_exe_toolchain})" ] |
| |
| inputs += [ "${linux_exe_path}/vkgbm" ] |
| } |
| |
| inputs += termina_user_extras |
| } |
| |
| output = extras_image |
| } |
| |
| executable("bin") { |
| output_name = "termina_guest_manager" |
| |
| sources = [ "main.cc" ] |
| deps = [ ":lib" ] |
| } |
| |
| fuchsia_component("termina_guest_manager_cmp") { |
| # TODO(https://fxbug.dev/122217): when |
| # fuchsia.component.test/Realm.InitMutableConfigFromPackage works with |
| # subpackaged components, uncomment. |
| # visibility = [ ":*" ] |
| cm_label = ":manifest" |
| if (termina_extras_tests) { |
| testonly = true |
| } |
| deps = [ |
| ":bin", |
| ":default_config", |
| ":extras_img", |
| "//src/virtualization/bin/vmm:vmm_component", |
| ] |
| } |
| |
| fuchsia_package("termina_guest_manager") { |
| if (termina_extras_tests) { |
| testonly = true |
| } |
| deps = [ ":termina_guest_manager_cmp" ] |
| subpackages = [ "//src/virtualization/packages/termina_guest" ] |
| } |
| |
| executable("termina_guest_manager_unittests") { |
| visibility = [ ":*" ] |
| testonly = true |
| |
| sources = [ |
| "block_devices_unittest.cc", |
| "termina_guest_manager_unittest.cc", |
| ] |
| |
| deps = [ |
| ":lib", |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_hlcpp", |
| "//sdk/lib/component/incoming/cpp", |
| "//sdk/lib/fdio", |
| "//sdk/lib/sys/cpp/testing:unit", |
| "//sdk/lib/virtualization/testing", |
| "//src/lib/files", |
| "//src/lib/fxl/test:gtest_main", |
| "//src/lib/testing/loop_fixture", |
| "//src/storage/memfs:cpp", |
| "//src/storage/testing:storage_driver_test_support", |
| ] |
| } |
| |
| fuchsia_unittest_package("termina_guest_manager_tests") { |
| deps = [ |
| ":termina_guest_manager_unittests", |
| |
| # Use the storage_driver_test_realm to provide access to a ramdisk driver for testing. |
| "//src/storage/testing:storage_driver_test_realm", |
| "//src/storage/testing:storage_test_includes", |
| ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":termina_guest_manager_tests" ] |
| } |