Pepper: Remove Mojo integration and tests.
[chromium-blink-merge.git] / third_party / protobuf / protobuf.gyp
blob7417eecc8915165e77acbd30a01826fe14708122
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.
6   'conditions': [
7     ['use_system_protobuf==0', {
8       'conditions': [
9         ['OS!="win"', {
10           'variables': {
11             'config_h_dir':
12               '.',  # crafted for gcc/linux.
13           },
14         }, {  # else, OS=="win"
15           'variables': {
16             'config_h_dir':
17               'vsprojects',  # crafted for msvc.
18           },
19           'target_defaults': {
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
26             ],
27             'defines!': [
28               'WIN32_LEAN_AND_MEAN',  # Protobuf defines this itself.
29             ],
30           },
31         }],
32         ['OS=="ios" and "<(GENERATOR)"=="xcode" and "<(GENERATOR_FLAVOR)"!="ninja"', {
33           'variables': {
34             'ninja_output_dir': 'ninja-protoc',
35             'ninja_product_dir':
36               '<(DEPTH)/xcodebuild/<(ninja_output_dir)/<(CONFIGURATION_NAME)',
37             # Gyp to rerun
38             're_run_targets': [
39               'third_party/protobuf/protobuf.gyp',
40             ],
41           },
42           'targets': [
43             {
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',
55               'type': 'none',
56               'toolsets': ['host'],
57               'includes': ['../../build/ios/mac_build.gypi'],
58               'actions': [
59                 {
60                   'action_name': 'compile protoc',
61                   'inputs': [],
62                   'outputs': [],
63                   'action': [
64                     '<@(ninja_cmd)',
65                     'protoc',
66                   ],
67                   'message': 'Generating the C++ protocol buffers compiler',
68                 },
69               ],
70             },
71           ],
72         }],
73       ],
74       'targets': [
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:
79         #
80         #   option optimize_for = LITE_RUNTIME;
81         #
82         # to your .proto file.
83         {
84           'target_name': 'protobuf_lite',
85           'type': '<(component)',
86           'toolsets': ['host', 'target'],
87           'includes': [
88             'protobuf_lite.gypi',
89           ],
90           # Required for component builds. See http://crbug.com/172800.
91           'defines': [
92             'LIBPROTOBUF_EXPORTS',
93             'PROTOBUF_USE_DLLS',
94           ],
95           'direct_dependent_settings': {
96             'defines': [
97               'PROTOBUF_USE_DLLS',
98             ],
99           },
100         },
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.
104         #
105         # DO NOT LINK AGAINST THIS TARGET IN CHROME CODE  --agl
106         {
107           'target_name': 'protobuf_full_do_not_use',
108           'type': 'static_library',
109           'toolsets': ['host','target'],
110           'includes': [
111             'protobuf_lite.gypi',
112           ],
113           'sources': [
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',
168           ],
169         },
170         {
171           'target_name': 'protoc',
172           'conditions': [
173             ['OS!="ios" or "<(GENERATOR)"!="xcode" or "<(GENERATOR_FLAVOR)"=="ninja"', {
174               'type': 'executable',
175               'toolsets': ['host'],
176               'sources': [
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',
233               ],
234               'dependencies': [
235                 'protobuf_full_do_not_use',
236               ],
237               'include_dirs': [
238                 '<(config_h_dir)',
239                 'src/src',
240               ],
241             }, {  # else, OS=="ios" and "<(GENERATOR)"=="xcode" and "<(GENERATOR_FLAVOR)"!="ninja"
242               'type': 'none',
243               'toolsets': ['host'],
244               'dependencies': [
245                 'compile_protoc',
246               ],
247               'actions': [
248                 {
249                   'action_name': 'copy protoc',
250                   'inputs': [
251                     '<(ninja_product_dir)/protoc',
252                   ],
253                   'outputs': [
254                     '<(PRODUCT_DIR)/protoc',
255                   ],
256                   'action': [
257                     'cp',
258                     '<(ninja_product_dir)/protoc',
259                     '<(PRODUCT_DIR)/protoc',
260                   ],
261                 },
262               ],
263             }],
264           ],
265         },
266         {
267           # Generate the python module needed by all protoc-generated Python code.
268           'target_name': 'py_proto',
269           'type': 'none',
270           'copies': [
271             {
272               'destination': '<(PRODUCT_DIR)/pyproto/google/',
273               'files': [
274                 # google/ module gets an empty __init__.py.
275                 '__init__.py',
276               ],
277             },
278             {
279               'destination': '<(PRODUCT_DIR)/pyproto/google/protobuf',
280               'files': [
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
299                 # generated.
300                 'descriptor_pb2.py',
301               ],
302             },
303             {
304               'destination': '<(PRODUCT_DIR)/pyproto/google/protobuf/internal',
305               'files': [
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',
318               ],
319             },
320           ],
321       #   # We can't generate a proper descriptor_pb2.py -- see earlier comment.
322       #   'rules': [
323       #     {
324       #       'rule_name': 'genproto',
325       #       'extension': 'proto',
326       #       'inputs': [
327       #         '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
328       #       ],
329       #       'variables': {
330       #         # The protoc compiler requires a proto_path argument with the
331       #           # directory containing the .proto file.
332       #           'rule_input_relpath': 'src/google/protobuf',
333       #         },
334       #         'outputs': [
335       #           '<(PRODUCT_DIR)/pyproto/google/protobuf/<(RULE_INPUT_ROOT)_pb2.py',
336       #         ],
337       #         'action': [
338       #           '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
339       #           '-I./src',
340       #           '-I.',
341       #           '--python_out=<(PRODUCT_DIR)/pyproto/google/protobuf',
342       #           'google/protobuf/descriptor.proto',
343       #         ],
344       #         'message': 'Generating Python code from <(RULE_INPUT_PATH)',
345       #       },
346       #     ],
347       #     'dependencies': [
348       #       'protoc#host',
349       #     ],
350       #     'sources': [
351       #       'src/google/protobuf/descriptor.proto',
352       #     ],
353          },
354       ],
355     }, { # use_system_protobuf==1
356       'targets': [
357         {
358           'target_name': 'protobuf_lite',
359           'type': 'none',
360           'direct_dependent_settings': {
361             'cflags': [
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)',
365             ],
366             'defines': [
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',
373             ],
374           },
375           'link_settings': {
376             # Use full protobuf, because vanilla protobuf doesn't have
377             # our custom patch to retain unknown fields in lite mode.
378             'ldflags': [
379               '<!@(pkg-config --libs-only-L --libs-only-other protobuf)',
380             ],
381             'libraries': [
382               '<!@(pkg-config --libs-only-l protobuf)',
383             ],
384           },
385         },
386         {
387           'target_name': 'protoc',
388           'type': 'none',
389           'toolsets': ['host', 'target'],
390         },
391         {
392           'target_name': 'py_proto',
393           'type': 'none',
394         },
395       ],
396     }],
397   ],