forked from vsrinivas/fuchsia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfidl.gni
189 lines (169 loc) · 5.54 KB
/
fidl.gni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# 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/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.
#
# api (optional)
# Path to the file representing the API of this library.
# This file is used to ensure modifications to the library's API are
# explicitly acknowledged. It is mandatory for publication categories of
# "partner" or "public".
# Defaults to "<target name>.api".
#
# excluded_checks (optional)
# A list of fidl-lint check IDs to ignore (by passing the command line flag
# "-e some-check-id" for each value).
#
# fuzzers (optional)
# Protocol/methods for which to generate LibFuzzer fuzz targets. Example:
# [
# {
# # Required:
# protocol = "fully.qualified.FIDLProtocolName"
# # Optional. Default: All methods in protocol.
# methods = [ "MethodName1", "MethodName2", ... ]
# },
# ...
# ]
#
# experimental_flags (optional)
# A list of experimental fidlc features to enable.
#
# host_llcpp (optional)
# A flag to enable or disable llcpp host generation.
#
# non_fidl_deps (optional)
# A list of non-FIDL dependency targets, i.e. targets that don't contribute
# FIDL artifacts, but should be built before this target regardless.
#
# should_lint (optional, boolean)
# If set to false, the linting step is skipped.
#
# experimental_api_summary (optional, boolean, default false)
# If set, the builder will generate FIDL API summary files. The generated
# file names are "<fidl_library_name>.api_summary" (human-readable), and
# "<fidl_library_name>.api_summary.json" (machine-readable).
template("fidl") {
if (defined(invoker.sdk_category)) {
not_needed(invoker, [ "sdk_category" ])
}
if (defined(invoker.api)) {
not_needed(invoker, [ "api" ])
}
if (defined(invoker.excluded_checks)) {
not_needed(invoker, [ "excluded_checks" ])
}
if (defined(invoker.fuzzers)) {
not_needed(invoker, [ "fuzzers" ])
}
if (defined(invoker.experimental_flags)) {
not_needed(invoker, [ "experimental_flags" ])
}
if (defined(invoker.host_llcpp)) {
not_needed(invoker, [ "host_llcpp" ])
}
if (defined(invoker.experimental_api_summary)) {
not_needed(invoker, [ "experimental_api_summary" ])
}
# Allow generated targets visibility to their dependant generated targets
if (defined(invoker.visibility)) {
invoker.visibility += [ ":*" ]
}
assert(!defined(invoker.deps),
"All FIDL dependencies are inherently " +
"public, use 'public_deps' instead of 'deps'.")
deps = []
if (defined(invoker.non_fidl_deps)) {
deps += invoker.non_fidl_deps
}
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 (current_toolchain == fidl_toolchain) {
import("//build/fidl/fidl_library.gni")
fidl_library(target_name) {
forward_variables_from(invoker, "*")
}
}
# Define the C++ family of generated bindings
import("//build/cpp/fidl_cpp.gni")
fidl_cpp_family(target_name) {
forward_variables_from(invoker, "*")
}
# Define FIDL coding tables target, used by C and C++
import("//build/c/fidl_c.gni")
fidl_tables(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
}
# TODO(cramertj): remove pending fxbug.dev/26853.
import("//build/rust/fidl_rust_library.gni")
fidl_rust_library(target_name) {
forward_variables_from(invoker, "*")
}
# Define the C generated bindings
if (is_fuchsia) {
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",
]
}
import("//build/banjo/fidl_banjo.gni")
fidl_banjo(target_name) {
forward_variables_from(invoker, "*")
}
}
}
}