Chromium Code Reviews| 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 # Specifies the path of an additionnal directory to find imported | |
|
sdefresne
2016/10/04 11:29:55
I would make this an optional list (to allow addin
Olivier
2016/10/04 12:44:31
Done.
| |
| 24 # protos. | |
| 25 # | |
| 22 # generate_python (optional, default true) | 26 # generate_python (optional, default true) |
| 23 # Generate Python protobuf stubs. | 27 # Generate Python protobuf stubs. |
| 24 # | 28 # |
| 25 # generate_cc (optional, default true) | 29 # generate_cc (optional, default true) |
| 26 # Generate C++ protobuf stubs. | 30 # Generate C++ protobuf stubs. |
| 27 # | 31 # |
| 28 # cc_generator_options (optional) | 32 # cc_generator_options (optional) |
| 29 # List of extra flags passed to the protocol compiler. If you need to | 33 # 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 | 34 # add an EXPORT macro to a protobuf's C++ header, set the |
| 31 # 'cc_generator_options' variable with the value: | 35 # '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") | 233 protoc_out_dir = get_label_info(protoc_label, "root_out_dir") |
| 230 args += [ | 234 args += [ |
| 231 # Wrapper should never pick a system protoc. | 235 # Wrapper should never pick a system protoc. |
| 232 # Path should be rebased because |root_build_dir| for current toolchain | 236 # 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. | 237 # may be different from |root_out_dir| of protoc built on host toolchain. |
| 234 "--protoc", | 238 "--protoc", |
| 235 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc", | 239 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc", |
| 236 "--proto-in-dir", | 240 "--proto-in-dir", |
| 237 rebase_path(proto_in_dir, root_build_dir), | 241 rebase_path(proto_in_dir, root_build_dir), |
| 238 ] | 242 ] |
| 243 if (defined(invoker.proto_path)) { | |
| 244 args += [ | |
|
sdefresne
2016/10/04 11:29:55
If using a list as recommended, then you would nee
Olivier
2016/10/04 12:44:31
Done.
| |
| 245 "--proto-path", | |
| 246 "./" + rebase_path(invoker.proto_path, root_build_dir), | |
|
sdefresne
2016/10/04 11:29:55
I think you can remove this "./".
Olivier
2016/10/04 12:44:31
Done.
| |
| 247 ] | |
| 248 } | |
| 239 | 249 |
| 240 if (generate_cc) { | 250 if (generate_cc) { |
| 241 args += [ | 251 args += [ |
| 242 "--cc-out-dir", | 252 "--cc-out-dir", |
| 243 rel_cc_out_dir, | 253 rel_cc_out_dir, |
| 244 ] | 254 ] |
| 245 if (defined(invoker.cc_generator_options)) { | 255 if (defined(invoker.cc_generator_options)) { |
| 246 args += [ | 256 args += [ |
| 247 "--cc-options", | 257 "--cc-options", |
| 248 invoker.cc_generator_options, | 258 invoker.cc_generator_options, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 deps += [ plugin_host_label ] | 297 deps += [ plugin_host_label ] |
| 288 } | 298 } |
| 289 if (defined(invoker.deps)) { | 299 if (defined(invoker.deps)) { |
| 290 # The deps may have steps that have to run before running protoc. | 300 # The deps may have steps that have to run before running protoc. |
| 291 deps += invoker.deps | 301 deps += invoker.deps |
| 292 } | 302 } |
| 293 } | 303 } |
| 294 | 304 |
| 295 # Option to disable building a library in component build. | 305 # Option to disable building a library in component build. |
| 296 if (defined(invoker.component_build_force_source_set) && | 306 if (defined(invoker.component_build_force_source_set) && |
| 297 invoker.component_build_force_source_set && | 307 invoker.component_build_force_source_set && is_component_build) { |
| 298 is_component_build) { | |
| 299 link_target_type = "source_set" | 308 link_target_type = "source_set" |
| 300 } else { | 309 } else { |
| 301 link_target_type = "static_library" | 310 link_target_type = "static_library" |
| 302 } | 311 } |
| 303 | 312 |
| 304 # Generated files may include other generated headers. These includes always | 313 # Generated files may include other generated headers. These includes always |
| 305 # use relative paths starting at |cc_out_dir|. | 314 # use relative paths starting at |cc_out_dir|. |
| 306 # However there is no necessity to add an additional directory, if all protos | 315 # 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. | 316 # are located in the same directory which is in the search path by default. |
| 308 if (has_nested_dirs) { | 317 if (has_nested_dirs) { |
| 309 config_name = "${target_name}_config" | 318 config_name = "${target_name}_config" |
| 310 config(config_name) { | 319 config(config_name) { |
| 311 include_dirs = [ cc_out_dir ] | 320 include_dirs = [ cc_out_dir ] |
| 312 } | 321 } |
| 313 } | 322 } |
| 314 | 323 |
| 315 # Build generated protobuf stubs as libary or source set. | 324 # Build generated protobuf stubs as libary or source set. |
| 316 target(link_target_type, target_name) { | 325 target(link_target_type, target_name) { |
| 317 forward_variables_from(invoker, | 326 forward_variables_from(invoker, |
| 318 [ | 327 [ |
| 319 "defines", | 328 "defines", |
| 329 "include_dirs", | |
| 320 "testonly", | 330 "testonly", |
| 321 "visibility", | 331 "visibility", |
| 322 ]) | 332 ]) |
| 323 | 333 |
| 324 sources = get_target_outputs(":$action_name") | 334 sources = get_target_outputs(":$action_name") |
| 325 | 335 |
| 326 if (defined(invoker.extra_configs)) { | 336 if (defined(invoker.extra_configs)) { |
| 327 configs += invoker.extra_configs | 337 configs += invoker.extra_configs |
| 328 } | 338 } |
| 329 | 339 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 351 ":$action_name", | 361 ":$action_name", |
| 352 ] | 362 ] |
| 353 | 363 |
| 354 # This will link any libraries in the deps (the use of invoker.deps in the | 364 # This will link any libraries in the deps (the use of invoker.deps in the |
| 355 # action won't link it). | 365 # action won't link it). |
| 356 if (defined(invoker.deps)) { | 366 if (defined(invoker.deps)) { |
| 357 deps += invoker.deps | 367 deps += invoker.deps |
| 358 } | 368 } |
| 359 } | 369 } |
| 360 } | 370 } |
| OLD | NEW |