blob: d559ca9f3e0ba08e12a68bf7bc9c667cb1b5dfd0 [file] [log] [blame]
# Copyright 2018 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/banjo/toolchain.gni")
import("//build/compiled_action.gni")
import("//build/rust/rustc_library.gni")
# Declares the rustc_library invocation for the generated FIDL bindings.
template("banjo_rust_library") {
not_needed(invoker, [ "sources" ])
rustc_target_name = "${target_name}_rust"
generation_target_name = "${target_name}_rust_compile"
library_name = target_name
if (defined(invoker.name)) {
library_name = invoker.name
}
underscore_name = "banjo_" + string_replace(library_name, ".", "_")
banjo_target_gen_dir =
get_label_info(":bogus($banjo_toolchain)", "target_gen_dir")
file_stem = "$banjo_target_gen_dir/${underscore_name}"
rustc_library(rustc_target_name) {
name = underscore_name
version = "0.1.0"
edition = "2018"
disable_clippy = true
forward_variables_from(invoker, [ "testonly" ])
deps = [
"//src/lib/fuchsia-async",
"//src/lib/zircon/rust:fuchsia-zircon-status",
"//third_party/rust_crates:futures",
]
if (is_fuchsia) {
deps += [ "//src/lib/zircon/rust:fuchsia-zircon" ]
}
if (defined(invoker.public_deps)) {
foreach(dep, invoker.public_deps) {
label = get_label_info(dep, "label_no_toolchain")
deps += [ "${label}_rust" ]
}
}
if (defined(invoker.deps)) {
foreach(dep, invoker.deps) {
label = get_label_info(dep, "label_no_toolchain")
deps += [ "${label}_rust" ]
}
}
non_rust_deps = [ ":$generation_target_name($banjo_toolchain)" ]
source_root = "$file_stem.rs"
sources = [ "$file_stem.rs" ]
}
}
template("banjo_dummy_rust_library") {
assert(is_fuchsia, "This template can only be used in $target_toolchain.")
not_needed(invoker,
[
"sources",
"name",
])
rustc_target_name = "${target_name}_rust"
group(rustc_target_name) {
forward_variables_from(invoker,
[
"deps",
"testonly",
"visibility",
])
}
}