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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 # generator_plugin_suffix[es] (required if using a plugin) | 52 # generator_plugin_suffix[es] (required if using a plugin) |
53 # Suffix (before extension) for generated .cc and .h files | 53 # Suffix (before extension) for generated .cc and .h files |
54 # or list of suffixes for all files (with extensions). | 54 # or list of suffixes for all files (with extensions). |
55 # | 55 # |
56 # generator_plugin_options (optional) | 56 # generator_plugin_options (optional) |
57 # Extra flags passed to the plugin. See cc_generator_options. | 57 # Extra flags passed to the plugin. See cc_generator_options. |
58 # | 58 # |
59 # deps (optional) | 59 # deps (optional) |
60 # Additional dependencies. | 60 # Additional dependencies. |
61 # | 61 # |
62 # use_protobuf_full (optional) | |
63 # If adding protobuf library would be required, adds protobuf_full to deps | |
64 # instead of protobuf_lite. | |
Peter Kasting
2016/11/26 05:44:17
Nit: Maybe clearer:
Adds protobuf_full to the dep
| |
65 # | |
62 # Parameters for compiling the generated code: | 66 # Parameters for compiling the generated code: |
63 # | 67 # |
64 # component_build_force_source_set (Default=false) | 68 # component_build_force_source_set (Default=false) |
65 # When set true the generated code will be compiled as a source set in | 69 # When set true the generated code will be compiled as a source set in |
66 # the component build. This does not affect static builds. If you are | 70 # the component build. This does not affect static builds. If you are |
67 # exporting symbols from a component, this is required to prevent those | 71 # exporting symbols from a component, this is required to prevent those |
68 # symbols from being stripped. If you're not using dllexports in | 72 # symbols from being stripped. If you're not using dllexports in |
69 # cc_generator_options, it's usually best to leave this false. | 73 # cc_generator_options, it's usually best to leave this false. |
70 # | 74 # |
71 # defines (optional) | 75 # defines (optional) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 } else { | 114 } else { |
111 generate_python = true | 115 generate_python = true |
112 } | 116 } |
113 | 117 |
114 if (defined(invoker.generator_plugin_label)) { | 118 if (defined(invoker.generator_plugin_label)) { |
115 # Straightforward way to get the name of executable doesn't work because | 119 # Straightforward way to get the name of executable doesn't work because |
116 # |root_out_dir| and |root_build_dir| may differ in cross-compilation and | 120 # |root_out_dir| and |root_build_dir| may differ in cross-compilation and |
117 # also Windows executables have .exe at the end. | 121 # also Windows executables have .exe at the end. |
118 | 122 |
119 plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)" | 123 plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)" |
120 plugin_path = get_label_info(plugin_host_label, "root_out_dir") + "/" + | 124 plugin_path = |
121 get_label_info(plugin_host_label, "name") + | 125 get_label_info(plugin_host_label, "root_out_dir") + "/" + |
122 host_executable_suffix | 126 get_label_info(plugin_host_label, "name") + host_executable_suffix |
123 generate_with_plugin = true | 127 generate_with_plugin = true |
124 } else if (defined(invoker.generator_plugin_script)) { | 128 } else if (defined(invoker.generator_plugin_script)) { |
125 plugin_path = invoker.generator_plugin_script | 129 plugin_path = invoker.generator_plugin_script |
126 generate_with_plugin = true | 130 generate_with_plugin = true |
127 } else { | 131 } else { |
128 generate_with_plugin = false | 132 generate_with_plugin = false |
129 } | 133 } |
130 | 134 |
131 if (generate_with_plugin) { | 135 if (generate_with_plugin) { |
132 if (defined(invoker.generator_plugin_suffix)) { | 136 if (defined(invoker.generator_plugin_suffix)) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 } | 298 } |
295 | 299 |
296 if (defined(invoker.deps)) { | 300 if (defined(invoker.deps)) { |
297 # 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. |
298 deps += invoker.deps | 302 deps += invoker.deps |
299 } | 303 } |
300 } | 304 } |
301 | 305 |
302 # Option to disable building a library in component build. | 306 # Option to disable building a library in component build. |
303 if (defined(invoker.component_build_force_source_set) && | 307 if (defined(invoker.component_build_force_source_set) && |
304 invoker.component_build_force_source_set && | 308 invoker.component_build_force_source_set && is_component_build) { |
305 is_component_build) { | |
306 link_target_type = "source_set" | 309 link_target_type = "source_set" |
307 } else { | 310 } else { |
308 link_target_type = "static_library" | 311 link_target_type = "static_library" |
309 } | 312 } |
310 | 313 |
311 # Generated files may include other generated headers. These includes always | 314 # Generated files may include other generated headers. These includes always |
312 # use relative paths starting at |cc_out_dir|. | 315 # use relative paths starting at |cc_out_dir|. |
313 # 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 |
314 # 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. |
315 if (has_nested_dirs) { | 318 if (has_nested_dirs) { |
(...skipping 25 matching lines...) Expand all Loading... | |
341 if (has_nested_dirs) { | 344 if (has_nested_dirs) { |
342 # It's not enough to set |include_dirs| for target since public imports | 345 # It's not enough to set |include_dirs| for target since public imports |
343 # expose corresponding includes to header files as well. | 346 # expose corresponding includes to header files as well. |
344 public_configs += [ ":$config_name" ] | 347 public_configs += [ ":$config_name" ] |
345 } | 348 } |
346 | 349 |
347 # If using built-in cc generator, the resulting headers reference headers | 350 # If using built-in cc generator, the resulting headers reference headers |
348 # within protobuf_lite. Hence, dependencies require those headers too. | 351 # within protobuf_lite. Hence, dependencies require those headers too. |
349 # If using generator plugin, extra deps should be resolved by the invoker. | 352 # If using generator plugin, extra deps should be resolved by the invoker. |
350 if (generate_cc) { | 353 if (generate_cc) { |
351 public_deps = [ | 354 if (defined(invoker.use_protobuf_full) && |
352 "//third_party/protobuf:protobuf_lite", | 355 invoker.use_protobuf_full == true) { |
353 ] | 356 public_deps = [ |
357 "//third_party/protobuf:protobuf_full", | |
358 ] | |
359 } else { | |
360 public_deps = [ | |
361 "//third_party/protobuf:protobuf_lite", | |
362 ] | |
363 } | |
354 } | 364 } |
355 } | 365 } |
356 | 366 |
357 deps = [ | 367 deps = [ |
358 ":$action_name", | 368 ":$action_name", |
359 ] | 369 ] |
360 | 370 |
361 # This will link any libraries in the deps (the use of invoker.deps in the | 371 # This will link any libraries in the deps (the use of invoker.deps in the |
362 # action won't link it). | 372 # action won't link it). |
363 if (defined(invoker.deps)) { | 373 if (defined(invoker.deps)) { |
364 deps += invoker.deps | 374 deps += invoker.deps |
365 } | 375 } |
366 } | 376 } |
367 } | 377 } |
OLD | NEW |