| # Copyright 2022 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("//src/storage/fshost/generated_fshost_config.gni") | |
| import("//tools/cmc/build/cmc.gni") | |
| declare_args() { | |
| # If true, use the Rust version of fshost. | |
| rust_fshost = false | |
| } | |
| # Generates an fshost cml file. | |
| # | |
| # Parameters | |
| # | |
| # options - a scope that can contain any fshost config option (see meta/config.cml). | |
| # data_filesystem_format is mandatory. The following options are also supported: | |
| # | |
| # bootfs_only - if set, the blob and data partitions will not get mounted. | |
| # | |
| # testonly - the component will only be used for testing | |
| template("fshost_cml") { | |
| cmc_merge(target_name) { | |
| forward_variables_from(invoker, | |
| [ | |
| "output_name", | |
| "visibility", | |
| "testonly", | |
| ]) | |
| sources = [ | |
| "//src/storage/fshost/meta/base_fshost.cml", | |
| "//src/storage/fshost/meta/config.cml", | |
| ] | |
| options = invoker.options | |
| if (!defined(options.bootfs_only) || !options.bootfs_only) { | |
| if (options.data_filesystem_format == "minfs") { | |
| sources += [ "//src/storage/fshost/meta/minfs_fshost.cml" ] | |
| } else if (options.data_filesystem_format == "fxfs") { | |
| sources += [ "//src/storage/fshost/meta/fxfs_fshost.cml" ] | |
| } else if (options.data_filesystem_format == "f2fs") { | |
| sources += [ "//src/storage/fshost/meta/f2fs_fshost.cml" ] | |
| } | |
| sources += [ "//src/storage/fshost/meta/core_fshost.cml" ] | |
| if (defined(options.use_disk_based_minfs_migration) && | |
| options.use_disk_based_minfs_migration) { | |
| sources += [ "//src/storage/fshost/meta/minfs_fshost.cml" ] | |
| } | |
| # These are components that must be included in the package depending on the data filesystem | |
| # format. | |
| # TODO(fxbug.dev/112753): Remove these dep when adding fshost to the common platform AIB, | |
| # and add these component to the AIB at the same time. | |
| deps = [ | |
| "//src/storage/bin/blobfs:component", | |
| "//src/storage/memfs:memfs_component", | |
| # For now, we always need minfs to support migration | |
| "//src/storage/bin/minfs:minfs-component", | |
| ] | |
| if (options.data_filesystem_format == "fxfs") { | |
| deps += [ | |
| "//src/storage/fxfs:fxfs_component", | |
| "//src/storage/fxfs-crypt", | |
| ] | |
| } else if (options.data_filesystem_format == "f2fs") { | |
| deps += [ "//src/storage/bin/f2fs:f2fs-component" ] | |
| } | |
| } | |
| } | |
| } | |
| # Generates an fshost component and matching config. | |
| # | |
| # Parameters: | |
| # | |
| # options - same as for `fshost_cml` above, see that template's documentation | |
| # for details. The following options are also supported: | |
| # | |
| # use_rust_port - if set, use the rust port of fshost instead of the cpp version. | |
| # | |
| # component_name (optional; default: target_name) | |
| # [string] The name to use for the fshost component (changes the name of the | |
| # component manifest that's created). | |
| # | |
| # output_name (optional; used to enable transition to other template changes) | |
| # | |
| # This will produces the following targets: | |
| # | |
| # <target-name>.cml : the cml file | |
| # <target-name>.manifest : the manifest (compiled cml file) | |
| # <target-name>.config : the config | |
| # <target-name>.comp : the component | |
| # <target-name> : a group encompassing the component and the config | |
| # | |
| template("fshost_component_and_config") { | |
| _cml_target = "$target_name.cml" | |
| _manifest_target = "$target_name.manifest" | |
| _config_target = "$target_name.config" | |
| _component_target = "$target_name.comp" | |
| # This is used by any of the templates below that use `invoker.component_name` | |
| # or `forward_variables_from(invoker, [ "component_name" ...`. | |
| component_name = target_name | |
| if (defined(invoker.component_name)) { | |
| component_name = invoker.component_name | |
| } | |
| # The CML file | |
| fshost_cml(_cml_target) { | |
| forward_variables_from(invoker, | |
| [ | |
| "options", | |
| "output_name", | |
| "testonly", | |
| ]) | |
| visibility = [ ":*" ] | |
| } | |
| # The manifest (compiled CML) | |
| fuchsia_component_manifest(_manifest_target) { | |
| forward_variables_from(invoker, [ "testonly" ]) | |
| _target_outputs = get_target_outputs(":$_cml_target") | |
| manifest = _target_outputs[0] | |
| deps = [ ":$_cml_target" ] | |
| visibility = [ ":*" ] | |
| } | |
| # The config | |
| generated_fshost_config(_config_target) { | |
| options = { | |
| forward_variables_from(invoker.options, | |
| "*", | |
| [ | |
| "bootfs_only", | |
| "use_rust_port", | |
| ]) | |
| } | |
| } | |
| # The component | |
| fuchsia_component(_component_target) { | |
| forward_variables_from(invoker, [ "testonly" ]) | |
| forward_variables_from(invoker.options, [ "use_rust_port" ]) | |
| deps = [] | |
| if (defined(use_rust_port) && use_rust_port) { | |
| deps += [ "//src/storage/fshost-rust" ] | |
| } else { | |
| deps += [ "//src/storage/fshost" ] | |
| } | |
| cm_label = ":$_manifest_target" | |
| } | |
| group(target_name) { | |
| forward_variables_from(invoker, [ "testonly" ]) | |
| deps = [ | |
| ":$_component_target", | |
| ":$_config_target", | |
| ] | |
| # If testonly, use a null key source. This will affect all components | |
| # in the same package. | |
| if (invoker.testonly) { | |
| deps += [ "//src/security/policy/zxcrypt:null" ] | |
| } | |
| } | |
| } | |
| default_integration_test_options = { | |
| # Some of the tests require us to be able to match against multiple GPT devices. | |
| gpt_all = true | |
| # The test BlockDeviceManagerIntegration.MaxSize verifies that the minfs "max runtime bytes" gets | |
| # applied correctly. It checks that the max size in FVM is set to this value. The | |
| # "apply_limits_to_ramdisk" flag is required to apply the minfs limit even to a ramdisk which is | |
| # used in tests (normally the limits apply only to physical devices). This number applies to all | |
| # tests in the fshost integration test, so all minfs partitions created must be smaller than this | |
| # value, but all disks should be larger than this value. | |
| data_max_bytes = 117440512 | |
| apply_limits_to_ramdisk = true | |
| check_filesystems = true | |
| # The BlockDeviceManagerIntegration.SetPartitionName test needs this. | |
| allow_legacy_data_partition_names = true | |
| use_native_fxfs_crypto = true | |
| blobfs_use_deprecated_padded_format = false | |
| } |