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)"=="xcode" and "<(GENERATOR_FLAVOR)"!="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',
57 'includes': ['../../build/ios/mac_build.gypi'],
60 'action_name': 'compile protoc',
67 'message': 'Generating the C++ protocol buffers compiler',
75 # The "lite" lib is about 1/7th the size of the heavy lib,
76 # but it doesn't support some of the more exotic features of
77 # protobufs, like reflection. To generate C++ code that can link
78 # against the lite version of the library, add the option line:
80 # option optimize_for = LITE_RUNTIME;
82 # to your .proto file.
84 'target_name': 'protobuf_lite',
85 'type': '<(component)',
86 'toolsets': ['host', 'target'],
90 # Required for component builds. See http://crbug.com/172800.
92 'LIBPROTOBUF_EXPORTS',
95 'direct_dependent_settings': {
101 # This is the full, heavy protobuf lib that's needed for c++ .protos
102 # that don't specify the LITE_RUNTIME option. The protocol
103 # compiler itself (protoc) falls into that category.
105 # DO NOT LINK AGAINST THIS TARGET IN CHROME CODE --agl
107 'target_name': 'protobuf_full_do_not_use',
108 'type': 'static_library',
109 'toolsets': ['host','target'],
111 'protobuf_lite.gypi',
114 'src/google/protobuf/descriptor.h',
115 'src/google/protobuf/descriptor.pb.h',
116 'src/google/protobuf/descriptor_database.h',
117 'src/google/protobuf/dynamic_message.h',
118 'src/google/protobuf/generated_enum_reflection.h',
119 'src/google/protobuf/generated_message_reflection.h',
120 'src/google/protobuf/message.h',
121 'src/google/protobuf/reflection_ops.h',
122 'src/google/protobuf/service.h',
123 'src/google/protobuf/text_format.h',
124 'src/google/protobuf/wire_format.h',
125 'src/google/protobuf/io/gzip_stream.h',
126 'src/google/protobuf/io/printer.h',
127 'src/google/protobuf/io/tokenizer.h',
128 'src/google/protobuf/io/zero_copy_stream_impl.h',
129 'src/google/protobuf/compiler/code_generator.h',
130 'src/google/protobuf/compiler/command_line_interface.h',
131 'src/google/protobuf/compiler/importer.h',
132 'src/google/protobuf/compiler/java/java_doc_comment.cc',
133 'src/google/protobuf/compiler/java/java_doc_comment.h',
134 'src/google/protobuf/compiler/parser.h',
136 'src/google/protobuf/stubs/strutil.cc',
137 'src/google/protobuf/stubs/strutil.h',
138 'src/google/protobuf/stubs/substitute.cc',
139 'src/google/protobuf/stubs/substitute.h',
140 'src/google/protobuf/stubs/stl_util.h',
141 'src/google/protobuf/stubs/stringprintf.cc',
142 'src/google/protobuf/stubs/stringprintf.h',
143 'src/google/protobuf/stubs/structurally_valid.cc',
144 'src/google/protobuf/stubs/template_util.h',
145 'src/google/protobuf/stubs/type_traits.h',
147 'src/google/protobuf/descriptor.cc',
148 'src/google/protobuf/descriptor.pb.cc',
149 'src/google/protobuf/descriptor_database.cc',
150 'src/google/protobuf/dynamic_message.cc',
151 'src/google/protobuf/extension_set.cc',
152 'src/google/protobuf/extension_set.h',
153 'src/google/protobuf/extension_set_heavy.cc',
154 'src/google/protobuf/generated_message_reflection.cc',
155 'src/google/protobuf/message.cc',
156 'src/google/protobuf/reflection_ops.cc',
157 'src/google/protobuf/service.cc',
158 'src/google/protobuf/text_format.cc',
159 'src/google/protobuf/wire_format.cc',
160 # This file pulls in zlib, but it's not actually used by protoc, so
161 # instead of compiling zlib for the host, let's just exclude this.
162 # 'src/src/google/protobuf/io/gzip_stream.cc',
163 'src/google/protobuf/io/printer.cc',
164 'src/google/protobuf/io/tokenizer.cc',
165 'src/google/protobuf/io/zero_copy_stream_impl.cc',
166 'src/google/protobuf/compiler/importer.cc',
167 'src/google/protobuf/compiler/parser.cc',
171 'target_name': 'protoc',
173 ['OS!="ios" or "<(GENERATOR)"!="xcode" or "<(GENERATOR_FLAVOR)"=="ninja"', {
174 'type': 'executable',
175 'toolsets': ['host'],
177 'src/google/protobuf/compiler/code_generator.cc',
178 'src/google/protobuf/compiler/command_line_interface.cc',
179 'src/google/protobuf/compiler/plugin.cc',
180 'src/google/protobuf/compiler/plugin.pb.cc',
181 'src/google/protobuf/compiler/subprocess.cc',
182 'src/google/protobuf/compiler/subprocess.h',
183 'src/google/protobuf/compiler/zip_writer.cc',
184 'src/google/protobuf/compiler/zip_writer.h',
185 'src/google/protobuf/compiler/cpp/cpp_enum.cc',
186 'src/google/protobuf/compiler/cpp/cpp_enum.h',
187 'src/google/protobuf/compiler/cpp/cpp_enum_field.cc',
188 'src/google/protobuf/compiler/cpp/cpp_enum_field.h',
189 'src/google/protobuf/compiler/cpp/cpp_extension.cc',
190 'src/google/protobuf/compiler/cpp/cpp_extension.h',
191 'src/google/protobuf/compiler/cpp/cpp_field.cc',
192 'src/google/protobuf/compiler/cpp/cpp_field.h',
193 'src/google/protobuf/compiler/cpp/cpp_file.cc',
194 'src/google/protobuf/compiler/cpp/cpp_file.h',
195 'src/google/protobuf/compiler/cpp/cpp_generator.cc',
196 'src/google/protobuf/compiler/cpp/cpp_helpers.cc',
197 'src/google/protobuf/compiler/cpp/cpp_helpers.h',
198 'src/google/protobuf/compiler/cpp/cpp_message.cc',
199 'src/google/protobuf/compiler/cpp/cpp_message.h',
200 'src/google/protobuf/compiler/cpp/cpp_message_field.cc',
201 'src/google/protobuf/compiler/cpp/cpp_message_field.h',
202 'src/google/protobuf/compiler/cpp/cpp_primitive_field.cc',
203 'src/google/protobuf/compiler/cpp/cpp_primitive_field.h',
204 'src/google/protobuf/compiler/cpp/cpp_service.cc',
205 'src/google/protobuf/compiler/cpp/cpp_service.h',
206 'src/google/protobuf/compiler/cpp/cpp_string_field.cc',
207 'src/google/protobuf/compiler/cpp/cpp_string_field.h',
208 'src/google/protobuf/compiler/java/java_enum.cc',
209 'src/google/protobuf/compiler/java/java_enum.h',
210 'src/google/protobuf/compiler/java/java_enum_field.cc',
211 'src/google/protobuf/compiler/java/java_enum_field.h',
212 'src/google/protobuf/compiler/java/java_extension.cc',
213 'src/google/protobuf/compiler/java/java_extension.h',
214 'src/google/protobuf/compiler/java/java_field.cc',
215 'src/google/protobuf/compiler/java/java_field.h',
216 'src/google/protobuf/compiler/java/java_file.cc',
217 'src/google/protobuf/compiler/java/java_file.h',
218 'src/google/protobuf/compiler/java/java_generator.cc',
219 'src/google/protobuf/compiler/java/java_helpers.cc',
220 'src/google/protobuf/compiler/java/java_helpers.h',
221 'src/google/protobuf/compiler/java/java_message.cc',
222 'src/google/protobuf/compiler/java/java_message.h',
223 'src/google/protobuf/compiler/java/java_message_field.cc',
224 'src/google/protobuf/compiler/java/java_message_field.h',
225 'src/google/protobuf/compiler/java/java_primitive_field.cc',
226 'src/google/protobuf/compiler/java/java_primitive_field.h',
227 'src/google/protobuf/compiler/java/java_service.cc',
228 'src/google/protobuf/compiler/java/java_service.h',
229 'src/google/protobuf/compiler/java/java_string_field.cc',
230 'src/google/protobuf/compiler/java/java_string_field.h',
231 'src/google/protobuf/compiler/python/python_generator.cc',
232 'src/google/protobuf/compiler/main.cc',
235 'protobuf_full_do_not_use',
241 }, { # else, OS=="ios" and "<(GENERATOR)"=="xcode" and "<(GENERATOR_FLAVOR)"!="ninja"
243 'toolsets': ['host'],
249 'action_name': 'copy protoc',
251 '<(ninja_product_dir)/protoc',
254 '<(PRODUCT_DIR)/protoc',
258 '<(ninja_product_dir)/protoc',
259 '<(PRODUCT_DIR)/protoc',
267 # Generate the python module needed by all protoc-generated Python code.
268 'target_name': 'py_proto',
272 'destination': '<(PRODUCT_DIR)/pyproto/google/',
274 # google/ module gets an empty __init__.py.
279 'destination': '<(PRODUCT_DIR)/pyproto/google/protobuf',
281 'python/google/protobuf/__init__.py',
282 'python/google/protobuf/descriptor.py',
283 'python/google/protobuf/descriptor_database.py',
284 'python/google/protobuf/descriptor_pool.py',
285 'python/google/protobuf/message.py',
286 'python/google/protobuf/message_factory.py',
287 'python/google/protobuf/reflection.py',
288 'python/google/protobuf/service.py',
289 'python/google/protobuf/service_reflection.py',
290 'python/google/protobuf/text_format.py',
292 # TODO(ncarter): protoc's python generator treats
293 # descriptor.proto specially, but it's not possible to trigger
294 # the special treatment unless you run protoc from ./src/src
295 # (the treatment is based on the path to the .proto file
296 # matching a constant exactly). I'm not sure how to convince
297 # gyp to execute a rule from a different directory. Until this
298 # is resolved, use a copy of descriptor_pb2.py that I manually
304 'destination': '<(PRODUCT_DIR)/pyproto/google/protobuf/internal',
306 'python/google/protobuf/internal/__init__.py',
307 'python/google/protobuf/internal/api_implementation.py',
308 'python/google/protobuf/internal/containers.py',
309 'python/google/protobuf/internal/cpp_message.py',
310 'python/google/protobuf/internal/decoder.py',
311 'python/google/protobuf/internal/encoder.py',
312 'python/google/protobuf/internal/enum_type_wrapper.py',
313 'python/google/protobuf/internal/generator_test.py',
314 'python/google/protobuf/internal/message_listener.py',
315 'python/google/protobuf/internal/python_message.py',
316 'python/google/protobuf/internal/type_checkers.py',
317 'python/google/protobuf/internal/wire_format.py',
321 # # We can't generate a proper descriptor_pb2.py -- see earlier comment.
324 # 'rule_name': 'genproto',
325 # 'extension': 'proto',
327 # '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
330 # # The protoc compiler requires a proto_path argument with the
331 # # directory containing the .proto file.
332 # 'rule_input_relpath': 'src/google/protobuf',
335 # '<(PRODUCT_DIR)/pyproto/google/protobuf/<(RULE_INPUT_ROOT)_pb2.py',
338 # '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
341 # '--python_out=<(PRODUCT_DIR)/pyproto/google/protobuf',
342 # 'google/protobuf/descriptor.proto',
344 # 'message': 'Generating Python code from <(RULE_INPUT_PATH)',
351 # 'src/google/protobuf/descriptor.proto',
355 }, { # use_system_protobuf==1
358 'target_name': 'protobuf_lite',
360 'direct_dependent_settings': {
362 # Use full protobuf, because vanilla protobuf doesn't have
363 # our custom patch to retain unknown fields in lite mode.
364 '<!@(pkg-config --cflags protobuf)',
367 'USE_SYSTEM_PROTOBUF',
369 # This macro must be defined to suppress the use
370 # of dynamic_cast<>, which requires RTTI.
371 'GOOGLE_PROTOBUF_NO_RTTI',
372 'GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER',
376 # Use full protobuf, because vanilla protobuf doesn't have
377 # our custom patch to retain unknown fields in lite mode.
379 '<!@(pkg-config --libs-only-L --libs-only-other protobuf)',
382 '<!@(pkg-config --libs-only-l protobuf)',
387 'target_name': 'protoc',
389 'toolsets': ['host', 'target'],
392 'target_name': 'py_proto',