blob: 6a5b5adfaeb60ae58100cdf95c647c3ea039d4ec [file] [log] [blame]
# Copyright 2021 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")
# 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)
#
# inputs (optional)
# deps (optional)
# testonly (optional)
# visibility (optional)
# metadata (optional)
# Same as for any GN `action()` target.
template("generate_fvm") {
visibility = [ "//src/storage/volume_image/fvm/*" ]
compiled_action(target_name) {
forward_variables_from(invoker,
[
"inputs",
"deps",
"metadata",
"testonly",
"visibility",
])
tool = "//src/storage/bin/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_data) && invoker.with_empty_data) {
# TODO(https://fxbug.dev/42166034): Remove this flag and pass in an empty file instead.
args += [ "--with-empty-data" ]
}
if (defined(invoker.partitions)) {
foreach(part, invoker.partitions) {
args += [ "--${part.type}" ]
deps += [ part.dep ]
dep_outputs = [] # Reset after last iteration.
dep_outputs = get_target_outputs(part.dep)
sources += [ dep_outputs[0] ]
args += [ rebase_path(dep_outputs[0], root_build_dir) ]
if (defined(part.minimum_inodes) && part.minimum_inodes != false) {
args += [
"--minimum-inodes",
"${part.minimum_inodes}",
]
}
if (defined(part.minimum_data_bytes) &&
part.minimum_data_bytes != false) {
args += [
"--minimum-data-bytes",
"${part.minimum_data_bytes}",
]
}
if (defined(part.maximum_bytes) && part.maximum_bytes != false) {
args += [
"--maximum-bytes",
"${part.maximum_bytes}",
]
}
}
}
}
}