blob: c2d5b820dcd44a948ee7d49af59aff9c15b39ab0 [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/rust/rustc_library.gni")
# Generates a rust library for a given wayland protocol.xml file. The protocol
# will be built as a crate with the same name as the target.
#
# Ex:
# wayland_protocol("my_protocol") {
# protocol = "my_protocol.xml"
# }
#
template("wayland_protocol") {
assert(defined(invoker.protocol), "protocol must be defined for $target_name")
target_crate_root = "$target_gen_dir/$target_name.rs"
# Generate the rust sources using the scanner.
compiled_action("gen_${target_name}_source") {
tool = "//garnet/bin/wayland/scanner"
sources = [
invoker.protocol,
]
outputs = [
target_crate_root,
]
args = [
rebase_path(invoker.protocol),
rebase_path(target_crate_root),
]
}
# Build the library.
rustc_library(target_name) {
edition = "2018"
non_rust_deps = [ ":gen_${target_name}_source" ]
deps = [
"//garnet/bin/wayland/core",
"//garnet/public/rust/fuchsia-zircon",
"//third_party/rust-crates/rustc_deps:bitflags",
"//third_party/rust-crates/rustc_deps:failure",
]
source_root = target_crate_root
}
}