| # 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/config/fuchsia/zircon.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 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 = "" |
| |
| # 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 = "" |
| |
| # 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 = "" |
| } |
| |
| # 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) |
| # Same as for any GN `action()` target. |
| template("generate_fvm") { |
| zircon_tool_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "deps", |
| "visibility", |
| ]) |
| tool = "fvm" |
| outputs = [ |
| invoker.output_name, |
| ] |
| args = rebase_path(outputs, root_build_dir) |
| if (defined(invoker.args)) { |
| args += invoker.args |
| } |
| sources = [] |
| if (!defined(deps)) { |
| deps = [] |
| } |
| 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 |