1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
7 ['use_system_protobuf==0', {
12 '.', # crafted for gcc/linux.
14 }, { # else, OS=="win"
17 'vsprojects', # crafted for msvc.
20 'msvs_disabled_warnings': [
21 4018, # signed/unsigned mismatch in comparison
22 4244, # implicit conversion, possible loss of data
23 4355, # 'this' used in base member initializer list
24 4267, # size_t to int truncation
25 4291, # no matching operator delete for a placement new
28 'WIN32_LEAN_AND_MEAN', # Protobuf defines this itself.
32 ['OS=="ios" and "<(GENERATOR)"!="ninja"', {
34 'ninja_output_dir': 'ninja-protoc',
36 '<(DEPTH)/xcodebuild/<(ninja_output_dir)/<(CONFIGURATION_NAME)',
39 'third_party/protobuf/protobuf.gyp',
44 # On iOS, generating protoc is done via two actions: (1) compiling
45 # the executable with ninja, and (2) copying the executable into a
46 # location that is shared with other projects. These actions are
47 # separated into two targets in order to be able to specify that the
48 # second action should not run until the first action finishes (since
49 # the ordering of multiple actions in one target is defined only by
50 # inputs and outputs, and it's impossible to set correct inputs for
51 # the ninja build, so setting all the inputs and outputs isn't an
52 # option). The first target is given here; the second target is the
53 # normal protoc target under the condition that "OS==iOS".
54 'target_name': 'compile_protoc',
56 'includes': ['../../build/ios/mac_build.gypi'],
59 'action_name': 'compile protoc',
66 'message': 'Generating the C++ protocol buffers compiler',
75 'target_name': 'protobuf_lite_javalib',
81 'script_descriptors': './protobuf_lite_java_descriptor_proto.py',
82 'script_pom': './protobuf_lite_java_parse_pom.py',
83 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
84 # Variables needed by java.gypi below.
85 'java_out_dir': '<(PRODUCT_DIR)/java_proto/protobuf_lite_java_descriptor_proto',
86 'generated_src_dirs': ['<(java_out_dir)'],
87 'java_in_dir': 'java',
88 'maven_pom': '<(java_in_dir)/pom.xml',
89 'javac_includes': ['<!@(<(script_pom) <(maven_pom))'],
90 'additional_input_paths': [
91 '<(java_out_dir)/com/google/protobuf/DescriptorProtos.java'
96 'action_name': 'protobuf_lite_java_gen_descriptor_proto',
98 '<(script_descriptors)',
100 'src/google/protobuf/descriptor.proto',
103 '<(java_out_dir)/com/google/protobuf/DescriptorProtos.java',
106 '<(script_descriptors)',
110 'src/google/protobuf/descriptor.proto',
112 'message': 'Generating descriptor protos for Java',
115 # Now that we have generated DescriptorProtos.java, build jar.
116 'includes': ['../../build/java.gypi'],
122 # The "lite" lib is about 1/7th the size of the heavy lib,
123 # but it doesn't support some of the more exotic features of
124 # protobufs, like reflection. To generate C++ code that can link
125 # against the lite version of the library, add the option line:
127 # option optimize_for = LITE_RUNTIME;
129 # to your .proto file.
131 'target_name': 'protobuf_lite',
132 'type': '<(component)',
133 'toolsets': ['host', 'target'],
135 'protobuf_lite.gypi',
137 # Required for component builds. See http://crbug.com/172800.
139 'LIBPROTOBUF_EXPORTS',
142 'direct_dependent_settings': {
148 # This is the full, heavy protobuf lib that's needed for c++ .protos
149 # that don't specify the LITE_RUNTIME option. The protocol
150 # compiler itself (protoc) falls into that category.
152 # DO NOT LINK AGAINST THIS TARGET IN CHROME CODE --agl
154 'target_name': 'protobuf_full_do_not_use',
155 'type': 'static_library',
156 'toolsets': ['host','target'],
158 'protobuf_lite.gypi',
161 'src/google/protobuf/descriptor.h',
162 'src/google/protobuf/descriptor.pb.h',
163 'src/google/protobuf/descriptor_database.h',
164 'src/google/protobuf/dynamic_message.h',
165 'src/google/protobuf/generated_enum_reflection.h',
166 'src/google/protobuf/generated_message_reflection.h',
167 'src/google/protobuf/message.h',
168 'src/google/protobuf/reflection_ops.h',
169 'src/google/protobuf/service.h',
170 'src/google/protobuf/text_format.h',
171 'src/google/protobuf/wire_format.h',
172 'src/google/protobuf/io/gzip_stream.h',
173 'src/google/protobuf/io/printer.h',
174 'src/google/protobuf/io/tokenizer.h',
175 'src/google/protobuf/io/zero_copy_stream_impl.h',
176 'src/google/protobuf/compiler/code_generator.h',
177 'src/google/protobuf/compiler/command_line_interface.h',
178 'src/google/protobuf/compiler/importer.h',
179 'src/google/protobuf/compiler/java/java_doc_comment.cc',
180 'src/google/protobuf/compiler/java/java_doc_comment.h',
181 'src/google/protobuf/compiler/parser.h',
183 'src/google/protobuf/stubs/strutil.cc',
184 'src/google/protobuf/stubs/strutil.h',
185 'src/google/protobuf/stubs/substitute.cc',
186 'src/google/protobuf/stubs/substitute.h',
187 'src/google/protobuf/stubs/stl_util.h',
188 'src/google/protobuf/stubs/stringprintf.cc',
189 'src/google/protobuf/stubs/stringprintf.h',
190 'src/google/protobuf/stubs/structurally_valid.cc',
191 'src/google/protobuf/stubs/template_util.h',
192 'src/google/protobuf/stubs/type_traits.h',
194 'src/google/protobuf/descriptor.cc',
195 'src/google/protobuf/descriptor.pb.cc',
196 'src/google/protobuf/descriptor_database.cc',
197 'src/google/protobuf/dynamic_message.cc',
198 'src/google/protobuf/extension_set.cc',
199 'src/google/protobuf/extension_set.h',
200 'src/google/protobuf/extension_set_heavy.cc',
201 'src/google/protobuf/generated_message_reflection.cc',
202 'src/google/protobuf/message.cc',
203 'src/google/protobuf/reflection_ops.cc',
204 'src/google/protobuf/service.cc',
205 'src/google/protobuf/text_format.cc',
206 'src/google/protobuf/wire_format.cc',
207 # This file pulls in zlib, but it's not actually used by protoc, so
208 # instead of compiling zlib for the host, let's just exclude this.
209 # 'src/src/google/protobuf/io/gzip_stream.cc',
210 'src/google/protobuf/io/printer.cc',
211 'src/google/protobuf/io/tokenizer.cc',
212 'src/google/protobuf/io/zero_copy_stream_impl.cc',
213 'src/google/protobuf/compiler/importer.cc',
214 'src/google/protobuf/compiler/parser.cc',
218 'target_name': 'protoc',
220 ['OS!="ios" or "<(GENERATOR)"=="ninja"', {
221 'type': 'executable',
222 'toolsets': ['host'],
224 'src/google/protobuf/compiler/code_generator.cc',
225 'src/google/protobuf/compiler/command_line_interface.cc',
226 'src/google/protobuf/compiler/plugin.cc',
227 'src/google/protobuf/compiler/plugin.pb.cc',
228 'src/google/protobuf/compiler/subprocess.cc',
229 'src/google/protobuf/compiler/subprocess.h',
230 'src/google/protobuf/compiler/zip_writer.cc',
231 'src/google/protobuf/compiler/zip_writer.h',
232 'src/google/protobuf/compiler/cpp/cpp_enum.cc',
233 'src/google/protobuf/compiler/cpp/cpp_enum.h',
234 'src/google/protobuf/compiler/cpp/cpp_enum_field.cc',
235 'src/google/protobuf/compiler/cpp/cpp_enum_field.h',
236 'src/google/protobuf/compiler/cpp/cpp_extension.cc',
237 'src/google/protobuf/compiler/cpp/cpp_extension.h',
238 'src/google/protobuf/compiler/cpp/cpp_field.cc',
239 'src/google/protobuf/compiler/cpp/cpp_field.h',
240 'src/google/protobuf/compiler/cpp/cpp_file.cc',
241 'src/google/protobuf/compiler/cpp/cpp_file.h',
242 'src/google/protobuf/compiler/cpp/cpp_generator.cc',
243 'src/google/protobuf/compiler/cpp/cpp_helpers.cc',
244 'src/google/protobuf/compiler/cpp/cpp_helpers.h',
245 'src/google/protobuf/compiler/cpp/cpp_message.cc',
246 'src/google/protobuf/compiler/cpp/cpp_message.h',
247 'src/google/protobuf/compiler/cpp/cpp_message_field.cc',
248 'src/google/protobuf/compiler/cpp/cpp_message_field.h',
249 'src/google/protobuf/compiler/cpp/cpp_primitive_field.cc',
250 'src/google/protobuf/compiler/cpp/cpp_primitive_field.h',
251 'src/google/protobuf/compiler/cpp/cpp_service.cc',
252 'src/google/protobuf/compiler/cpp/cpp_service.h',
253 'src/google/protobuf/compiler/cpp/cpp_string_field.cc',
254 'src/google/protobuf/compiler/cpp/cpp_string_field.h',
255 'src/google/protobuf/compiler/java/java_enum.cc',
256 'src/google/protobuf/compiler/java/java_enum.h',
257 'src/google/protobuf/compiler/java/java_enum_field.cc',
258 'src/google/protobuf/compiler/java/java_enum_field.h',
259 'src/google/protobuf/compiler/java/java_extension.cc',
260 'src/google/protobuf/compiler/java/java_extension.h',
261 'src/google/protobuf/compiler/java/java_field.cc',
262 'src/google/protobuf/compiler/java/java_field.h',
263 'src/google/protobuf/compiler/java/java_file.cc',
264 'src/google/protobuf/compiler/java/java_file.h',
265 'src/google/protobuf/compiler/java/java_generator.cc',
266 'src/google/protobuf/compiler/java/java_helpers.cc',
267 'src/google/protobuf/compiler/java/java_helpers.h',
268 'src/google/protobuf/compiler/java/java_message.cc',
269 'src/google/protobuf/compiler/java/java_message.h',
270 'src/google/protobuf/compiler/java/java_message_field.cc',
271 'src/google/protobuf/compiler/java/java_message_field.h',
272 'src/google/protobuf/compiler/java/java_primitive_field.cc',
273 'src/google/protobuf/compiler/java/java_primitive_field.h',
274 'src/google/protobuf/compiler/java/java_service.cc',
275 'src/google/protobuf/compiler/java/java_service.h',
276 'src/google/protobuf/compiler/java/java_string_field.cc',
277 'src/google/protobuf/compiler/java/java_string_field.h',
278 'src/google/protobuf/compiler/python/python_generator.cc',
279 'src/google/protobuf/compiler/main.cc',
282 'protobuf_full_do_not_use',
288 }, { # else, OS=="ios" and "<(GENERATOR)"!="ninja"
295 'action_name': 'copy protoc',
297 '<(ninja_product_dir)/protoc',
300 '<(PRODUCT_DIR)/protoc',
304 '<(ninja_product_dir)/protoc',
305 '<(PRODUCT_DIR)/protoc',
313 # Generate the python module needed by all protoc-generated Python code.
314 'target_name': 'py_proto',
318 'destination': '<(PRODUCT_DIR)/pyproto/google/',
320 # google/ module gets an empty __init__.py.
325 'destination': '<(PRODUCT_DIR)/pyproto/google/protobuf',
327 'python/google/protobuf/__init__.py',
328 'python/google/protobuf/descriptor.py',
329 'python/google/protobuf/descriptor_database.py',
330 'python/google/protobuf/descriptor_pool.py',
331 'python/google/protobuf/message.py',
332 'python/google/protobuf/message_factory.py',
333 'python/google/protobuf/reflection.py',
334 'python/google/protobuf/service.py',
335 'python/google/protobuf/service_reflection.py',
336 'python/google/protobuf/text_format.py',
338 # TODO(ncarter): protoc's python generator treats
339 # descriptor.proto specially, but it's not possible to trigger
340 # the special treatment unless you run protoc from ./src/src
341 # (the treatment is based on the path to the .proto file
342 # matching a constant exactly). I'm not sure how to convince
343 # gyp to execute a rule from a different directory. Until this
344 # is resolved, use a copy of descriptor_pb2.py that I manually
350 'destination': '<(PRODUCT_DIR)/pyproto/google/protobuf/internal',
352 'python/google/protobuf/internal/__init__.py',
353 'python/google/protobuf/internal/api_implementation.py',
354 'python/google/protobuf/internal/containers.py',
355 'python/google/protobuf/internal/cpp_message.py',
356 'python/google/protobuf/internal/decoder.py',
357 'python/google/protobuf/internal/encoder.py',
358 'python/google/protobuf/internal/enum_type_wrapper.py',
359 'python/google/protobuf/internal/generator_test.py',
360 'python/google/protobuf/internal/message_listener.py',
361 'python/google/protobuf/internal/python_message.py',
362 'python/google/protobuf/internal/type_checkers.py',
363 'python/google/protobuf/internal/wire_format.py',
367 # # We can't generate a proper descriptor_pb2.py -- see earlier comment.
370 # 'rule_name': 'genproto',
371 # 'extension': 'proto',
373 # '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
376 # # The protoc compiler requires a proto_path argument with the
377 # # directory containing the .proto file.
378 # 'rule_input_relpath': 'src/google/protobuf',
381 # '<(PRODUCT_DIR)/pyproto/google/protobuf/<(RULE_INPUT_ROOT)_pb2.py',
384 # '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
387 # '--python_out=<(PRODUCT_DIR)/pyproto/google/protobuf',
388 # 'google/protobuf/descriptor.proto',
390 # 'message': 'Generating Python code from <(RULE_INPUT_PATH)',
397 # 'src/google/protobuf/descriptor.proto',
401 }, { # use_system_protobuf==1
404 'target_name': 'protobuf_lite',
406 'direct_dependent_settings': {
408 # Use full protobuf, because vanilla protobuf doesn't have
409 # our custom patch to retain unknown fields in lite mode.
410 '<!@(pkg-config --cflags protobuf)',
413 'USE_SYSTEM_PROTOBUF',
415 # This macro must be defined to suppress the use
416 # of dynamic_cast<>, which requires RTTI.
417 'GOOGLE_PROTOBUF_NO_RTTI',
418 'GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER',
422 # Use full protobuf, because vanilla protobuf doesn't have
423 # our custom patch to retain unknown fields in lite mode.
425 '<!@(pkg-config --libs-only-L --libs-only-other protobuf)',
428 '<!@(pkg-config --libs-only-l protobuf)',
433 'target_name': 'protoc',
435 'toolsets': ['host', 'target'],
438 'target_name': 'py_proto',