Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / protobuf / BUILD.gn
blob0c57bd65c46710a94e5821bc09554f2893664092
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
3 # found in the LICENSE file.
5 if (is_win) {
6   config_h_dir = "vsprojects"
7 } else {
8   config_h_dir = "."
11 config("protobuf_config") {
12   include_dirs = [
13     "src",
14     config_h_dir,
15   ]
16   defines = [
17     "GOOGLE_PROTOBUF_NO_RTTI",
18     "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
19   ]
22 if (component_mode == "shared_library") {
23   config("protobuf_use_dlls") {
24     defines = [ "PROTOBUF_USE_DLLS" ]
25   }
28 # This config should be applied to targets using generated code from the proto
29 # compiler. It sets up the include directories properly.
30 config("using_proto") {
31   include_dirs = [
32     "src",
33     "$root_gen_dir/protoc_out",
34   ]
37 protobuf_lite_sources = [
38   "src/google/protobuf/extension_set.cc",
39   "src/google/protobuf/extension_set.h",
40   "src/google/protobuf/generated_message_util.cc",
41   "src/google/protobuf/generated_message_util.h",
42   "src/google/protobuf/io/coded_stream.cc",
43   "src/google/protobuf/io/coded_stream.h",
44   "src/google/protobuf/io/coded_stream_inl.h",
45   "src/google/protobuf/io/zero_copy_stream.cc",
46   "src/google/protobuf/io/zero_copy_stream.h",
47   "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
48   "src/google/protobuf/io/zero_copy_stream_impl_lite.h",
49   "src/google/protobuf/message_lite.cc",
50   "src/google/protobuf/message_lite.h",
51   "src/google/protobuf/repeated_field.cc",
52   "src/google/protobuf/repeated_field.h",
53   "src/google/protobuf/stubs/atomicops.h",
54   "src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
55   "src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
56   "src/google/protobuf/stubs/atomicops_internals_macosx.h",
57   "src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
58   "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
59   "src/google/protobuf/stubs/atomicops_internals_x86_gcc.h",
60   "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
61   "src/google/protobuf/stubs/atomicops_internals_x86_msvc.h",
62   "src/google/protobuf/stubs/common.cc",
63   "src/google/protobuf/stubs/common.h",
64   "src/google/protobuf/stubs/hash.h",
65   "src/google/protobuf/stubs/map-util.h",
66   "src/google/protobuf/stubs/once.cc",
67   "src/google/protobuf/stubs/once.h",
68   "src/google/protobuf/stubs/platform_macros.h",
69   "src/google/protobuf/unknown_field_set.cc",
70   "src/google/protobuf/unknown_field_set.h",
71   "src/google/protobuf/wire_format_lite.cc",
72   "src/google/protobuf/wire_format_lite.h",
73   "src/google/protobuf/wire_format_lite_inl.h",
74   "$config_h_dir/config.h",
77 protobuf_lite_cflags = []
78 if (is_win) {
79   protobuf_lite_cflags = [
80     "/wd4018",  # signed/unsigned mismatch in comparison
81     "/wd4244",  # implicit conversion, possible loss of data
82     "/wd4355",  # 'this' used in base member initializer list
83     "/wd4267",  # size_t to int truncation
84     "/wd4291",  # no matching operator delete for a placement new
85   ]
88 component("protobuf_lite") {
89   sources = protobuf_lite_sources
91   configs -= [ "//build/config/compiler:chromium_code" ]
92   configs += [ "//build/config/compiler:no_chromium_code" ]
93   if (is_win) {
94     configs -= [ "//build/config/win:lean_and_mean" ]
95   }
96   public_configs = [
97     ":protobuf_config",
99     # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
100     "//build/config/compiler:no_size_t_to_int_warning",
101   ]
103   cflags = protobuf_lite_cflags
105   # Required for component builds. See http://crbug.com/172800.
106   if (component_mode == "shared_library") {
107     public_configs += [ ":protobuf_use_dlls" ]
108     defines = [ "LIBPROTOBUF_EXPORTS" ]
109   }
112 # This is the full, heavy protobuf lib that's needed for c++ .protos that don't
113 # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
114 # into that category. Do not use in Chrome code.
116 source_set("protobuf_full") {
117   # Prevent people from depending on this outside our file.
118   visibility = [ ":*" ]
120   sources = protobuf_lite_sources
121   sources += [
122     "src/google/protobuf/compiler/code_generator.h",
123     "src/google/protobuf/compiler/command_line_interface.h",
124     "src/google/protobuf/compiler/importer.h",
125     "src/google/protobuf/compiler/java/java_doc_comment.cc",
126     "src/google/protobuf/compiler/java/java_doc_comment.h",
127     "src/google/protobuf/compiler/parser.h",
128     "src/google/protobuf/descriptor.cc",
129     "src/google/protobuf/descriptor.h",
130     "src/google/protobuf/descriptor.pb.cc",
131     "src/google/protobuf/descriptor.pb.h",
132     "src/google/protobuf/descriptor_database.cc",
133     "src/google/protobuf/descriptor_database.h",
134     "src/google/protobuf/dynamic_message.cc",
135     "src/google/protobuf/dynamic_message.h",
136     "src/google/protobuf/extension_set_heavy.cc",
137     "src/google/protobuf/generated_enum_reflection.h",
138     "src/google/protobuf/generated_message_reflection.cc",
139     "src/google/protobuf/generated_message_reflection.h",
140     "src/google/protobuf/io/gzip_stream.h",
141     "src/google/protobuf/io/printer.h",
142     "src/google/protobuf/io/tokenizer.h",
143     "src/google/protobuf/io/zero_copy_stream_impl.h",
144     "src/google/protobuf/message.cc",
145     "src/google/protobuf/message.h",
146     "src/google/protobuf/reflection_ops.cc",
147     "src/google/protobuf/reflection_ops.h",
148     "src/google/protobuf/service.cc",
149     "src/google/protobuf/service.h",
150     "src/google/protobuf/stubs/stl_util.h",
151     "src/google/protobuf/stubs/stringprintf.cc",
152     "src/google/protobuf/stubs/stringprintf.h",
153     "src/google/protobuf/stubs/structurally_valid.cc",
154     "src/google/protobuf/stubs/strutil.cc",
155     "src/google/protobuf/stubs/strutil.h",
156     "src/google/protobuf/stubs/substitute.cc",
157     "src/google/protobuf/stubs/substitute.h",
158     "src/google/protobuf/stubs/template_util.h",
159     "src/google/protobuf/stubs/type_traits.h",
160     "src/google/protobuf/text_format.cc",
161     "src/google/protobuf/text_format.h",
162     "src/google/protobuf/wire_format.cc",
163     "src/google/protobuf/wire_format.h",
165     # This file pulls in zlib, but it's not actually used by protoc, so
166     # instead of compiling zlib for the host, let's just exclude this.
167     # "src/src/google/protobuf/io/gzip_stream.cc",
168     "src/google/protobuf/compiler/importer.cc",
169     "src/google/protobuf/compiler/parser.cc",
170     "src/google/protobuf/io/printer.cc",
171     "src/google/protobuf/io/tokenizer.cc",
172     "src/google/protobuf/io/zero_copy_stream_impl.cc",
173   ]
175   configs -= [ "//build/config/compiler:chromium_code" ]
176   configs += [ "//build/config/compiler:no_chromium_code" ]
177   if (is_win) {
178     configs -= [ "//build/config/win:lean_and_mean" ]
179   }
180   public_configs = [
181     ":protobuf_config",
183     # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
184     "//build/config/compiler:no_size_t_to_int_warning",
185   ]
187   cflags = protobuf_lite_cflags
190 # Only compile the compiler for the host architecture.
191 if (current_toolchain == host_toolchain) {
192   executable("protoc") {
193     sources = [
194       "src/google/protobuf/compiler/code_generator.cc",
195       "src/google/protobuf/compiler/command_line_interface.cc",
196       "src/google/protobuf/compiler/cpp/cpp_enum.cc",
197       "src/google/protobuf/compiler/cpp/cpp_enum.h",
198       "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
199       "src/google/protobuf/compiler/cpp/cpp_enum_field.h",
200       "src/google/protobuf/compiler/cpp/cpp_extension.cc",
201       "src/google/protobuf/compiler/cpp/cpp_extension.h",
202       "src/google/protobuf/compiler/cpp/cpp_field.cc",
203       "src/google/protobuf/compiler/cpp/cpp_field.h",
204       "src/google/protobuf/compiler/cpp/cpp_file.cc",
205       "src/google/protobuf/compiler/cpp/cpp_file.h",
206       "src/google/protobuf/compiler/cpp/cpp_generator.cc",
207       "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
208       "src/google/protobuf/compiler/cpp/cpp_helpers.h",
209       "src/google/protobuf/compiler/cpp/cpp_message.cc",
210       "src/google/protobuf/compiler/cpp/cpp_message.h",
211       "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
212       "src/google/protobuf/compiler/cpp/cpp_message_field.h",
213       "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
214       "src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
215       "src/google/protobuf/compiler/cpp/cpp_service.cc",
216       "src/google/protobuf/compiler/cpp/cpp_service.h",
217       "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
218       "src/google/protobuf/compiler/cpp/cpp_string_field.h",
219       "src/google/protobuf/compiler/java/java_enum.cc",
220       "src/google/protobuf/compiler/java/java_enum.h",
221       "src/google/protobuf/compiler/java/java_enum_field.cc",
222       "src/google/protobuf/compiler/java/java_enum_field.h",
223       "src/google/protobuf/compiler/java/java_extension.cc",
224       "src/google/protobuf/compiler/java/java_extension.h",
225       "src/google/protobuf/compiler/java/java_field.cc",
226       "src/google/protobuf/compiler/java/java_field.h",
227       "src/google/protobuf/compiler/java/java_file.cc",
228       "src/google/protobuf/compiler/java/java_file.h",
229       "src/google/protobuf/compiler/java/java_generator.cc",
230       "src/google/protobuf/compiler/java/java_helpers.cc",
231       "src/google/protobuf/compiler/java/java_helpers.h",
232       "src/google/protobuf/compiler/java/java_message.cc",
233       "src/google/protobuf/compiler/java/java_message.h",
234       "src/google/protobuf/compiler/java/java_message_field.cc",
235       "src/google/protobuf/compiler/java/java_message_field.h",
236       "src/google/protobuf/compiler/java/java_primitive_field.cc",
237       "src/google/protobuf/compiler/java/java_primitive_field.h",
238       "src/google/protobuf/compiler/java/java_service.cc",
239       "src/google/protobuf/compiler/java/java_service.h",
240       "src/google/protobuf/compiler/java/java_string_field.cc",
241       "src/google/protobuf/compiler/java/java_string_field.h",
242       "src/google/protobuf/compiler/main.cc",
243       "src/google/protobuf/compiler/plugin.cc",
244       "src/google/protobuf/compiler/plugin.pb.cc",
245       "src/google/protobuf/compiler/python/python_generator.cc",
246       "src/google/protobuf/compiler/subprocess.cc",
247       "src/google/protobuf/compiler/subprocess.h",
248       "src/google/protobuf/compiler/zip_writer.cc",
249       "src/google/protobuf/compiler/zip_writer.h",
250     ]
252     configs -= [ "//build/config/compiler:chromium_code" ]
253     configs += [ "//build/config/compiler:no_chromium_code" ]
254     if (is_win) {
255       # This is defined internally, don't warn on duplicate.
256       configs -= [ "//build/config/win:lean_and_mean" ]
257     }
259     cflags = protobuf_lite_cflags
261     deps = [
262       ":protobuf_full",
263     ]
264     deps += [ "//build/config/sanitizers:deps" ]
265   }
268 google_python_dir = "$root_out_dir/pyproto/google"
270 copy("copy_google") {
271   sources = [
272     "__init__.py",
273   ]
274   outputs = [
275     "$google_python_dir/{{source_file_part}}",
276   ]
279 copy("copy_google_protobuf") {
280   sources = [
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   outputs = [
303     "$google_python_dir/protobuf/{{source_file_part}}",
304   ]
307 copy("copy_google_protobuf_internal") {
308   sources = [
309     "python/google/protobuf/internal/__init__.py",
310     "python/google/protobuf/internal/api_implementation.py",
311     "python/google/protobuf/internal/containers.py",
312     "python/google/protobuf/internal/cpp_message.py",
313     "python/google/protobuf/internal/decoder.py",
314     "python/google/protobuf/internal/encoder.py",
315     "python/google/protobuf/internal/enum_type_wrapper.py",
316     "python/google/protobuf/internal/generator_test.py",
317     "python/google/protobuf/internal/message_listener.py",
318     "python/google/protobuf/internal/python_message.py",
319     "python/google/protobuf/internal/type_checkers.py",
320     "python/google/protobuf/internal/wire_format.py",
321   ]
322   outputs = [
323     "$google_python_dir/protobuf/internal/{{source_file_part}}",
324   ]
327 group("py_proto") {
328   public_deps = [
329     ":copy_google",
330     ":copy_google_protobuf",
331     ":copy_google_protobuf_internal",
332   ]
334   # Targets that depend on this should depend on the copied data files.
335   data = get_target_outputs(":copy_google")
336   data += get_target_outputs(":copy_google_protobuf")
337   data += get_target_outputs(":copy_google_protobuf_internal")