blob: 0f69dda04a257333d618a22a8e5c24a44a58d4fa [file] [log] [blame]
# 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/compiled_action.gni")
declare_args() {
# The size in bytes of the FVM partition image to create. Normally this is
# computed to be just large enough to fit the blob and data images. The
# default value is "", which means to size based on inputs. Specifying a size
# that is too small will result in build failure.
fvm_image_size = ""
# The max size of the disk where the FVM is written. This is used for
# preallocating metadata to determine how much the FVM can expand on disk.
# Only applies to sparse FVM images. At sparse image construction time, the
# build fails if the inputs are larger than `fvm_max_disk_size`. At paving
# time, the FVM will be sized to the target's disk size up to
# `fvm_max_disk_size`. If the size of the disk increases after initial paving,
# the FVM will resize up to `fvm_max_disk_size`. During paving, if the target
# FVM has declared a smaller size than `fvm_max_disk_size`, the FVM is
# reinitialized to the larger size.
# The default value is "" which sets the max disk size to the size of the disk
# at pave/format time.
fvm_max_disk_size = ""
# The size of the FVM partition images "slice size". The FVM slice size is a
# minimum size of a particular chunk of a partition that is stored within
# FVM. A very small slice size may lead to decreased throughput. A very large
# slice size may lead to wasted space. The selected default size of 8mb is
# selected for conservation of space, rather than performance.
fvm_slice_size = "8388608"
# Users of the filesystem may know required minimum load (total number of
# data bytes and total number of files) on the fs. Following parameters
# help to reserve the space needed for the load.
# minimum_inodes is the number of inodes to reserve for the fs
# An empty string does not reserve any additional space than minimum
# required for the filesystem.
blobfs_minimum_inodes = ""
minfs_minimum_inodes = ""
# For build/images:fvm.blob.sparse.blk, use this argument.
blob_blobfs_minimum_inodes = ""
# Number of bytes to reserve for data in the fs. This is in addition
# to what is reserved, if any, for the inodes. Data bytes constitutes
# "usable" space of the fs.
# An empty string does not reserve any additional space than minimum
# required for the filesystem.
blobfs_minimum_data_bytes = ""
minfs_minimum_data_bytes = ""
# For build/images:fvm.blob.sparse.blk, use this argument.
blob_blobfs_minimum_data_bytes = ""
# In addition to reserving space for inodes and data, fs needs additional
# space for maintaining some internal data structures. So the
# space required to reserve inodes and data may exceed sum of the space
# needed for inodes and data.
# maximum_bytes puts an upper bound on the total bytes reserved for inodes,
# data bytes and reservation for all other internal fs metadata.
# An empty string does not put any upper bound. A filesystem may
# reserve few blocks required for its operations.
blobfs_maximum_bytes = ""
minfs_maximum_bytes = ""
# For build/images:fvm.blob.sparse.blk, use this argument.
blob_blobfs_maximum_bytes = ""
}
# Build an FVM partition
#
# Parameters
#
# args (optional)
# [list of strings] Additional arguments to pass to the FVM tool.
#
# output_name (required)
# [string] The filename to produce.
#
# partitions (required)
# [list of scopes] a list of partitions to be included
# dep (required)
# [label] The label must be defined earlier in the same file.
# type (required)
# [string] A partition type accepted by fvm (e.g. blob, data, data-unsafe)
#
# deps (optional)
# testonly (optional)
# visibility (optional)
# metadata (optional)
# Same as for any GN `action()` target.
template("generate_fvm") {
compiled_action(target_name) {
forward_variables_from(invoker,
[
"deps",
"metadata",
"testonly",
"visibility",
])
tool = "//zircon/tools/fvm"
outputs = [ invoker.output_name ]
args = rebase_path(outputs, root_build_dir)
if (defined(invoker.args)) {
args += invoker.args
}
sources = []
if (!defined(deps)) {
deps = []
}
if (defined(invoker.with_empty_minfs) && invoker.with_empty_minfs) {
args += [ "--with-empty-minfs" ]
}
foreach(part, invoker.partitions) {
args += [ "--${part.type}" ]
deps += [ part.dep ]
sources += get_target_outputs(part.dep)
args += rebase_path(get_target_outputs(part.dep), root_build_dir)
if (defined(part.minimum_inodes) && "${part.minimum_inodes}" != "") {
args += [
"--minimum-inodes",
"${part.minimum_inodes}",
]
}
if (defined(part.minimum_data_bytes) &&
"${part.minimum_data_bytes}" != "") {
args += [
"--minimum-data-bytes",
"${part.minimum_data_bytes}",
]
}
if (defined(part.maximum_bytes) && "${part.maximum_bytes}" != "") {
args += [
"--maximum-bytes",
"${part.maximum_bytes}",
]
}
}
}
}
fvm_slice_args = [
"--slice",
fvm_slice_size,
]
fvm_create_args = [ "create" ] + fvm_slice_args
fvm_sparse_args = [
"sparse",
"--compress",
"lz4",
] + fvm_slice_args
if (fvm_max_disk_size != "") {
fvm_sparse_args += [
"--max-disk-size",
fvm_max_disk_size,
]
}