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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 } | 106 } |
107 | 107 |
108 if (defined(invoker.generator_plugin_label)) { | 108 if (defined(invoker.generator_plugin_label)) { |
109 # Straightforward way to get the name of executable doesn't work because | 109 # Straightforward way to get the name of executable doesn't work because |
110 # |root_out_dir| and |root_build_dir| may differ in cross-compilation and | 110 # |root_out_dir| and |root_build_dir| may differ in cross-compilation and |
111 # also Windows executables have .exe at the end. | 111 # also Windows executables have .exe at the end. |
112 | 112 |
113 plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)" | 113 plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)" |
114 plugin_path = get_label_info(plugin_host_label, "root_out_dir") + "/" + | 114 plugin_path = get_label_info(plugin_host_label, "root_out_dir") + "/" + |
115 get_label_info(plugin_host_label, "name") | 115 get_label_info(plugin_host_label, "name") |
116 if (host_os == "win") { | 116 if (host_os == "win") { |
sdefresne
2016/10/18 22:44:54
This is done multiple time in this file. I would r
kraynov
2016/10/19 11:04:59
Done.
| |
117 plugin_path += ".exe" | 117 plugin_path += ".exe" |
118 } | 118 } |
119 generate_with_plugin = true | 119 generate_with_plugin = true |
120 } else if (defined(invoker.generator_plugin_script)) { | 120 } else if (defined(invoker.generator_plugin_script)) { |
121 plugin_path = invoker.generator_plugin_script | 121 plugin_path = invoker.generator_plugin_script |
122 generate_with_plugin = true | 122 generate_with_plugin = true |
123 } else { | 123 } else { |
124 generate_with_plugin = false | 124 generate_with_plugin = false |
125 } | 125 } |
126 | 126 |
127 if (generate_with_plugin) { | 127 if (generate_with_plugin) { |
128 if (defined(invoker.generator_plugin_suffix)) { | 128 if (defined(invoker.generator_plugin_suffix)) { |
129 generator_plugin_suffixes = [ | 129 generator_plugin_suffixes = [ |
130 "${invoker.generator_plugin_suffix}.h", | 130 "${invoker.generator_plugin_suffix}.h", |
131 "${invoker.generator_plugin_suffix}.cc", | 131 "${invoker.generator_plugin_suffix}.cc", |
132 ] | 132 ] |
133 } else { | 133 } else { |
134 generator_plugin_suffixes = invoker.generator_plugin_suffixes | 134 generator_plugin_suffixes = invoker.generator_plugin_suffixes |
135 } | 135 } |
136 plugin_path = rebase_path(plugin_path, root_build_dir) | |
137 } | 136 } |
138 | 137 |
139 if (defined(invoker.proto_in_dir)) { | 138 if (defined(invoker.proto_in_dir)) { |
140 proto_in_dir = invoker.proto_in_dir | 139 proto_in_dir = invoker.proto_in_dir |
141 has_nested_dirs = false | 140 has_nested_dirs = false |
142 foreach(proto_source, proto_sources) { | 141 foreach(proto_source, proto_sources) { |
143 if (get_path_info(proto_source, "dir") != proto_in_dir) { | 142 if (get_path_info(proto_source, "dir") != proto_in_dir) { |
144 has_nested_dirs = true | 143 has_nested_dirs = true |
145 } | 144 } |
146 } | 145 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 source_set_name = target_name | 208 source_set_name = target_name |
210 | 209 |
211 # Generate protobuf stubs. | 210 # Generate protobuf stubs. |
212 action(action_name) { | 211 action(action_name) { |
213 visibility = [ ":$source_set_name" ] | 212 visibility = [ ":$source_set_name" ] |
214 script = "//tools/protoc_wrapper/protoc_wrapper.py" | 213 script = "//tools/protoc_wrapper/protoc_wrapper.py" |
215 sources = proto_sources | 214 sources = proto_sources |
216 outputs = get_path_info(protogens, "abspath") | 215 outputs = get_path_info(protogens, "abspath") |
217 args = protos | 216 args = protos |
218 | 217 |
219 if (defined(invoker.generator_plugin_script)) { | 218 protoc_label = "//third_party/protobuf:protoc($host_toolchain)" |
220 inputs = [ | 219 protoc_path = get_label_info(protoc_label, "root_out_dir") + "/protoc" |
sdefresne
2016/10/18 22:44:54
protoc_path = get_label_info(protoc_label, "root_o
kraynov
2016/10/19 11:04:59
Done.
| |
221 invoker.generator_plugin_script, | 220 if (host_os == "win") { |
kraynov
2016/10/18 12:35:52
It's not missing :)
invoker.generator_plugin_scrip
sdefresne
2016/10/18 22:44:54
Ack.
| |
222 ] | 221 protoc_path += ".exe" |
223 } | |
224 if (defined(invoker.generator_plugin_script_deps)) { | |
225 inputs += invoker.generator_plugin_script_deps | |
226 } | 222 } |
227 | 223 |
228 protoc_label = "//third_party/protobuf:protoc($host_toolchain)" | |
229 protoc_out_dir = get_label_info(protoc_label, "root_out_dir") | |
230 args += [ | 224 args += [ |
231 # Wrapper should never pick a system protoc. | 225 # Wrapper should never pick a system protoc. |
232 # Path should be rebased because |root_build_dir| for current toolchain | 226 # 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. | 227 # may be different from |root_out_dir| of protoc built on host toolchain. |
234 "--protoc", | 228 "--protoc", |
235 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc", | 229 rebase_path(protoc_path, root_build_dir), |
236 "--proto-in-dir", | 230 "--proto-in-dir", |
237 rebase_path(proto_in_dir, root_build_dir), | 231 rebase_path(proto_in_dir, root_build_dir), |
238 ] | 232 ] |
239 | 233 |
240 if (generate_cc) { | 234 if (generate_cc) { |
241 args += [ | 235 args += [ |
242 "--cc-out-dir", | 236 "--cc-out-dir", |
243 rel_cc_out_dir, | 237 rel_cc_out_dir, |
244 ] | 238 ] |
245 if (defined(invoker.cc_generator_options)) { | 239 if (defined(invoker.cc_generator_options)) { |
(...skipping 13 matching lines...) Expand all Loading... | |
259 if (generate_python) { | 253 if (generate_python) { |
260 args += [ | 254 args += [ |
261 "--py-out-dir", | 255 "--py-out-dir", |
262 rel_py_out_dir, | 256 rel_py_out_dir, |
263 ] | 257 ] |
264 } | 258 } |
265 | 259 |
266 if (generate_with_plugin) { | 260 if (generate_with_plugin) { |
267 args += [ | 261 args += [ |
268 "--plugin", | 262 "--plugin", |
269 plugin_path, | 263 rebase_path(plugin_path, root_build_dir), |
270 "--plugin-out-dir", | 264 "--plugin-out-dir", |
271 rel_cc_out_dir, | 265 rel_cc_out_dir, |
272 ] | 266 ] |
273 if (defined(invoker.generator_plugin_options)) { | 267 if (defined(invoker.generator_plugin_options)) { |
274 args += [ | 268 args += [ |
275 "--plugin-options", | 269 "--plugin-options", |
276 invoker.generator_plugin_options, | 270 invoker.generator_plugin_options, |
277 ] | 271 ] |
278 } | 272 } |
279 } | 273 } |
280 | 274 |
275 # System protoc is not used so it's necessary to build a chromium one. | |
276 inputs = [ | |
277 protoc_path, | |
278 ] | |
281 deps = [ | 279 deps = [ |
282 # System protoc is not used so it's necessary to build a chromium one. | |
283 protoc_label, | 280 protoc_label, |
284 ] | 281 ] |
285 if (defined(plugin_host_label)) { | 282 |
286 # Action depends on generator plugin but for host toolchain only. | 283 if (generate_with_plugin) { |
287 deps += [ plugin_host_label ] | 284 inputs += [ plugin_path ] |
285 if (defined(invoker.generator_plugin_script_deps)) { | |
286 # Additional scripts for plugin. | |
287 inputs += invoker.generator_plugin_script_deps | |
288 } | |
289 if (defined(plugin_host_label)) { | |
290 # Action depends on native generator plugin but for host toolchain only. | |
291 deps += [ plugin_host_label ] | |
292 } | |
288 } | 293 } |
294 | |
289 if (defined(invoker.deps)) { | 295 if (defined(invoker.deps)) { |
290 # The deps may have steps that have to run before running protoc. | 296 # The deps may have steps that have to run before running protoc. |
291 deps += invoker.deps | 297 deps += invoker.deps |
292 } | 298 } |
293 } | 299 } |
294 | 300 |
295 # Option to disable building a library in component build. | 301 # Option to disable building a library in component build. |
296 if (defined(invoker.component_build_force_source_set) && | 302 if (defined(invoker.component_build_force_source_set) && |
297 invoker.component_build_force_source_set && | 303 invoker.component_build_force_source_set && |
298 is_component_build) { | 304 is_component_build) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 ":$action_name", | 357 ":$action_name", |
352 ] | 358 ] |
353 | 359 |
354 # This will link any libraries in the deps (the use of invoker.deps in the | 360 # This will link any libraries in the deps (the use of invoker.deps in the |
355 # action won't link it). | 361 # action won't link it). |
356 if (defined(invoker.deps)) { | 362 if (defined(invoker.deps)) { |
357 deps += invoker.deps | 363 deps += invoker.deps |
358 } | 364 } |
359 } | 365 } |
360 } | 366 } |
OLD | NEW |