blob: f4b037582cce5aa6ff464f534a1b4a17e2da192a [file] [log] [blame]
# 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")
# 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",
"//src/storage/lib/fs_management/client.shard.cml",
]
options = invoker.options
if (!defined(options.bootfs_only) || !options.bootfs_only) {
if (defined(options.use_disk_migration) && options.use_disk_migration) {
sources += [
"//src/storage/fshost/meta/blobfs_fshost_test.cml",
"//src/storage/fshost/meta/f2fs_fshost_test.cml",
"//src/storage/fshost/meta/fxfs_fshost_test.cml",
"//src/storage/fshost/meta/minfs_fshost_test.cml",
]
} else if (options.data_filesystem_format == "minfs") {
if (defined(options.storage_host) && options.storage_host) {
if (invoker.testonly) {
sources +=
[ "//src/storage/fshost/meta/storage_host_minfs_test.cml" ]
} else {
sources += [ "//src/storage/fshost/meta/storage_host_minfs.cml" ]
}
} else {
sources += [
"//src/storage/fshost/meta/blobfs_fshost_test.cml",
"//src/storage/fshost/meta/minfs_fshost_test.cml",
"//src/storage/fshost/meta/non_fxfs_fshost.cml",
]
}
} else if (options.data_filesystem_format == "fxfs") {
if (defined(options.fxfs_blob) && !options.fxfs_blob) {
sources += [
"//src/storage/fshost/meta/blobfs_fshost_test.cml",
"//src/storage/fshost/meta/fxfs_fshost_test.cml",
]
} else if (defined(options.storage_host) && options.storage_host) {
sources += [ "//src/storage/fshost/meta/fxfs_gpt_fshost_test.cml" ]
} else {
sources += [ "//src/storage/fshost/meta/fxfs_blob_fshost_test.cml" ]
}
} else if (options.data_filesystem_format == "f2fs") {
sources += [
"//src/storage/fshost/meta/blobfs_fshost_test.cml",
"//src/storage/fshost/meta/f2fs_fshost_test.cml",
"//src/storage/fshost/meta/non_fxfs_fshost.cml",
]
}
sources += [ "//src/storage/fshost/meta/core_fshost.cml" ]
if (defined(options.use_disk_migration) && options.use_disk_migration) {
sources += [ "//src/storage/fshost/meta/minfs_fshost_test.cml" ]
}
# These are components that must be included in the package depending on the data filesystem
# format and other configuration knobs.
# TODO(https://fxbug.dev/42064086): 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/blobfs/bin:component",
"//src/storage/memfs:memfs_component",
# For now, we always need minfs to support migration
"//src/storage/minfs/bin: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/f2fs/bin:f2fs-component" ]
}
if (defined(options.storage_host) && options.storage_host) {
deps += [ "//src/storage/storage-host" ]
}
}
}
}
# 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:
#
# 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" ])
}
}
# The component
fuchsia_component(_component_target) {
forward_variables_from(invoker, [ "testonly" ])
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/storage/fshost/testing:test_zxcrypt_config" ]
}
}
}