OLD | NEW |
| (Empty) |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 # TODO(vardhan): Targets for each language bindings depend on a central | |
6 # generator target which generates bindings for /every/ language. Create | |
7 # separate generator targets for each language. | |
8 | |
9 import("../../mojo_sdk.gni") | |
10 | |
11 # Generate C++/JavaScript/Java/Python/Dart/Go source files from mojom files. The | |
12 # output files will go under the generated file directory tree with the same | |
13 # path as each input file. | |
14 # | |
15 # If a mojom target is intended for use in a client repo where the location of | |
16 # the Mojo SDK will be different than its location in the Mojo repo, | |
17 # dependencies on the SDK should be specified relative to the parent directory | |
18 # of the Mojo public SDK in |mojo_sdk_deps| rather than via absolute paths in | |
19 # |deps|. | |
20 # | |
21 # Parameters: | |
22 # | |
23 # sources (optional if one of the deps sets listed below is present) | |
24 # List of source .mojom files to compile. | |
25 # | |
26 # deps (optional) | |
27 # Note: this can contain only other mojom targets. | |
28 # | |
29 # mojo_sdk_deps (optional) | |
30 # List of deps specified relative to the parent directory of the Mojo | |
31 # public SDK. These deps will be added as ordinary deps rebased to the | |
32 # current directory. | |
33 # | |
34 # public_deps (optional) | |
35 # Note: this can contain only other mojom targets. | |
36 # | |
37 # mojo_sdk_public_deps (optional) | |
38 # List of public deps specified relative to the parent directory of the | |
39 # Mojo public SDK. These deps will be added as ordinary public deps | |
40 # rebased to the current directory. | |
41 # | |
42 # import_dirs (optional) | |
43 # List of import directories that will get added when processing sources. | |
44 # | |
45 # testonly (optional) | |
46 # | |
47 # visibility (optional) | |
48 template("mojom") { | |
49 assert( | |
50 defined(invoker.sources) || defined(invoker.deps) || | |
51 defined(invoker.public_deps) || defined(invoker.mojo_sdk_deps) || | |
52 defined(invoker.mojo_sdk_public_deps), | |
53 "\"sources\" or \"deps\" must be defined for the $target_name template.") | |
54 | |
55 cpp_sources_suffix = "cpp_sources" | |
56 cpp_sources_target_name = "${target_name}_${cpp_sources_suffix}" | |
57 cpp_sync_sources_target_name = "${target_name}_${cpp_sources_suffix}_sync" | |
58 | |
59 if (defined(invoker.sources)) { | |
60 generator_root = rebase_path("mojo/public/tools/bindings", ".", mojo_root) | |
61 mojom_tool = "$generator_root/mojom_tool.py" | |
62 | |
63 # The |generator_host_platform| string is used to determine the subdirectory | |
64 # where our mojom and generator binaries live. | |
65 generator_host_platform = host_os | |
66 if (host_cpu == "x64") { | |
67 generator_host_platform += "64" | |
68 } else if (host_cpu == "x86") { | |
69 generator_host_platform += "32" | |
70 } | |
71 generator_sources = [ | |
72 mojom_tool, | |
73 "$generator_root/run_code_generators.py", | |
74 "$generator_root/generators/cpp_templates/enum_macros.tmpl", | |
75 "$generator_root/generators/cpp_templates/interface_declaration.tmpl", | |
76 "$generator_root/generators/cpp_templates/interface_definition.tmpl", | |
77 "$generator_root/generators/cpp_templates/interface_macros.tmpl", | |
78 "$generator_root/generators/cpp_templates/interface_proxy_declaration.tmpl
", | |
79 "$generator_root/generators/cpp_templates/interface_request_validator_decl
aration.tmpl", | |
80 "$generator_root/generators/cpp_templates/interface_response_validator_dec
laration.tmpl", | |
81 "$generator_root/generators/cpp_templates/interface_stub_declaration.tmpl"
, | |
82 "$generator_root/generators/cpp_templates/module-common.cc.tmpl", | |
83 "$generator_root/generators/cpp_templates/module-common.h.tmpl", | |
84 "$generator_root/generators/cpp_templates/module-internal.h.tmpl", | |
85 "$generator_root/generators/cpp_templates/module-sync.cc.tmpl", | |
86 "$generator_root/generators/cpp_templates/module-sync.h.tmpl", | |
87 "$generator_root/generators/cpp_templates/module.cc.tmpl", | |
88 "$generator_root/generators/cpp_templates/module.h.tmpl", | |
89 "$generator_root/generators/cpp_templates/struct_declaration.tmpl", | |
90 "$generator_root/generators/cpp_templates/struct_definition.tmpl", | |
91 "$generator_root/generators/cpp_templates/struct_macros.tmpl", | |
92 "$generator_root/generators/cpp_templates/struct_serialization_declaration
.tmpl", | |
93 "$generator_root/generators/cpp_templates/struct_serialization_definition.
tmpl", | |
94 "$generator_root/generators/cpp_templates/union_declaration.tmpl", | |
95 "$generator_root/generators/cpp_templates/union_definition.tmpl", | |
96 "$generator_root/generators/cpp_templates/union_serialization_declaration.
tmpl", | |
97 "$generator_root/generators/cpp_templates/union_serialization_definition.t
mpl", | |
98 "$generator_root/generators/cpp_templates/validation_macros.tmpl", | |
99 "$generator_root/generators/cpp_templates/wrapper_class_declaration.tmpl", | |
100 "$generator_root/generators/cpp_templates/wrapper_class_definition.tmpl", | |
101 "$generator_root/generators/cpp_templates/wrapper_union_class_declaration.
tmpl", | |
102 "$generator_root/generators/cpp_templates/wrapper_union_class_definition.t
mpl", | |
103 "$generator_root/generators/dart_templates/encoding_macros.tmpl", | |
104 "$generator_root/generators/dart_templates/enum_definition.tmpl", | |
105 "$generator_root/generators/dart_templates/interface_definition.tmpl", | |
106 "$generator_root/generators/dart_templates/module.lib.tmpl", | |
107 "$generator_root/generators/dart_templates/module_definition.tmpl", | |
108 "$generator_root/generators/dart_templates/struct_definition.tmpl", | |
109 "$generator_root/generators/dart_templates/union_definition.tmpl", | |
110 "$generator_root/generators/go_templates/encoding_macros.tmpl", | |
111 "$generator_root/generators/go_templates/enum.tmpl", | |
112 "$generator_root/generators/go_templates/interface.tmpl", | |
113 "$generator_root/generators/go_templates/source.tmpl", | |
114 "$generator_root/generators/go_templates/struct.tmpl", | |
115 "$generator_root/generators/go_templates/union.tmpl", | |
116 "$generator_root/generators/java_templates/constant_definition.tmpl", | |
117 "$generator_root/generators/java_templates/constants.java.tmpl", | |
118 "$generator_root/generators/java_templates/data_types_definition.tmpl", | |
119 "$generator_root/generators/java_templates/enum_definition.tmpl", | |
120 "$generator_root/generators/java_templates/enum.java.tmpl", | |
121 "$generator_root/generators/java_templates/header.java.tmpl", | |
122 "$generator_root/generators/java_templates/interface_definition.tmpl", | |
123 "$generator_root/generators/java_templates/interface_internal.java.tmpl", | |
124 "$generator_root/generators/java_templates/interface.java.tmpl", | |
125 "$generator_root/generators/java_templates/struct.java.tmpl", | |
126 "$generator_root/generators/java_templates/union.java.tmpl", | |
127 "$generator_root/generators/js_templates/enum_definition.tmpl", | |
128 "$generator_root/generators/js_templates/interface_definition.tmpl", | |
129 "$generator_root/generators/js_templates/module.amd.tmpl", | |
130 "$generator_root/generators/js_templates/module_definition.tmpl", | |
131 "$generator_root/generators/js_templates/struct_definition.tmpl", | |
132 "$generator_root/generators/js_templates/union_definition.tmpl", | |
133 "$generator_root/generators/js_templates/validation_macros.tmpl", | |
134 "$generator_root/generators/python_templates/module.py.tmpl", | |
135 "$generator_root/generators/python_templates/module_macros.tmpl", | |
136 "$generator_root/generators/mojom_cpp_generator.py", | |
137 "$generator_root/generators/mojom_dart_generator.py", | |
138 "$generator_root/generators/mojom_go_generator.py", | |
139 "$generator_root/generators/mojom_js_generator.py", | |
140 "$generator_root/generators/mojom_java_generator.py", | |
141 "$generator_root/generators/mojom_python_generator.py", | |
142 "$generator_root/mojom_tool/bin/${generator_host_platform}/mojom", | |
143 "$generator_root/mojom_tool/bin/${generator_host_platform}/generators/c", | |
144 "$generator_root/mojom_tool/bin/${generator_host_platform}/generators/go", | |
145 "$generator_root/pylib/mojom/__init__.py", | |
146 "$generator_root/pylib/mojom/error.py", | |
147 "$generator_root/pylib/mojom/generate/__init__.py", | |
148 "$generator_root/pylib/mojom/generate/constant_resolver.py", | |
149 "$generator_root/pylib/mojom/generate/generator.py", | |
150 "$generator_root/pylib/mojom/generate/module.py", | |
151 "$generator_root/pylib/mojom/generate/pack.py", | |
152 "$generator_root/pylib/mojom/generate/template_expander.py", | |
153 "$generator_root/pylib/mojom/parse/__init__.py", | |
154 "$generator_root/pylib/mojom/parse/parser_runner.py", | |
155 ] | |
156 generator_cpp_outputs = [ | |
157 "{{source_gen_dir}}/{{source_name_part}}.mojom-common.cc", | |
158 "{{source_gen_dir}}/{{source_name_part}}.mojom-common.h", | |
159 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h", | |
160 "{{source_gen_dir}}/{{source_name_part}}.mojom-sync.cc", | |
161 "{{source_gen_dir}}/{{source_name_part}}.mojom-sync.h", | |
162 "{{source_gen_dir}}/{{source_name_part}}.mojom.h", | |
163 "{{source_gen_dir}}/{{source_name_part}}.mojom.cc", | |
164 ] | |
165 generator_c_outputs = [ | |
166 "{{source_gen_dir}}/{{source_name_part}}.mojom-c.c", | |
167 "{{source_gen_dir}}/{{source_name_part}}.mojom-c.h", | |
168 ] | |
169 generator_js_outputs = | |
170 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.js" ] | |
171 generator_dart_outputs = | |
172 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.dart" ] | |
173 generator_go_outputs = [ "${root_gen_dir}/go/src/{{source_dir}}/{{source_nam
e_part}}/{{source_name_part}}.mojom.go" ] | |
174 generator_python_outputs = | |
175 [ "{{source_gen_dir}}/{{source_name_part}}_mojom.py" ] | |
176 generator_java_outputs = | |
177 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.srcjar" ] | |
178 } | |
179 generator_python_zip_output = "$target_out_dir/${target_name}_python.pyzip" | |
180 | |
181 rebased_mojo_sdk_public_deps = [] | |
182 if (defined(invoker.mojo_sdk_public_deps)) { | |
183 foreach(sdk_dep, invoker.mojo_sdk_public_deps) { | |
184 # Check that the SDK dep was not mistakenly given as an absolute path. | |
185 assert(get_path_info(sdk_dep, "abspath") != sdk_dep) | |
186 rebased_mojo_sdk_public_deps += [ rebase_path(sdk_dep, ".", mojo_root) ] | |
187 } | |
188 } | |
189 | |
190 rebased_mojo_sdk_deps = [] | |
191 if (defined(invoker.mojo_sdk_deps)) { | |
192 foreach(sdk_dep, invoker.mojo_sdk_deps) { | |
193 # Check that the SDK dep was not mistakenly given as an absolute path. | |
194 assert(get_path_info(sdk_dep, "abspath") != sdk_dep) | |
195 rebased_mojo_sdk_deps += [ rebase_path(sdk_dep, ".", mojo_root) ] | |
196 } | |
197 } | |
198 | |
199 if (defined(invoker.sources)) { | |
200 generator_target_name = target_name + "__generator" | |
201 action_foreach(generator_target_name) { | |
202 script = mojom_tool | |
203 inputs = generator_sources | |
204 if (defined(invoker.generate_type_info) && invoker.generate_type_info) { | |
205 deps = [ | |
206 rebase_path("mojo/public/interfaces/bindings", ".", mojo_root), | |
207 ] | |
208 } | |
209 sources = invoker.sources | |
210 outputs = | |
211 generator_cpp_outputs + generator_dart_outputs + | |
212 generator_go_outputs + generator_java_outputs + generator_js_outputs + | |
213 generator_python_outputs + generator_c_outputs | |
214 args = [ | |
215 "gen", | |
216 "--src-root-path", | |
217 rebase_path("//", root_build_dir), | |
218 "-I", | |
219 rebase_path("//", root_build_dir), | |
220 "-I", | |
221 rebase_path(mojo_root, root_build_dir), | |
222 "--output-dir", | |
223 rebase_path(root_gen_dir), | |
224 "--no-gen-imports", | |
225 "--generators", | |
226 "legacy,c,go", | |
227 ] | |
228 | |
229 if (defined(invoker.generate_type_info) && invoker.generate_type_info) { | |
230 args += [ | |
231 "--gen-arg", | |
232 "generate-type-info", | |
233 ] | |
234 } | |
235 | |
236 if (defined(invoker.import_dirs)) { | |
237 foreach(import_dir, invoker.import_dirs) { | |
238 args += [ | |
239 "-I", | |
240 rebase_path(import_dir, root_build_dir), | |
241 ] | |
242 } | |
243 } | |
244 | |
245 args += [ "{{source}}" ] | |
246 } | |
247 } | |
248 | |
249 # Some re-usable variables for the C++ source sets: | |
250 cpp_public_deps = rebased_mojo_sdk_public_deps | |
251 if (defined(invoker.public_deps)) { | |
252 cpp_public_deps += invoker.public_deps | |
253 } | |
254 if (defined(invoker.sources)) { | |
255 cpp_public_deps += [ ":$generator_target_name" ] | |
256 } | |
257 cpp_deps = rebased_mojo_sdk_deps | |
258 if (defined(invoker.deps)) { | |
259 cpp_deps += invoker.deps | |
260 } | |
261 if (defined(invoker.mojo_sdk_deps)) { | |
262 foreach(sdk_dep, invoker.mojo_sdk_deps) { | |
263 # Check that the SDK dep was not mistakenly given as an absolute path. | |
264 assert(get_path_info(sdk_dep, "abspath") != sdk_dep) | |
265 cpp_deps += [ rebase_path(sdk_dep, ".", mojo_root) ] | |
266 } | |
267 } | |
268 | |
269 source_set(target_name) { | |
270 if (defined(invoker.visibility)) { | |
271 visibility = invoker.visibility | |
272 } | |
273 if (defined(invoker.testonly)) { | |
274 testonly = invoker.testonly | |
275 } | |
276 | |
277 public_configs = | |
278 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) | |
279 | |
280 public_deps = | |
281 rebase_path([ "mojo/public/cpp/bindings:core" ], ".", mojo_root) | |
282 public_deps += cpp_public_deps | |
283 if (defined(invoker.sources)) { | |
284 public_deps += [ ":${cpp_sources_target_name}" ] | |
285 data = process_file_template(invoker.sources, generator_js_outputs) | |
286 } | |
287 | |
288 deps = cpp_deps | |
289 } | |
290 | |
291 # This target is used to generate and build the C mojom bindings. | |
292 source_set("${target_name}_c") { | |
293 if (defined(invoker.visibility)) { | |
294 visibility = invoker.visibility | |
295 } | |
296 if (defined(invoker.testonly)) { | |
297 testonly = invoker.testonly | |
298 } | |
299 | |
300 public_configs = | |
301 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) | |
302 | |
303 public_deps = rebase_path([ "mojo/public/c:bindings" ], ".", mojo_root) | |
304 deps = [] | |
305 c_public_deps = [] | |
306 c_deps = [] | |
307 | |
308 # Bring in |invoker.public_deps| and |invoker.deps|. | |
309 if (defined(invoker.public_deps)) { | |
310 c_public_deps += invoker.public_deps | |
311 } | |
312 if (defined(invoker.deps)) { | |
313 c_deps += invoker.deps | |
314 } | |
315 | |
316 foreach(d, c_public_deps + rebased_mojo_sdk_public_deps) { | |
317 # Resolve the name, so that a target //mojo/something becomes | |
318 # //mojo/something:something and we can append "_c" to get the C | |
319 # dependency name. | |
320 full_name = get_label_info(d, "label_no_toolchain") | |
321 public_deps += [ "${full_name}_c" ] | |
322 } | |
323 foreach(d, c_deps + rebased_mojo_sdk_deps) { | |
324 full_name = get_label_info(d, "label_no_toolchain") | |
325 deps += [ "${full_name}_c" ] | |
326 } | |
327 | |
328 if (defined(invoker.sources)) { | |
329 deps += [ ":$generator_target_name" ] | |
330 sources = process_file_template( | |
331 invoker.sources, | |
332 [ | |
333 "{{source_gen_dir}}/{{source_name_part}}.mojom-c.c", | |
334 "{{source_gen_dir}}/{{source_name_part}}.mojom-c.h", | |
335 ]) | |
336 } | |
337 } | |
338 | |
339 source_set("${target_name}_sync") { | |
340 if (defined(invoker.visibility)) { | |
341 visibility = invoker.visibility | |
342 } | |
343 if (defined(invoker.testonly)) { | |
344 testonly = invoker.testonly | |
345 } | |
346 | |
347 public_configs = | |
348 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) | |
349 | |
350 public_deps = rebase_path([ "mojo/public/cpp/bindings" ], ".", mojo_root) | |
351 public_deps += cpp_public_deps | |
352 if (defined(invoker.sources)) { | |
353 public_deps += [ ":${cpp_sync_sources_target_name}" ] | |
354 data = process_file_template(invoker.sources, generator_js_outputs) | |
355 } | |
356 | |
357 deps = cpp_deps | |
358 } | |
359 | |
360 source_set("${target_name}_data_only") { | |
361 if (defined(invoker.visibility)) { | |
362 visibility = invoker.visibility | |
363 } | |
364 if (defined(invoker.testonly)) { | |
365 testonly = invoker.testonly | |
366 } | |
367 | |
368 public_configs = | |
369 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) | |
370 | |
371 public_deps = rebase_path([ "mojo/public/cpp/bindings:serialization" ], | |
372 ".", | |
373 mojo_root) | |
374 public_deps += cpp_public_deps | |
375 if (defined(invoker.sources)) { | |
376 public_deps += [ ":${cpp_sources_target_name}" ] | |
377 data = process_file_template(invoker.sources, generator_js_outputs) | |
378 } | |
379 deps = cpp_deps | |
380 } | |
381 | |
382 all_deps = rebased_mojo_sdk_deps + rebased_mojo_sdk_public_deps | |
383 if (defined(invoker.deps)) { | |
384 all_deps += invoker.deps | |
385 } | |
386 if (defined(invoker.public_deps)) { | |
387 all_deps += invoker.public_deps | |
388 } | |
389 | |
390 group("${target_name}__is_mojom") { | |
391 } | |
392 | |
393 # Explicitly ensure that all dependencies (invoker.deps and | |
394 # invoker.public_deps) are mojom targets themselves. | |
395 group("${target_name}__check_deps_are_all_mojom") { | |
396 deps = [] | |
397 foreach(d, all_deps) { | |
398 name = get_label_info(d, "label_no_toolchain") | |
399 toolchain = get_label_info(d, "toolchain") | |
400 deps += [ "${name}__is_mojom(${toolchain})" ] | |
401 } | |
402 } | |
403 | |
404 action("${target_name}_python") { | |
405 script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_root) | |
406 | |
407 deps = [] | |
408 zip_inputs = [] | |
409 | |
410 if (defined(invoker.sources)) { | |
411 inputs = process_file_template(invoker.sources, generator_python_outputs) | |
412 deps += [ ":$generator_target_name" ] | |
413 } | |
414 | |
415 foreach(d, all_deps) { | |
416 # Resolve the name, so that a target //mojo/something becomes | |
417 # //mojo/something:something and we can append "_python" to get the python | |
418 # dependency name. | |
419 full_name = get_label_info(d, "label_no_toolchain") | |
420 dep_name = get_label_info(d, "name") | |
421 dep_target_out_dir = get_label_info(d, "target_out_dir") | |
422 deps += [ "${full_name}_python" ] | |
423 zip_inputs += [ "$dep_target_out_dir/${dep_name}_python.pyzip" ] | |
424 } | |
425 | |
426 output = generator_python_zip_output | |
427 outputs = [ | |
428 output, | |
429 ] | |
430 | |
431 rebase_base_dir = rebase_path(target_gen_dir, root_build_dir) | |
432 if (defined(invoker.sources)) { | |
433 rebase_inputs = rebase_path(inputs, root_build_dir) | |
434 } | |
435 rebase_zip_inputs = rebase_path(zip_inputs, root_build_dir) | |
436 rebase_output = rebase_path(output, root_build_dir) | |
437 args = [ | |
438 "--base-dir=$rebase_base_dir", | |
439 "--zip-inputs=$rebase_zip_inputs", | |
440 "--output=$rebase_output", | |
441 ] | |
442 if (defined(invoker.sources)) { | |
443 args += [ "--inputs=$rebase_inputs" ] | |
444 } | |
445 } | |
446 | |
447 if (defined(invoker.sources)) { | |
448 # The generated C++ source files. The main reason to introduce this target | |
449 # is so that mojo/public/cpp/bindings can depend on mojom interfaces without | |
450 # circular dependencies. It means that the target is missing the dependency | |
451 # on mojo/public/cpp/bindings. No external targets should depend directly on | |
452 # this target *except* mojo/public/cpp/bindings and other *_cpp_sources | |
453 # targets. | |
454 | |
455 source_set(cpp_sources_target_name + "__common") { | |
456 if (defined(invoker.testonly)) { | |
457 testonly = invoker.testonly | |
458 } | |
459 sources = process_file_template( | |
460 invoker.sources, | |
461 [ | |
462 "{{source_gen_dir}}/{{source_name_part}}.mojom-common.cc", | |
463 "{{source_gen_dir}}/{{source_name_part}}.mojom-common.h", | |
464 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h", | |
465 ]) | |
466 public_configs = | |
467 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) | |
468 deps = [ | |
469 ":$generator_target_name", | |
470 rebase_path("mojo/public/interfaces/bindings:bindings__generator", | |
471 ".", | |
472 mojo_root), | |
473 ] | |
474 foreach(d, all_deps) { | |
475 # Resolve the name, so that a target //mojo/something becomes | |
476 # //mojo/something:something and we can append cpp_sources_suffix to | |
477 # get the cpp dependency name. | |
478 full_name = get_label_info(d, "label_no_toolchain") | |
479 deps += [ "${full_name}_${cpp_sources_suffix}" ] | |
480 } | |
481 } | |
482 | |
483 source_set(cpp_sources_target_name) { | |
484 if (defined(invoker.testonly)) { | |
485 testonly = invoker.testonly | |
486 } | |
487 sources = process_file_template( | |
488 invoker.sources, | |
489 [ | |
490 "{{source_gen_dir}}/{{source_name_part}}.mojom.h", | |
491 "{{source_gen_dir}}/{{source_name_part}}.mojom.cc", | |
492 ]) | |
493 public_configs = | |
494 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) | |
495 deps = [ | |
496 ":$generator_target_name", | |
497 ":${cpp_sources_target_name}__common", | |
498 rebase_path("mojo/public/interfaces/bindings:bindings__generator", | |
499 ".", | |
500 mojo_root), | |
501 ] | |
502 foreach(d, all_deps) { | |
503 # Resolve the name, so that a target //mojo/something becomes | |
504 # //mojo/something:something and we can append cpp_sources_suffix to | |
505 # get the cpp dependency name. | |
506 full_name = get_label_info(d, "label_no_toolchain") | |
507 deps += [ "${full_name}_${cpp_sources_suffix}" ] | |
508 } | |
509 } | |
510 | |
511 source_set(cpp_sync_sources_target_name) { | |
512 if (defined(invoker.testonly)) { | |
513 testonly = invoker.testonly | |
514 } | |
515 sources = process_file_template( | |
516 invoker.sources, | |
517 [ | |
518 "{{source_gen_dir}}/{{source_name_part}}.mojom-sync.cc", | |
519 "{{source_gen_dir}}/{{source_name_part}}.mojom-sync.h", | |
520 ]) | |
521 public_configs = | |
522 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root) | |
523 deps = [ | |
524 ":$generator_target_name", | |
525 ":${cpp_sources_target_name}__common", | |
526 rebase_path("mojo/public/interfaces/bindings:bindings__generator", | |
527 ".", | |
528 mojo_root), | |
529 ] | |
530 foreach(d, all_deps) { | |
531 # Resolve the name, so that a target //mojo/something becomes | |
532 # //mojo/something:something and we can append cpp_sources_suffix to | |
533 # get the cpp dependency name. | |
534 full_name = get_label_info(d, "label_no_toolchain") | |
535 deps += [ "${full_name}_${cpp_sources_suffix}" ] | |
536 } | |
537 } | |
538 } | |
539 | |
540 if (is_android) { | |
541 import("//build/config/android/rules.gni") | |
542 | |
543 java_srcjar_target_name = target_name + "_java_sources" | |
544 action(java_srcjar_target_name) { | |
545 script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_root) | |
546 inputs = process_file_template(invoker.sources, generator_java_outputs) | |
547 output = "$target_gen_dir/$target_name.srcjar" | |
548 outputs = [ | |
549 output, | |
550 ] | |
551 rebase_inputs = rebase_path(inputs, root_build_dir) | |
552 rebase_output = rebase_path(output, root_build_dir) | |
553 args = [ | |
554 "--zip-inputs=$rebase_inputs", | |
555 "--output=$rebase_output", | |
556 ] | |
557 deps = [ | |
558 ":$generator_target_name", | |
559 ] | |
560 } | |
561 | |
562 java_target_name = target_name + "_java" | |
563 android_library(java_target_name) { | |
564 deps = rebase_path([ | |
565 "mojo/public/java:bindings", | |
566 "mojo/public/java:system", | |
567 ], | |
568 ".", | |
569 mojo_root) | |
570 | |
571 foreach(d, all_deps) { | |
572 # Resolve the name, so that a target //mojo/something becomes | |
573 # //mojo/something:something and we can append "_java" to get the java | |
574 # dependency name. | |
575 full_name = get_label_info(d, "label_no_toolchain") | |
576 deps += [ "${full_name}_java" ] | |
577 } | |
578 | |
579 srcjar_deps = [ ":$java_srcjar_target_name" ] | |
580 } | |
581 } | |
582 } | |
OLD | NEW |