blob: 46f6d5265bd1e9941aeae4c1d8c4a7b1b1365d12 [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.
import("//build/bind/bind.gni")
# Generates a driver bind library for a FIDL library.
#
# Parameters (see //build/fidl/fidl.gni for descriptions):
#
# name
# testonly
# visibility
#
template("fidl_bind_library") {
not_needed(invoker,
[
"public_deps",
"sdk_category",
])
generation_target_name = "${target_name}_bindlib_generate"
library_name = target_name
if (defined(invoker.name)) {
library_name = invoker.name
}
fidl_target_gen_dir =
get_label_info(":bogus($fidl_toolchain)", "target_gen_dir")
bind_library_file_name = "${library_name}.bind"
generated_bind_library =
"$fidl_target_gen_dir/$target_name/fidl_bindlibs/$bind_library_file_name"
if (current_toolchain == fidl_toolchain) {
not_needed(invoker, [ "visibility" ])
main_target_name = target_name
ir_file = "$fidl_target_gen_dir/$target_name.fidl.json"
compiled_action(generation_target_name) {
forward_variables_from(invoker, [ "testonly" ])
visibility = [ ":*" ]
tool = "//tools/bindc:bin"
tool_output_name = "bindc"
inputs = [ ir_file ]
outputs = [ generated_bind_library ]
deps = [ ":${main_target_name}($fidl_toolchain)" ]
args = [
"generate-bind",
"--output",
rebase_path("${generated_bind_library}", root_build_dir),
rebase_path("${ir_file}", root_build_dir),
]
metadata = {
generated_sources = rebase_path(outputs, root_build_dir)
}
}
} else {
bind_library("${target_name}_bindlib") {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
source_dep = ":$generation_target_name($fidl_toolchain)"
source = generated_bind_library
name = library_name
}
}
}