OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Compile a protocol buffer. | 5 # Compile a protocol buffer. |
6 # | 6 # |
7 # Protobuf parameters: | 7 # Protobuf parameters: |
8 # | 8 # |
9 # proto_in_dir (optional) | 9 # proto_in_dir (optional) |
10 # Specifies the path relative to the current BUILD.gn file where | 10 # Specifies the path relative to the current BUILD.gn file where |
11 # proto files are located and the directory structure of | 11 # proto files are located and the directory structure of |
12 # this proto library starts. | 12 # this proto library starts. |
13 # | 13 # |
14 # This option can be calculated automatically but it will raise an | 14 # This option can be calculated automatically but it will raise an |
15 # assertion error if any nested directories are found. | 15 # assertion error if any nested directories are found. |
16 # | 16 # |
17 # proto_out_dir (optional) | 17 # proto_out_dir (optional) |
18 # Specifies the path suffix that output files are generated under. | 18 # Specifies the path suffix that output files are generated under. |
19 # This path will be appended to |root_gen_dir|, but for python stubs | 19 # This path will be appended to |root_gen_dir|, but for python stubs |
20 # it will be appended to |root_build_dir|/pyproto. | 20 # it will be appended to |root_build_dir|/pyproto. |
21 # | 21 # |
22 # proto_path (optional) | |
23 # List of additional directories to find imported protos. | |
24 # | |
22 # generate_python (optional, default true) | 25 # generate_python (optional, default true) |
23 # Generate Python protobuf stubs. | 26 # Generate Python protobuf stubs. |
24 # | 27 # |
25 # generate_cc (optional, default true) | 28 # generate_cc (optional, default true) |
26 # Generate C++ protobuf stubs. | 29 # Generate C++ protobuf stubs. |
27 # | 30 # |
28 # cc_generator_options (optional) | 31 # cc_generator_options (optional) |
29 # List of extra flags passed to the protocol compiler. If you need to | 32 # List of extra flags passed to the protocol compiler. If you need to |
30 # add an EXPORT macro to a protobuf's C++ header, set the | 33 # add an EXPORT macro to a protobuf's C++ header, set the |
31 # 'cc_generator_options' variable with the value: | 34 # 'cc_generator_options' variable with the value: |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 protoc_out_dir = get_label_info(protoc_label, "root_out_dir") | 232 protoc_out_dir = get_label_info(protoc_label, "root_out_dir") |
230 args += [ | 233 args += [ |
231 # Wrapper should never pick a system protoc. | 234 # Wrapper should never pick a system protoc. |
232 # Path should be rebased because |root_build_dir| for current toolchain | 235 # Path should be rebased because |root_build_dir| for current toolchain |
233 # may be different from |root_out_dir| of protoc built on host toolchain. | 236 # may be different from |root_out_dir| of protoc built on host toolchain. |
234 "--protoc", | 237 "--protoc", |
235 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc", | 238 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc", |
236 "--proto-in-dir", | 239 "--proto-in-dir", |
237 rebase_path(proto_in_dir, root_build_dir), | 240 rebase_path(proto_in_dir, root_build_dir), |
238 ] | 241 ] |
242 if (defined(invoker.proto_path)) { | |
243 foreach(_proto_dir, invoker.proto_path) { | |
244 args += [ | |
245 "--proto-path", | |
246 rebase_path(_proto_dir, root_build_dir), | |
247 ] | |
248 } | |
249 } | |
239 | 250 |
240 if (generate_cc) { | 251 if (generate_cc) { |
241 args += [ | 252 args += [ |
242 "--cc-out-dir", | 253 "--cc-out-dir", |
243 rel_cc_out_dir, | 254 rel_cc_out_dir, |
244 ] | 255 ] |
245 if (defined(invoker.cc_generator_options)) { | 256 if (defined(invoker.cc_generator_options)) { |
246 args += [ | 257 args += [ |
247 "--cc-options", | 258 "--cc-options", |
248 invoker.cc_generator_options, | 259 invoker.cc_generator_options, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 deps += [ plugin_host_label ] | 298 deps += [ plugin_host_label ] |
288 } | 299 } |
289 if (defined(invoker.deps)) { | 300 if (defined(invoker.deps)) { |
290 # The deps may have steps that have to run before running protoc. | 301 # The deps may have steps that have to run before running protoc. |
291 deps += invoker.deps | 302 deps += invoker.deps |
292 } | 303 } |
293 } | 304 } |
294 | 305 |
295 # Option to disable building a library in component build. | 306 # Option to disable building a library in component build. |
296 if (defined(invoker.component_build_force_source_set) && | 307 if (defined(invoker.component_build_force_source_set) && |
297 invoker.component_build_force_source_set && | 308 invoker.component_build_force_source_set && is_component_build) { |
298 is_component_build) { | |
299 link_target_type = "source_set" | 309 link_target_type = "source_set" |
300 } else { | 310 } else { |
301 link_target_type = "static_library" | 311 link_target_type = "static_library" |
302 } | 312 } |
303 | 313 |
304 # Generated files may include other generated headers. These includes always | 314 # Generated files may include other generated headers. These includes always |
305 # use relative paths starting at |cc_out_dir|. | 315 # use relative paths starting at |cc_out_dir|. |
306 # However there is no necessity to add an additional directory, if all protos | 316 # However there is no necessity to add an additional directory, if all protos |
307 # are located in the same directory which is in the search path by default. | 317 # are located in the same directory which is in the search path by default. |
308 if (has_nested_dirs) { | 318 if (has_nested_dirs) { |
309 config_name = "${target_name}_config" | 319 config_name = "${target_name}_config" |
310 config(config_name) { | 320 config(config_name) { |
311 include_dirs = [ cc_out_dir ] | 321 include_dirs = [ cc_out_dir ] |
312 } | 322 } |
313 } | 323 } |
314 | 324 |
315 # Build generated protobuf stubs as libary or source set. | 325 # Build generated protobuf stubs as libary or source set. |
316 target(link_target_type, target_name) { | 326 target(link_target_type, target_name) { |
317 forward_variables_from(invoker, | 327 forward_variables_from(invoker, |
318 [ | 328 [ |
319 "defines", | 329 "defines", |
330 "include_dirs", | |
sdefresne
2016/10/06 15:08:46
I think this is incorrect as dependent target will
Olivier
2016/10/06 16:36:31
Done.
| |
320 "testonly", | 331 "testonly", |
321 "visibility", | 332 "visibility", |
322 ]) | 333 ]) |
323 | 334 |
324 sources = get_target_outputs(":$action_name") | 335 sources = get_target_outputs(":$action_name") |
325 | 336 |
326 if (defined(invoker.extra_configs)) { | 337 if (defined(invoker.extra_configs)) { |
327 configs += invoker.extra_configs | 338 configs += invoker.extra_configs |
328 } | 339 } |
329 | 340 |
(...skipping 21 matching lines...) Expand all Loading... | |
351 ":$action_name", | 362 ":$action_name", |
352 ] | 363 ] |
353 | 364 |
354 # This will link any libraries in the deps (the use of invoker.deps in the | 365 # This will link any libraries in the deps (the use of invoker.deps in the |
355 # action won't link it). | 366 # action won't link it). |
356 if (defined(invoker.deps)) { | 367 if (defined(invoker.deps)) { |
357 deps += invoker.deps | 368 deps += invoker.deps |
358 } | 369 } |
359 } | 370 } |
360 } | 371 } |
OLD | NEW |