blob: eadc9ed5f72c5fb567386e8102e4eeec71a319db [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/compiled_action.gni")
import("//build/fidl/toolchain.gni")
import("//build/rust/toolchain.gni")
import("//build/rust/rustc_library.gni")
# Declares the rustc_library invocation for the generated FIDL bindings.
template("fidl_rust_library") {
not_needed(invoker, [
"deps",
"public_deps",
"sdk_category",
"sources",
])
generation_target_name = "${target_name}_rust_generate"
rustc_target_name = "${target_name}-rustc"
library_name = target_name
if (defined(invoker.name)) {
library_name = invoker.name
}
underscore_name = exec_script(
"//build/rust/fidl_crate_from_library.py",
[
"--name",
library_name,
],
"trim string"
)
fidl_target_gen_dir = get_label_info(":bogus($fidl_toolchain)", "target_gen_dir")
file_stem = "$fidl_target_gen_dir/${underscore_name}"
rustc_library(rustc_target_name) {
name = underscore_name
version = "0.1.0"
forward_variables_from(invoker, [ "testonly" ])
deps = [
"//garnet/public/lib/fidl/rust/fidl",
"//garnet/public/rust/crates/fuchsia-async",
"//garnet/public/rust/crates/fuchsia-zircon",
"//third_party/rust-crates/rustc_deps:futures",
]
if (defined(invoker.public_deps)) {
foreach(dep, invoker.public_deps) {
label = get_label_info(dep, "label_no_toolchain")
deps += [ "${label}-rustc" ]
}
}
if (defined(invoker.deps)) {
foreach(dep, invoker.deps) {
label = get_label_info(dep, "label_no_toolchain")
deps += [ "${label}-rustc" ]
}
}
non_rust_deps= [ ":$generation_target_name($rust_toolchain)" ]
source_root = rebase_path("$file_stem.rs")
}
}