blob: 195d0b5498916226a38b1eea9b41d12be95be9b8 [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/cpp/fidl_cpp.gni")
import("//build/dart/toolchain.gni")
import("//build/fidl/toolchain.gni")
import("//build/go/toolchain.gni")
import("//build/rust/toolchain.gni")
# Declares a FIDL library.
#
# Depending on the toolchain in which this targets is expanded, it will yield
# different results:
# - in the FIDL toolchain, it will compile its source files into an
# intermediate representation consumable by language bindings generators;
# - in the target or shared toolchain, this will produce a source_set
# containing C++ bindings.
#
# Parameters
#
# sources (required)
# List of paths to library source files.
#
# name (optional)
# Name of the library.
# Defaults to the target's name.
#
# sdk_category (optional)
# Publication level of the library in SDKs.
# See //build/sdk/sdk_atom.gni.
#
# cpp_legacy_callbacks (optional)
# If true, uses std::function instead of fit::function.
# Defaults to true while migration is in progress.
template("fidl") {
if (defined(invoker.sdk_category)) {
not_needed(invoker, [ "sdk_category" ])
}
if (defined(invoker.cpp_legacy_callbacks)) {
not_needed(invoker, [ "cpp_legacy_callbacks" ])
}
if (current_toolchain == fidl_toolchain) {
import("//build/fidl/fidl_library.gni")
fidl_library(target_name) {
forward_variables_from(invoker, "*")
}
fidl_cpp_codegen(target_name) {
forward_variables_from(invoker, "*")
}
} else if (current_toolchain == dart_toolchain) {
import("//build/dart/fidl_dart.gni")
fidl_dart(target_name) {
forward_variables_from(invoker, "*")
}
} else if (current_toolchain == rust_toolchain) {
import("//build/rust/fidl_rust.gni")
fidl_rust(target_name) {
forward_variables_from(invoker, "*")
}
} else if (current_toolchain == go_toolchain) {
import("//build/go/fidl_go.gni")
fidl_go(target_name) {
forward_variables_from(invoker, "*")
}
} else if (is_fuchsia) {
import("//build/c/fidl_c.gni")
import("//build/rust/fidl_rust_library.gni")
fidl_tables(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
}
# TODO(cramertj): remove pending TC-81.
fidl_rust_library(target_name) {
forward_variables_from(invoker, "*")
}
fidl_cpp(target_name) {
forward_variables_from(invoker, "*")
}
fidl_c_client(target_name) {
forward_variables_from(invoker, "*")
}
fidl_c_server(target_name) {
forward_variables_from(invoker, "*")
}
group("${target_name}_c") {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
public_deps = [
":${target_name}_client",
":${target_name}_server",
]
}
} else {
# TODO(ctiller): this case is for host-side FIDL, and ultimately
# should be identical to the previous case (once C & Rust are usable from
# host)
import("//build/c/fidl_c.gni")
fidl_tables(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
}
fidl_cpp(target_name) {
forward_variables_from(invoker, "*")
}
}
}