blob: 76202f0c22814d92ea01ff92e838c9600206fcc1 [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").
#
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,
]
args = [
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),
]
inputs = [
response_file,
]
outputs = [
"$target_gen_dir/$output_file",
]
deps = [
":$response_file_target",
]
}
}
# 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" ])
}
}