blob: da9069500387bbcb891a85e0716e49d46eba7c87 [file] [log] [blame]
# Copyright 2019 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")
# Declares a driver's bind rules.
#
# Generate a C header that exposes a ZIRCON_DRIVER macro with the specified bind rules built in.
# For more details refer to //tools/bindc/README.md.
#
# Parameters
#
# rules (required)
# Path to the bind rules source file.
#
# deps
# List of bind_library targets included by the bind rules.
#
# output_file
# Name of the header file generated by the tool (defaults to target name + ".h").
#
# disable_autobind
# Configure the bind compiler to disable autobind, so that the driver must be bound on a user's
# request. Defaults to false.
# TODO(43400): Eventually this option should be removed when we can define this configuration
# in the driver's component manifest.
#
template("bind_rules") {
assert(defined(invoker.rules), "Need a bind rules source")
output_file = "$target_name.h"
if (defined(invoker.output)) {
output_file = invoker.output
}
response_file_target = "${target_name}_response_file"
response_file = "$target_gen_dir/$target_name.rsp"
generated_file(response_file_target) {
data_keys = [ "sources" ]
forward_variables_from(invoker, [ "deps" ])
outputs = [ response_file ]
}
compiled_action(target_name) {
tool = "//tools/bindc:bin"
tool_output_name = "bindc"
sources = [ invoker.rules ]
depfile = "$target_gen_dir/$target_name.d"
args = [
"compile",
rebase_path(invoker.rules, root_build_dir),
"--output",
rebase_path("$target_gen_dir/$output_file", root_build_dir),
"--include-file",
rebase_path(response_file, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
if (defined(invoker.disable_autobind) && invoker.disable_autobind) {
args += [ "--disable-autobind" ]
}
inputs = [ response_file ]
outputs = [ "$target_gen_dir/$output_file" ]
deps = [ ":$response_file_target" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
}
# Declares a bind library.
#
# Declare a bind library that may be included by other libraries or bind rules. For more details,
# refer to //tools/bindc/README.md.
#
# Parameters
#
# source (required)
# Path to the library source file.
#
# public_deps
# List of other bind_library targets included by the library.
#
template("bind_library") {
assert(defined(invoker.source), "Need a source file")
group(target_name) {
metadata = {
sources = [ rebase_path(invoker.source, root_build_dir) ]
}
forward_variables_from(invoker, [ "public_deps" ])
}
}