| # 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/dist/component_manifest_resources.gni") |
| import("//build/test.gni") |
| import("//src/lib/isolated_devmgr/v2_component/isolated_devmgr.gni") |
| import("//src/sys/build/components.gni") |
| |
| declare_args() { |
| # blobfs_maximum_runtime_bytes is an upper bound on the partition size on the device. Partitions |
| # can grow as needed if there are extra slices available in FVM. This limit prevents the blobfs |
| # partition from taking too much space away from other uses. |
| # |
| # Pass the empty string for no limit. |
| blobfs_maximum_runtime_bytes = "" |
| |
| # minfs_maximum_runtime_bytes is an upper bound on the partition size on the device. Partitions |
| # can grow as needed if there are extra slices available in FVM. This limit prevents the minfs |
| # partition from taking too much space away from other uses. |
| # |
| # Pass the empty string for no limit. |
| minfs_maximum_runtime_bytes = "" |
| |
| # If format_minfs_on_corruption is true (the default), fshost formats minfs partition on finding |
| # it corrupted. Set to false to keep the devices in a corrupted state which might be of help to |
| # debug issues. |
| format_minfs_on_corruption = true |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fshost-tests", |
| "//src/lib/isolated_devmgr/v2_component", |
| ] |
| } |
| |
| source_set("launcher") { |
| visibility = [ ":*" ] |
| sources = [ "fdio.cc" ] |
| deps = [ |
| "//sdk/lib/fdio", |
| "//sdk/lib/syslog/cpp", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/fidl", |
| "//zircon/public/lib/zircon-internal", |
| "//zircon/public/lib/zx", |
| ] |
| } |
| |
| source_set("fshost-registry") { |
| configs += [ "//build/unification/config:zircon-migrated" ] |
| sources = [ |
| "admin-server.cc", |
| "deprecated-loader-service.cc", |
| "fs-manager.cc", |
| "fshost-boot-args.cc", |
| "lifecycle.cc", |
| "registry.cc", |
| "registry_vnode.cc", |
| ] |
| public_deps = [ |
| ":inspect", |
| ":launcher", |
| ":metrics", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_llcpp", |
| "//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_llcpp", |
| "//sdk/lib/vfs/cpp", |
| "//src/lib/loader_service", |
| "//zircon/public/lib/fit", |
| "//zircon/public/lib/zircon-internal", |
| "//zircon/public/lib/zx", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-default", |
| "//zircon/system/ulib/fs", |
| "//zircon/system/ulib/fs-management", |
| "//zircon/system/ulib/memfs", |
| ] |
| deps = [ |
| "//sdk/lib/fdio", |
| "//src/lib/files", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/zircon-internal", |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", |
| "//zircon/system/ulib/memfs:memfs-cpp", |
| ] |
| } |
| |
| source_set("inspect") { |
| configs += [ "//build/unification/config:zircon-migrated" ] |
| sources = [ |
| "inspect-manager.cc", |
| "inspect-manager.h", |
| ] |
| public_deps = [ |
| "//sdk/lib/fdio", |
| "//sdk/lib/sys/inspect/cpp", |
| "//src/lib/fsl", |
| "//zircon/public/lib/fbl", |
| "//zircon/system/ulib/fs", |
| "//zircon/system/ulib/memfs", |
| ] |
| } |
| |
| source_set("metrics") { |
| sources = [ |
| "metrics.cc", |
| "metrics.h", |
| ] |
| public_deps = [ |
| "//zircon/public/lib/async-cpp", |
| "//zircon/system/ulib/cobalt-client", |
| "//zircon/system/ulib/fs/metrics:metrics-cobalt", |
| ] |
| deps = [ |
| "//sdk/lib/syslog/cpp", |
| "//zircon/system/ulib/cobalt-client", |
| "//zircon/system/ulib/fs/metrics:metrics-cobalt", |
| "//zircon/system/ulib/fs/metrics:metrics-inspect", |
| ] |
| } |
| |
| source_set("block-watcher") { |
| configs += [ |
| "//build/unification/config:zircon-migrated", |
| "//build/config:all_source", |
| ] |
| sources = [ |
| "block-device-manager.cc", |
| "block-device.cc", |
| "block-watcher.cc", |
| "encrypted-volume.cc", |
| "filesystem-mounter.cc", |
| "fshost-fs-provider.cc", |
| "pkgfs-launcher.cc", |
| "pkgfs-loader-service.cc", |
| ] |
| public_deps = [ |
| ":fshost-registry", |
| ":launcher", |
| ":metrics", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_llcpp", |
| "//src/storage/blobfs", |
| "//zircon/public/lib/fit", |
| "//zircon/public/lib/zircon-internal", |
| "//zircon/public/lib/zx", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-default", |
| "//zircon/system/ulib/fdio-caller", |
| "//zircon/system/ulib/fs", |
| "//zircon/system/ulib/memfs", |
| ] |
| deps = [ |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_c", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_c", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block:fuchsia.hardware.block_c", |
| "//sdk/fidl/fuchsia.hardware.block.encrypted:fuchsia.hardware.block.encrypted_c", |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_c", |
| "//sdk/fidl/fuchsia.hardware.block.verified:fuchsia.hardware.block.verified_llcpp", |
| "//sdk/lib/fdio", |
| "//src/devices/block/drivers/block-verity:verified-volume-client", |
| "//src/lib/loader_service", |
| "//src/security/zxcrypt:zxcrypt-fdio", |
| "//src/storage/minfs", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/fidl", |
| "//zircon/public/lib/fit", |
| "//zircon/public/lib/zircon-internal", |
| "//zircon/public/lib/zx", |
| "//zircon/system/ulib/digest", |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", |
| "//zircon/system/ulib/fs", |
| "//zircon/system/ulib/fs-management", |
| "//zircon/system/ulib/gpt", |
| "//zircon/system/ulib/ramdevice-client", |
| "//zircon/system/ulib/trace", |
| "//zircon/system/ulib/trace-engine", |
| ] |
| } |
| |
| executable("fshost") { |
| if (is_fuchsia) { |
| configs += [ |
| "//build/unification/config:zircon-migrated", |
| "//build/config:all_source", |
| ] |
| } |
| if (is_fuchsia) { |
| fdio_config = [ "//build/config/fuchsia:fdio_config" ] |
| if (configs + fdio_config - fdio_config != configs) { |
| configs -= fdio_config |
| } |
| } |
| sources = [ "main.cc" ] |
| deps = [ |
| ":block-watcher", |
| ":fshost-registry", |
| ":metrics", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_c", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_c", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_llcpp", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_llcpp", |
| "//sdk/fidl/fuchsia.ldsvc:fuchsia.ldsvc_c", |
| "//zircon/system/ulib/cobalt-client", |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", |
| "//zircon/system/ulib/fs-management", |
| "//zircon/system/ulib/ramdevice-client", |
| "//zircon/system/ulib/zbi-bootfs", |
| ] |
| } |
| |
| test("fshost_test") { |
| sources = [ |
| "delayed-outdir-test.cc", |
| "fshost-boot-args-test.cc", |
| "fshost-test.cc", |
| ] |
| deps = [ |
| ":block-watcher", |
| ":fshost-registry", |
| ":metrics", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_c", |
| "//zircon/public/lib/zxtest", |
| "//zircon/system/ulib/cobalt-client", |
| "//zircon/system/ulib/cobalt-client:in-memory-logger", |
| "//zircon/system/ulib/fidl-async", |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", |
| "//zircon/system/ulib/mock-boot-arguments", |
| ] |
| } |
| |
| # Include this target from a product config if you want to allow authoring |
| # factory partition contents in mutable mode and prevent opening block-verity |
| # volumes in verified read mode. |
| generated_resource("allow-authoring-factory") { |
| outputs = [ "config/allow-authoring-factory" ] |
| contents = "yes" |
| |
| # We should never allow authoring factory from a production, user-facing build. |
| deps = [ "//build/validate:non_production_tag" ] |
| } |
| |
| fuchsia_unittest_component("fshost-test") { |
| executable_path = "test/fshost_test" |
| deps = [ ":fshost_test" ] |
| } |
| |
| # This is a separate test executable because loader_service_test_fixture uses gtest, but other |
| # tests here use zxtest. |
| test("fshost_loader_service_test") { |
| sources = [ |
| "deprecated-loader-service-test.cc", |
| "pkgfs-loader-service-test.cc", |
| ] |
| deps = [ |
| ":block-watcher", |
| ":fshost-registry", |
| "//src/lib/loader_service:loader_service_test_fixture", |
| "//zircon/system/ulib/mock-boot-arguments", |
| ] |
| } |
| |
| fuchsia_unittest_component("fshost-loader-service-test") { |
| manifest = "meta/fshost-loader-service-test.cmx" |
| deps = [ ":fshost_loader_service_test" ] |
| } |
| |
| test("fshost_inspect_test") { |
| sources = [ "inspect-manager-test.cc" ] |
| deps = [ |
| ":inspect", |
| "//zircon/public/lib/async", |
| "//zircon/public/lib/zxtest", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-default", |
| "//zircon/system/ulib/inspect", |
| ] |
| } |
| |
| fuchsia_unittest_component("fshost-inspect-test") { |
| executable_path = "test/fshost_inspect_test" |
| deps = [ ":fshost_inspect_test" ] |
| } |
| |
| test("fshost_metrics_test") { |
| sources = [ "metrics-test.cc" ] |
| deps = [ |
| ":metrics", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/lib/fdio", |
| "//zircon/public/lib/zxtest", |
| "//zircon/system/ulib/async-testing", |
| "//zircon/system/ulib/cobalt-client:in-memory-logger", |
| "//zircon/system/ulib/fs/metrics:metrics-cobalt", |
| "//zircon/system/ulib/fs/metrics:metrics-inspect", |
| ] |
| } |
| |
| fuchsia_unittest_component("fshost-metrics-test") { |
| executable_path = "test/fshost_metrics_test" |
| deps = [ ":fshost_metrics_test" ] |
| } |
| |
| test("block_watcher_test") { |
| sources = [ |
| "block-device-manager-test.cc", |
| "block-device-test.cc", |
| "block-watcher-test.cc", |
| "filesystem-mounter-test.cc", |
| "mock-block-device.h", |
| ] |
| deps = [ |
| ":block-watcher", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_llcpp", |
| "//sdk/fidl/fuchsia.sys2", |
| "//src/lib/files", |
| "//src/lib/fxl/test:gtest_main", |
| "//src/lib/isolated_devmgr/v2_component:client", |
| "//src/storage/blobfs", |
| "//src/storage/minfs", |
| "//zircon/system/ulib/cobalt-client:in-memory-logger", |
| "//zircon/system/ulib/fidl-async", |
| "//zircon/system/ulib/fs-management", |
| "//zircon/system/ulib/fs/metrics:metrics-cobalt", |
| "//zircon/system/ulib/ramdevice-client", |
| ] |
| } |
| |
| generated_file("block_watcher_test_config") { |
| contents = [ |
| "default", |
| |
| # Some of the tests requires us to be able to match against multiple GPT devices. |
| "gpt-all", |
| ] |
| output_conversion = "list lines" |
| outputs = [ "$target_gen_dir/block_watcher_test_config" ] |
| } |
| |
| resource("block_watcher_test_config_resource") { |
| sources = [ "$target_gen_dir/block_watcher_test_config" ] |
| outputs = [ "config/fshost" ] |
| } |
| |
| # This is a test version of fshost, not a component with fshost tests. |
| fuchsia_component("test-fshost") { |
| testonly = true |
| manifest = "meta/fshost.cml" |
| deps = [ ":fshost" ] |
| } |
| |
| isolated_devmgr_unittest_v2_component("block-watcher-test") { |
| manifest = "meta/block_watcher_test.cml" |
| deps = [ |
| ":block_watcher_test", |
| ":block_watcher_test_config_resource", |
| "//src/devices/block/drivers/core", |
| "//src/devices/block/drivers/gpt", |
| "//src/devices/block/drivers/ramdisk", |
| "//src/devices/bus/drivers/platform", |
| "//src/devices/tests/sysdev", |
| ] |
| } |
| |
| fuchsia_test_package("fshost-tests") { |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| } |
| test_components = [ |
| ":block-watcher-test", |
| ":fshost-test", |
| ":fshost-inspect-test", |
| ":fshost-metrics-test", |
| ":fshost-loader-service-test", |
| ] |
| deps = [ ":test-fshost" ] |
| } |
| |
| component_manifest_resources("meta") { |
| sources = [ "meta/fshost.cml" ] |
| } |
| |
| group("bootfs") { |
| deps = [ |
| ":fshost", |
| ":meta", |
| ] |
| } |
| |
| # Generates an fshost config file that will appear in config/fshost. If no configuration file is |
| # present (i.e. there's no dependency on a target below), a default config is used (see |
| # block-device-manager.cc). |
| template("fshost_config") { |
| generated_resource(target_name) { |
| contents = [ "default" ] |
| deps = [] |
| if (defined(invoker.no_minfs_zxcrypt) && invoker.no_minfs_zxcrypt) { |
| contents += [ "no-zxcrypt" ] |
| deps += [ "//build/validate:non_production_tag" ] |
| } |
| if (defined(invoker.minfs_ramdisk) && invoker.minfs_ramdisk) { |
| contents += [ |
| "fvm-ramdisk", |
| "zxcrypt-non-ramdisk", |
| ] |
| } |
| if (defined(invoker.gpt_all) && invoker.gpt_all) { |
| contents += [ "gpt-all" ] |
| deps += [ "//build/validate:non_production_tag" ] |
| } |
| if (blobfs_maximum_runtime_bytes != "") { |
| contents += [ "blobfs-max-bytes=$blobfs_maximum_runtime_bytes" ] |
| } |
| if (minfs_maximum_runtime_bytes != "") { |
| contents += [ "minfs-max-bytes=$minfs_maximum_runtime_bytes" ] |
| } |
| if (!format_minfs_on_corruption) { |
| contents += [ "-format-minfs-on-corruption" ] |
| } |
| output_conversion = "list lines" |
| outputs = [ "config/fshost" ] |
| } |
| } |
| |
| fshost_config("minfs_ramdisk") { |
| minfs_ramdisk = true |
| } |
| |
| fshost_config("no_minfs_zxcrypt") { |
| no_minfs_zxcrypt = true |
| } |
| |
| # A configuration that allows access to multiple devices with GUID partition schemes; the default |
| # will only attach a driver to the first device that appears to have a GUID partition scheme. |
| fshost_config("gpt_all") { |
| gpt_all = true |
| } |
| |
| # Writes default configuration plus any changes to global variables. |
| fshost_config("default_config") { |
| minfs_ramdisk = false |
| gpt_all = false |
| no_minfs_zxcrypt = false |
| } |