Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / third_party / protobuf / BUILD.gn
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.
4
5 if (is_win) {
6   config_h_dir = "vsprojects"
7 } else {
8   config_h_dir = "."
9 }
10
11 config("protobuf_config") {
12   include_dirs = [
13     "src",
14     config_h_dir,
15   ]
16   defines = [
17     "PROTOBUF_USE_DLLS",
18     "GOOGLE_PROTOBUF_NO_RTTI",
19     "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
20   ]
21
22   if (is_win) {
23     # TODO(jschuh): http://crbug.com/167187 size_t -> int.
24     cflags = [ "/wd4267" ]
25   }
26 }
27
28 # This condif 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     "$root_gen_dir/protoc_out",
33   ]
34 }
35
36 protobuf_lite_sources = [
37   "src/google/protobuf/extension_set.cc",
38   "src/google/protobuf/extension_set.h",
39   "src/google/protobuf/generated_message_util.cc",
40   "src/google/protobuf/generated_message_util.h",
41   "src/google/protobuf/io/coded_stream.cc",
42   "src/google/protobuf/io/coded_stream.h",
43   "src/google/protobuf/io/coded_stream_inl.h",
44   "src/google/protobuf/io/zero_copy_stream.cc",
45   "src/google/protobuf/io/zero_copy_stream.h",
46   "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
47   "src/google/protobuf/io/zero_copy_stream_impl_lite.h",
48   "src/google/protobuf/message_lite.cc",
49   "src/google/protobuf/message_lite.h",
50   "src/google/protobuf/repeated_field.cc",
51   "src/google/protobuf/repeated_field.h",
52   "src/google/protobuf/stubs/atomicops.h",
53   "src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
54   "src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
55   "src/google/protobuf/stubs/atomicops_internals_macosx.h",
56   "src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
57   "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
58   "src/google/protobuf/stubs/atomicops_internals_x86_gcc.h",
59   "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
60   "src/google/protobuf/stubs/atomicops_internals_x86_msvc.h",
61   "src/google/protobuf/stubs/common.cc",
62   "src/google/protobuf/stubs/common.h",
63   "src/google/protobuf/stubs/hash.h",
64   "src/google/protobuf/stubs/map-util.h",
65   "src/google/protobuf/stubs/once.cc",
66   "src/google/protobuf/stubs/once.h",
67   "src/google/protobuf/stubs/platform_macros.h",
68   "src/google/protobuf/unknown_field_set.cc",
69   "src/google/protobuf/unknown_field_set.h",
70   "src/google/protobuf/wire_format_lite.cc",
71   "src/google/protobuf/wire_format_lite.h",
72   "src/google/protobuf/wire_format_lite_inl.h",
73   "$config_h_dir/config.h",
74 ]
75
76 protobuf_lite_cflags = []
77 if (is_win) {
78   protobuf_lite_cflags = [
79     "/wd4018",  # signed/unsigned mismatch in comparison
80     "/wd4244",  # implicit conversion, possible loss of data
81     "/wd4355",  # 'this' used in base member initializer list
82     "/wd4267",  # size_t to int truncation
83     "/wd4291",  # no matching operator delete for a placement new
84   ]
85 }
86
87 source_set("protobuf_lite") {
88   sources = protobuf_lite_sources
89
90   configs -= [ "//build/config/compiler:chromium_code" ]
91   configs += [ "//build/config/compiler:no_chromium_code" ]
92   direct_dependent_configs = [ ":protobuf_config" ]
93
94   cflags = protobuf_lite_cflags
95
96   # Required for component builds. See http://crbug.com/172800.
97   defines = [ "LIBPROTOBUF_EXPORTS" ]
98 }
99
100 # This is the full, heavy protobuf lib that's needed for c++ .protos that don't
101 # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
102 # into that category. Do not use in Chrome code.
103
104 source_set("protobuf_full") {
105   visibility = ":*"  # Prevent people from depending on this outside our file.
106
107   sources = protobuf_lite_sources
108   sources += [
109     "src/google/protobuf/descriptor.h",
110     "src/google/protobuf/descriptor.pb.h",
111     "src/google/protobuf/descriptor_database.h",
112     "src/google/protobuf/dynamic_message.h",
113     "src/google/protobuf/generated_enum_reflection.h",
114     "src/google/protobuf/generated_message_reflection.h",
115     "src/google/protobuf/message.h",
116     "src/google/protobuf/reflection_ops.h",
117     "src/google/protobuf/service.h",
118     "src/google/protobuf/text_format.h",
119     "src/google/protobuf/wire_format.h",
120     "src/google/protobuf/io/gzip_stream.h",
121     "src/google/protobuf/io/printer.h",
122     "src/google/protobuf/io/tokenizer.h",
123     "src/google/protobuf/io/zero_copy_stream_impl.h",
124     "src/google/protobuf/compiler/code_generator.h",
125     "src/google/protobuf/compiler/command_line_interface.h",
126     "src/google/protobuf/compiler/importer.h",
127     "src/google/protobuf/compiler/java/java_doc_comment.cc",
128     "src/google/protobuf/compiler/java/java_doc_comment.h",
129     "src/google/protobuf/compiler/parser.h",
130
131     "src/google/protobuf/stubs/strutil.cc",
132     "src/google/protobuf/stubs/strutil.h",
133     "src/google/protobuf/stubs/substitute.cc",
134     "src/google/protobuf/stubs/substitute.h",
135     "src/google/protobuf/stubs/stl_util.h",
136     "src/google/protobuf/stubs/stringprintf.cc",
137     "src/google/protobuf/stubs/stringprintf.h",
138     "src/google/protobuf/stubs/structurally_valid.cc",
139     "src/google/protobuf/stubs/template_util.h",
140     "src/google/protobuf/stubs/type_traits.h",
141
142     "src/google/protobuf/descriptor.cc",
143     "src/google/protobuf/descriptor.pb.cc",
144     "src/google/protobuf/descriptor_database.cc",
145     "src/google/protobuf/dynamic_message.cc",
146     "src/google/protobuf/extension_set_heavy.cc",
147     "src/google/protobuf/generated_message_reflection.cc",
148     "src/google/protobuf/message.cc",
149     "src/google/protobuf/reflection_ops.cc",
150     "src/google/protobuf/service.cc",
151     "src/google/protobuf/text_format.cc",
152     "src/google/protobuf/wire_format.cc",
153     # This file pulls in zlib, but it's not actually used by protoc, so
154     # instead of compiling zlib for the host, let's just exclude this.
155     # "src/src/google/protobuf/io/gzip_stream.cc",
156     "src/google/protobuf/io/printer.cc",
157     "src/google/protobuf/io/tokenizer.cc",
158     "src/google/protobuf/io/zero_copy_stream_impl.cc",
159     "src/google/protobuf/compiler/importer.cc",
160     "src/google/protobuf/compiler/parser.cc",
161   ]
162
163   configs -= [ "//build/config/compiler:chromium_code" ]
164   configs += [ "//build/config/compiler:no_chromium_code" ]
165   direct_dependent_configs = [ ":protobuf_config" ]
166
167   cflags = protobuf_lite_cflags
168 }
169
170 # Only compile the compiler for the host architecture.
171 if (current_toolchain == host_toolchain) {
172   executable("protoc") {
173     sources = [
174       "src/google/protobuf/compiler/code_generator.cc",
175       "src/google/protobuf/compiler/command_line_interface.cc",
176       "src/google/protobuf/compiler/plugin.cc",
177       "src/google/protobuf/compiler/plugin.pb.cc",
178       "src/google/protobuf/compiler/subprocess.cc",
179       "src/google/protobuf/compiler/subprocess.h",
180       "src/google/protobuf/compiler/zip_writer.cc",
181       "src/google/protobuf/compiler/zip_writer.h",
182       "src/google/protobuf/compiler/cpp/cpp_enum.cc",
183       "src/google/protobuf/compiler/cpp/cpp_enum.h",
184       "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
185       "src/google/protobuf/compiler/cpp/cpp_enum_field.h",
186       "src/google/protobuf/compiler/cpp/cpp_extension.cc",
187       "src/google/protobuf/compiler/cpp/cpp_extension.h",
188       "src/google/protobuf/compiler/cpp/cpp_field.cc",
189       "src/google/protobuf/compiler/cpp/cpp_field.h",
190       "src/google/protobuf/compiler/cpp/cpp_file.cc",
191       "src/google/protobuf/compiler/cpp/cpp_file.h",
192       "src/google/protobuf/compiler/cpp/cpp_generator.cc",
193       "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
194       "src/google/protobuf/compiler/cpp/cpp_helpers.h",
195       "src/google/protobuf/compiler/cpp/cpp_message.cc",
196       "src/google/protobuf/compiler/cpp/cpp_message.h",
197       "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
198       "src/google/protobuf/compiler/cpp/cpp_message_field.h",
199       "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
200       "src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
201       "src/google/protobuf/compiler/cpp/cpp_service.cc",
202       "src/google/protobuf/compiler/cpp/cpp_service.h",
203       "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
204       "src/google/protobuf/compiler/cpp/cpp_string_field.h",
205       "src/google/protobuf/compiler/java/java_enum.cc",
206       "src/google/protobuf/compiler/java/java_enum.h",
207       "src/google/protobuf/compiler/java/java_enum_field.cc",
208       "src/google/protobuf/compiler/java/java_enum_field.h",
209       "src/google/protobuf/compiler/java/java_extension.cc",
210       "src/google/protobuf/compiler/java/java_extension.h",
211       "src/google/protobuf/compiler/java/java_field.cc",
212       "src/google/protobuf/compiler/java/java_field.h",
213       "src/google/protobuf/compiler/java/java_file.cc",
214       "src/google/protobuf/compiler/java/java_file.h",
215       "src/google/protobuf/compiler/java/java_generator.cc",
216       "src/google/protobuf/compiler/java/java_helpers.cc",
217       "src/google/protobuf/compiler/java/java_helpers.h",
218       "src/google/protobuf/compiler/java/java_message.cc",
219       "src/google/protobuf/compiler/java/java_message.h",
220       "src/google/protobuf/compiler/java/java_message_field.cc",
221       "src/google/protobuf/compiler/java/java_message_field.h",
222       "src/google/protobuf/compiler/java/java_primitive_field.cc",
223       "src/google/protobuf/compiler/java/java_primitive_field.h",
224       "src/google/protobuf/compiler/java/java_service.cc",
225       "src/google/protobuf/compiler/java/java_service.h",
226       "src/google/protobuf/compiler/java/java_string_field.cc",
227       "src/google/protobuf/compiler/java/java_string_field.h",
228       "src/google/protobuf/compiler/python/python_generator.cc",
229       "src/google/protobuf/compiler/main.cc",
230     ]
231
232     configs -= [ "//build/config/compiler:chromium_code" ]
233     configs += [ "//build/config/compiler:no_chromium_code" ]
234     if (is_win) {
235       # This is defined internally, don't warn on duplicate.
236       configs -= [ "//build/config/win:lean_and_mean" ]
237     }
238
239     cflags = protobuf_lite_cflags
240
241     deps = [
242       ":protobuf_full",
243     ]
244   }
245 }