blob: de6f8d2662df5c40cf9c5e544204ce8147057d90 [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")
template("fidl_tables") {
main_target_name = target_name
fidl_target_gen_dir =
get_label_info(":$target_name($fidl_toolchain)", "target_gen_dir")
coding_tables = "$fidl_target_gen_dir/$target_name.fidl.tables.cc"
# The C simple $type code is generated by the frontend, so we just need to
# produce a target with the generated file name and configuration information.
source_set(main_target_name + "_tables") {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
sources = [
coding_tables,
]
deps = [
":${main_target_name}_compile($fidl_toolchain)",
]
public_deps = [
"//zircon/public/lib/fidl_base",
]
}
}
# C simple client bindings for a FIDL library.
#
# The parameters for this template are defined in //build/fidl/fidl.gni. The
# relevant parameters in this template are:
# name: string, name of the FIDL library
# type: string, 'client' or 'server'
template("fidl_c_target") {
assert(is_fuchsia, "This template can only be used in $target_toolchain.")
type = invoker.type
main_target_name = target_name
library_name = invoker.name
c_stem = string_replace(library_name, ".", "/") + "/c/fidl"
fidl_root_gen_dir =
get_label_info(":$target_name($fidl_toolchain)", "root_gen_dir")
c_header = "$fidl_root_gen_dir/$c_stem.h"
c_file = "$fidl_root_gen_dir/$c_stem.$type.c"
# The C simple $type code is generated by the frontend, so we just need to
# produce a target with the generated file name and configuration information.
source_set(main_target_name + "_c_" + type) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
sources = [
c_file,
]
public = [
c_header,
]
# Let dependencies use `#include "$file_stem.h"`.
public_configs = [ "//build/cpp:fidl_gen_config" ]
deps = [
":${main_target_name}_compile($fidl_toolchain)",
":${main_target_name}_tables",
]
public_deps = [
"//zircon/public/lib/fidl",
]
libs = [ "zircon" ]
}
}
template("fidl_c_client") {
library_name = target_name
if (defined(invoker.name)) {
library_name = invoker.name
}
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
fidl_c_target(target_name) {
name = library_name
type = "client"
}
}
template("fidl_c_server") {
library_name = target_name
if (defined(invoker.name)) {
library_name = invoker.name
}
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
fidl_c_target(target_name) {
name = library_name
type = "server"
}
}