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

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

Issue 2343833002: Remove workaround from GN proto_library. (Closed)
Patch Set: nit Created 4 years, 3 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 | « third_party/dom_distiller_js/BUILD.gn ('k') | 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 25 matching lines...) Expand all
36 # component_build_force_source_set = true. 36 # component_build_force_source_set = true.
37 # 37 #
38 # cc_include (optional) 38 # cc_include (optional)
39 # String listing an extra include that should be passed. 39 # String listing an extra include that should be passed.
40 # Example: cc_include = "foo/bar.h" 40 # Example: cc_include = "foo/bar.h"
41 # 41 #
42 # generator_plugin_label (optional) 42 # generator_plugin_label (optional)
43 # GN label for plugin executable which generates custom cc stubs. 43 # GN label for plugin executable which generates custom cc stubs.
44 # Don't specify a toolchain, host toolchain is assumed. 44 # Don't specify a toolchain, host toolchain is assumed.
45 # 45 #
46 # generator_plugin_suffix (required if |generator_plugin_label| set) 46 # generator_plugin_script (optional)
47 # Suffix (before extension) for generated .cc and .h files. 47 # Path to plugin script. Mutual exclusive with |generator_plugin_label|.
xyzzyz 2016/09/15 18:09:01 Mutually?
kraynov 2016/09/16 09:33:14 Done.
48 #
49 # generator_plugin_script_deps (optional)
50 # List of additional files required for generator plugin script.
51 #
52 # generator_plugin_suffix[es] (required if using a plugin)
wychen 2016/09/15 18:40:39 Nice touch!
kraynov 2016/09/16 09:33:14 Acknowledged.
53 # Suffix (before extension) for generated .cc and .h files
54 # or list of suffixes for all files (with extensions).
48 # 55 #
49 # generator_plugin_options (optional) 56 # generator_plugin_options (optional)
50 # Extra flags passed to the plugin. See cc_generator_options. 57 # Extra flags passed to the plugin. See cc_generator_options.
51 # 58 #
52 # deps (optional) 59 # deps (optional)
53 # Additional dependencies. 60 # Additional dependencies.
54 # 61 #
55 # Parameters for compiling the generated code: 62 # Parameters for compiling the generated code:
56 # 63 #
57 # component_build_force_source_set (Default=false) 64 # component_build_force_source_set (Default=false)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 generate_cc = true 99 generate_cc = true
93 } 100 }
94 101
95 if (defined(invoker.generate_python)) { 102 if (defined(invoker.generate_python)) {
96 generate_python = invoker.generate_python 103 generate_python = invoker.generate_python
97 } else { 104 } else {
98 generate_python = true 105 generate_python = true
99 } 106 }
100 107
101 if (defined(invoker.generator_plugin_label)) { 108 if (defined(invoker.generator_plugin_label)) {
102 generator_plugin_label = invoker.generator_plugin_label
103 generator_plugin_suffix = invoker.generator_plugin_suffix
104 generate_with_plugin = true
105
106 # 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
107 # |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
108 # also Windows executables have .exe at the end. 111 # also Windows executables have .exe at the end.
109 112
110 plugin_host_label = generator_plugin_label + "($host_toolchain)" 113 plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)"
111 plugin_path = get_label_info(plugin_host_label, "root_out_dir") + "/" + 114 plugin_path = get_label_info(plugin_host_label, "root_out_dir") + "/" +
112 get_label_info(plugin_host_label, "name") 115 get_label_info(plugin_host_label, "name")
113 if (host_os == "win") { 116 if (host_os == "win") {
114 plugin_path += ".exe" 117 plugin_path += ".exe"
115 } 118 }
116 plugin_path = rebase_path(plugin_path, root_build_dir) 119 generate_with_plugin = true
120 } else if (defined(invoker.generator_plugin_script)) {
121 plugin_path = invoker.generator_plugin_script
122 generate_with_plugin = true
117 } else { 123 } else {
118 generate_with_plugin = false 124 generate_with_plugin = false
119 } 125 }
120 126
121 # TODO(kraynov): Remove (in the next CL) merge conflict temporary workaround. 127 if (generate_with_plugin) {
122 # This option along with |inputs| would be replaced by the following pattern: 128 if (defined(invoker.generator_plugin_suffix)) {
123 # source_set("some_python_plugin") { 129 generator_plugin_suffixes = [
124 # sources = [ 130 "${invoker.generator_plugin_suffix}.h",
125 # "bar.py", 131 "${invoker.generator_plugin_suffix}.cc",
126 # ... 132 ]
127 # ] 133 } else {
128 # } 134 generator_plugin_suffixes = invoker.generator_plugin_suffixes
129 # proto_library("some_proto_lib") { 135 }
130 # generator_plugin_label = ":some_python_plugin" 136 plugin_path = rebase_path(plugin_path, root_build_dir)
131 # generator_plugin_suffix = ".pb.foo"
132 # generator_plugin_script = "bar.py"
133 # }
134 if (defined(invoker.json_converter)) {
135 generator_plugin_suffix = "_json_converter"
136 plugin_path = rebase_path(invoker.json_converter)
137 invoker.generator_plugin_options = "output_dir=:"
138 generate_with_plugin = true
139 } 137 }
140 138
141 if (defined(invoker.proto_in_dir)) { 139 if (defined(invoker.proto_in_dir)) {
142 proto_in_dir = invoker.proto_in_dir 140 proto_in_dir = invoker.proto_in_dir
143 has_nested_dirs = false 141 has_nested_dirs = false
144 foreach(proto_source, proto_sources) { 142 foreach(proto_source, proto_sources) {
145 if (get_path_info(proto_source, "dir") != proto_in_dir) { 143 if (get_path_info(proto_source, "dir") != proto_in_dir) {
146 has_nested_dirs = true 144 has_nested_dirs = true
147 } 145 }
148 } 146 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (generate_cc) { 192 if (generate_cc) {
195 protogens += [ 193 protogens += [
196 "$cc_out_dir/$proto_path.pb.h", 194 "$cc_out_dir/$proto_path.pb.h",
197 "$cc_out_dir/$proto_path.pb.cc", 195 "$cc_out_dir/$proto_path.pb.cc",
198 ] 196 ]
199 } 197 }
200 if (generate_python) { 198 if (generate_python) {
201 protogens += [ "$py_out_dir/${proto_path}_pb2.py" ] 199 protogens += [ "$py_out_dir/${proto_path}_pb2.py" ]
202 } 200 }
203 if (generate_with_plugin) { 201 if (generate_with_plugin) {
204 # TODO(kraynov): Remove merge conflict temporary workaround. 202 foreach(suffix, generator_plugin_suffixes) {
205 if (defined(invoker.json_converter)) { 203 protogens += [ "$cc_out_dir/${proto_path}${suffix}" ]
206 protogens += [ "$cc_out_dir/${proto_path}$generator_plugin_suffix.h" ]
207 } else {
208 protogens += [
209 "$cc_out_dir/${proto_path}$generator_plugin_suffix.h",
210 "$cc_out_dir/${proto_path}$generator_plugin_suffix.cc",
211 ]
212 } 204 }
213 } 205 }
214 } 206 }
215 207
216 action_name = "${target_name}_gen" 208 action_name = "${target_name}_gen"
217 source_set_name = target_name 209 source_set_name = target_name
218 210
219 # Generate protobuf stubs. 211 # Generate protobuf stubs.
220 action(action_name) { 212 action(action_name) {
221 visibility = [ ":$source_set_name" ] 213 visibility = [ ":$source_set_name" ]
222 script = "//tools/protoc_wrapper/protoc_wrapper.py" 214 script = "//tools/protoc_wrapper/protoc_wrapper.py"
223 sources = proto_sources 215 sources = proto_sources
224 outputs = get_path_info(protogens, "abspath") 216 outputs = get_path_info(protogens, "abspath")
225 args = protos 217 args = protos
226 218
227 if (defined(invoker.inputs)) { 219 if (defined(invoker.generator_plugin_script)) {
228 inputs = invoker.inputs 220 inputs = [ invoker.generator_plugin_script ]
221 }
222 if (defined(invoker.generator_plugin_script_deps)) {
223 inputs += invoker.generator_plugin_script_deps
229 } 224 }
230 225
231 protoc_label = "//third_party/protobuf:protoc($host_toolchain)" 226 protoc_label = "//third_party/protobuf:protoc($host_toolchain)"
232 protoc_out_dir = get_label_info(protoc_label, "root_out_dir") 227 protoc_out_dir = get_label_info(protoc_label, "root_out_dir")
233 args += [ 228 args += [
234 # Wrapper should never pick a system protoc. 229 # Wrapper should never pick a system protoc.
235 # Path should be rebased because |root_build_dir| for current toolchain 230 # Path should be rebased because |root_build_dir| for current toolchain
236 # may be different from |root_out_dir| of protoc built on host toolchain. 231 # may be different from |root_out_dir| of protoc built on host toolchain.
237 "--protoc", 232 "--protoc",
238 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc", 233 "./" + rebase_path(protoc_out_dir, root_build_dir) + "/protoc",
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 ":$action_name", 349 ":$action_name",
355 ] 350 ]
356 351
357 # This will link any libraries in the deps (the use of invoker.deps in the 352 # This will link any libraries in the deps (the use of invoker.deps in the
358 # action won't link it). 353 # action won't link it).
359 if (defined(invoker.deps)) { 354 if (defined(invoker.deps)) {
360 deps += invoker.deps 355 deps += invoker.deps
361 } 356 }
362 } 357 }
363 } 358 }
OLDNEW
« no previous file with comments | « third_party/dom_distiller_js/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698