Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: third_party/protobuf/proto_library.gni

Issue 2427943002: Explicit dependency on executables in proto_library.gni. (Closed)
Patch Set: never system protoc Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 template("proto_library") { 86 template("proto_library") {
87 assert(defined(invoker.sources), "Need sources for proto_library") 87 assert(defined(invoker.sources), "Need sources for proto_library")
88 proto_sources = invoker.sources 88 proto_sources = invoker.sources
89 89
90 # Don't apply OS-specific sources filtering to the assignments later on. 90 # Don't apply OS-specific sources filtering to the assignments later on.
91 # Platform files should have gotten filtered out in the sources assignment 91 # Platform files should have gotten filtered out in the sources assignment
92 # when this template was invoked. If they weren't, it was on purpose and 92 # when this template was invoked. If they weren't, it was on purpose and
93 # this template shouldn't re-apply the filter. 93 # this template shouldn't re-apply the filter.
94 set_sources_assignment_filter([]) 94 set_sources_assignment_filter([])
95 95
96 if (host_os == "win") {
97 host_executable_suffix = ".exe"
98 } else {
99 host_executable_suffix = ""
100 }
101
96 if (defined(invoker.generate_cc)) { 102 if (defined(invoker.generate_cc)) {
97 generate_cc = invoker.generate_cc 103 generate_cc = invoker.generate_cc
98 } else { 104 } else {
99 generate_cc = true 105 generate_cc = true
100 } 106 }
101 107
102 if (defined(invoker.generate_python)) { 108 if (defined(invoker.generate_python)) {
103 generate_python = invoker.generate_python 109 generate_python = invoker.generate_python
104 } else { 110 } else {
105 generate_python = true 111 generate_python = true
106 } 112 }
107 113
108 if (defined(invoker.generator_plugin_label)) { 114 if (defined(invoker.generator_plugin_label)) {
109 # Straightforward way to get the name of executable doesn't work because 115 # 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 116 # |root_out_dir| and |root_build_dir| may differ in cross-compilation and
111 # also Windows executables have .exe at the end. 117 # also Windows executables have .exe at the end.
112 118
113 plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)" 119 plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)"
114 plugin_path = get_label_info(plugin_host_label, "root_out_dir") + "/" + 120 plugin_path = get_label_info(plugin_host_label, "root_out_dir") + "/" +
115 get_label_info(plugin_host_label, "name") 121 get_label_info(plugin_host_label, "name") +
116 if (host_os == "win") { 122 host_executable_suffix
117 plugin_path += ".exe"
118 }
119 generate_with_plugin = true 123 generate_with_plugin = true
120 } else if (defined(invoker.generator_plugin_script)) { 124 } else if (defined(invoker.generator_plugin_script)) {
121 plugin_path = invoker.generator_plugin_script 125 plugin_path = invoker.generator_plugin_script
122 generate_with_plugin = true 126 generate_with_plugin = true
123 } else { 127 } else {
124 generate_with_plugin = false 128 generate_with_plugin = false
125 } 129 }
126 130
127 if (generate_with_plugin) { 131 if (generate_with_plugin) {
128 if (defined(invoker.generator_plugin_suffix)) { 132 if (defined(invoker.generator_plugin_suffix)) {
129 generator_plugin_suffixes = [ 133 generator_plugin_suffixes = [
130 "${invoker.generator_plugin_suffix}.h", 134 "${invoker.generator_plugin_suffix}.h",
131 "${invoker.generator_plugin_suffix}.cc", 135 "${invoker.generator_plugin_suffix}.cc",
132 ] 136 ]
133 } else { 137 } else {
134 generator_plugin_suffixes = invoker.generator_plugin_suffixes 138 generator_plugin_suffixes = invoker.generator_plugin_suffixes
135 } 139 }
136 plugin_path = rebase_path(plugin_path, root_build_dir)
137 } 140 }
138 141
139 if (defined(invoker.proto_in_dir)) { 142 if (defined(invoker.proto_in_dir)) {
140 proto_in_dir = invoker.proto_in_dir 143 proto_in_dir = invoker.proto_in_dir
141 has_nested_dirs = false 144 has_nested_dirs = false
142 foreach(proto_source, proto_sources) { 145 foreach(proto_source, proto_sources) {
143 if (get_path_info(proto_source, "dir") != proto_in_dir) { 146 if (get_path_info(proto_source, "dir") != proto_in_dir) {
144 has_nested_dirs = true 147 has_nested_dirs = true
145 } 148 }
146 } 149 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 source_set_name = target_name 212 source_set_name = target_name
210 213
211 # Generate protobuf stubs. 214 # Generate protobuf stubs.
212 action(action_name) { 215 action(action_name) {
213 visibility = [ ":$source_set_name" ] 216 visibility = [ ":$source_set_name" ]
214 script = "//tools/protoc_wrapper/protoc_wrapper.py" 217 script = "//tools/protoc_wrapper/protoc_wrapper.py"
215 sources = proto_sources 218 sources = proto_sources
216 outputs = get_path_info(protogens, "abspath") 219 outputs = get_path_info(protogens, "abspath")
217 args = protos 220 args = protos
218 221
219 if (defined(invoker.generator_plugin_script)) {
220 inputs = [
221 invoker.generator_plugin_script,
222 ]
223 }
224 if (defined(invoker.generator_plugin_script_deps)) {
225 inputs += invoker.generator_plugin_script_deps
226 }
227
228 protoc_label = "//third_party/protobuf:protoc($host_toolchain)" 222 protoc_label = "//third_party/protobuf:protoc($host_toolchain)"
229 protoc_out_dir = get_label_info(protoc_label, "root_out_dir") 223 protoc_path = get_label_info(protoc_label, "root_out_dir") + "/protoc" +
224 host_executable_suffix
230 args += [ 225 args += [
231 # Wrapper should never pick a system protoc. 226 # Wrapper should never pick a system protoc.
232 # Path should be rebased because |root_build_dir| for current toolchain 227 # 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. 228 # may be different from |root_out_dir| of protoc built on host toolchain.
234 "--protoc", 229 "--protoc",
235 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc", 230 "./" + rebase_path(protoc_path, root_build_dir),
236 "--proto-in-dir", 231 "--proto-in-dir",
237 rebase_path(proto_in_dir, root_build_dir), 232 rebase_path(proto_in_dir, root_build_dir),
238 ] 233 ]
239 234
240 if (generate_cc) { 235 if (generate_cc) {
241 args += [ 236 args += [
242 "--cc-out-dir", 237 "--cc-out-dir",
243 rel_cc_out_dir, 238 rel_cc_out_dir,
244 ] 239 ]
245 if (defined(invoker.cc_generator_options)) { 240 if (defined(invoker.cc_generator_options)) {
(...skipping 13 matching lines...) Expand all
259 if (generate_python) { 254 if (generate_python) {
260 args += [ 255 args += [
261 "--py-out-dir", 256 "--py-out-dir",
262 rel_py_out_dir, 257 rel_py_out_dir,
263 ] 258 ]
264 } 259 }
265 260
266 if (generate_with_plugin) { 261 if (generate_with_plugin) {
267 args += [ 262 args += [
268 "--plugin", 263 "--plugin",
269 plugin_path, 264 rebase_path(plugin_path, root_build_dir),
270 "--plugin-out-dir", 265 "--plugin-out-dir",
271 rel_cc_out_dir, 266 rel_cc_out_dir,
272 ] 267 ]
273 if (defined(invoker.generator_plugin_options)) { 268 if (defined(invoker.generator_plugin_options)) {
274 args += [ 269 args += [
275 "--plugin-options", 270 "--plugin-options",
276 invoker.generator_plugin_options, 271 invoker.generator_plugin_options,
277 ] 272 ]
278 } 273 }
279 } 274 }
280 275
276 # System protoc is not used so it's necessary to build a chromium one.
277 inputs = [
278 protoc_path,
279 ]
281 deps = [ 280 deps = [
282 # System protoc is not used so it's necessary to build a chromium one.
283 protoc_label, 281 protoc_label,
284 ] 282 ]
285 if (defined(plugin_host_label)) { 283
286 # Action depends on generator plugin but for host toolchain only. 284 if (generate_with_plugin) {
287 deps += [ plugin_host_label ] 285 inputs += [ plugin_path ]
286 if (defined(invoker.generator_plugin_script_deps)) {
287 # Additional scripts for plugin.
288 inputs += invoker.generator_plugin_script_deps
289 }
290 if (defined(plugin_host_label)) {
291 # Action depends on native generator plugin but for host toolchain only.
292 deps += [ plugin_host_label ]
293 }
288 } 294 }
295
289 if (defined(invoker.deps)) { 296 if (defined(invoker.deps)) {
290 # The deps may have steps that have to run before running protoc. 297 # The deps may have steps that have to run before running protoc.
291 deps += invoker.deps 298 deps += invoker.deps
292 } 299 }
293 } 300 }
294 301
295 # Option to disable building a library in component build. 302 # Option to disable building a library in component build.
296 if (defined(invoker.component_build_force_source_set) && 303 if (defined(invoker.component_build_force_source_set) &&
297 invoker.component_build_force_source_set && 304 invoker.component_build_force_source_set &&
298 is_component_build) { 305 is_component_build) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 ":$action_name", 358 ":$action_name",
352 ] 359 ]
353 360
354 # This will link any libraries in the deps (the use of invoker.deps in the 361 # This will link any libraries in the deps (the use of invoker.deps in the
355 # action won't link it). 362 # action won't link it).
356 if (defined(invoker.deps)) { 363 if (defined(invoker.deps)) {
357 deps += invoker.deps 364 deps += invoker.deps
358 } 365 }
359 } 366 }
360 } 367 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698