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 # 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) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 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 |
| 330 public_configs = [ "//third_party/protobuf:using_proto" ] | 340 if (!defined(invoker.public_configs)) { |
|
sdefresne
2016/10/06 16:44:44
The pattern we usually use is the following:
forw
| |
| 341 public_configs = [] | |
| 342 } else { | |
| 343 public_configs = invoker.public_configs | |
| 344 } | |
| 345 | |
| 346 public_configs += [ "//third_party/protobuf:using_proto" ] | |
| 331 | 347 |
| 332 if (generate_cc || generate_with_plugin) { | 348 if (generate_cc || generate_with_plugin) { |
| 333 # Not necessary if all protos are located in the same directory. | 349 # Not necessary if all protos are located in the same directory. |
| 334 if (has_nested_dirs) { | 350 if (has_nested_dirs) { |
| 335 # It's not enough to set |include_dirs| for target since public imports | 351 # It's not enough to set |include_dirs| for target since public imports |
| 336 # expose corresponding includes to header files as well. | 352 # expose corresponding includes to header files as well. |
| 337 public_configs += [ ":$config_name" ] | 353 public_configs += [ ":$config_name" ] |
| 338 } | 354 } |
| 339 | 355 |
| 340 # If using built-in cc generator, the resulting headers reference headers | 356 # If using built-in cc generator, the resulting headers reference headers |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 351 ":$action_name", | 367 ":$action_name", |
| 352 ] | 368 ] |
| 353 | 369 |
| 354 # This will link any libraries in the deps (the use of invoker.deps in the | 370 # This will link any libraries in the deps (the use of invoker.deps in the |
| 355 # action won't link it). | 371 # action won't link it). |
| 356 if (defined(invoker.deps)) { | 372 if (defined(invoker.deps)) { |
| 357 deps += invoker.deps | 373 deps += invoker.deps |
| 358 } | 374 } |
| 359 } | 375 } |
| 360 } | 376 } |
| OLD | NEW |