blob: b7594bda7ccf6e3ff3c3d969ddf8f01d74cd6e04 [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.
# An internal helper template that acts like a group, but also validates that
# its dependencies produce a set of files (the `inputs`).
#
# GN groups only have `deps` or `public_deps`, they can't list files that are
# inputs. GN's inputs are files that are required to be created by the deps
# of an `action()` or the public_deps of its deps.
#
# This template creates an action that acts like a group that also has inputs.
# - it has deps, like a group
# - it has public_deps, like a group
# - it has inputs, like an action
# - it doesn't have a "real" output, like a group.
#
# This can be used to catch if the deps of the groups don't produce the given
# set of input files, at GN-time. The deps can be larger than the set of files,
# but not the other way around).
#
# If one or more of the inputs are not generated by the deps or public_deps of
# this "group", GN will fail with an error message stating which files are not
# produced by any dep of this action.
#
# Arguments:
#
# inputs
# [list, files] The GN usual meaning of "inputs": A list of paths to files
# that must be created by the direct deps of this target.
#
# deps, public_deps
# [list, GN targets] These are the usual GN args, but are the set of deps
# that are validated (by GN) to ensure that these deps (private or public)
# create the listed input files.
#
# GN Usual:
# testonly
# visibility
template("group_with_inputs") {
action(target_name) {
forward_variables_from(invoker,
"*",
[
"testonly",
"visibility",
])
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
assert(defined(inputs), "Must provide inputs to manifests.")
assert(defined(deps) || defined(public_deps),
"Must provide deps or public_deps.")
script = "//build/scripts/no_op.sh"
outputs = [ "${target_out_dir}/${target_name}.inputs_checked" ]
args = rebase_path(outputs, root_build_dir)
}
}