Use third party libxml
[platform/framework/web/chromium-efl.git] / third_party / libxml / BUILD.gn
1 # Copyright 2013 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 # Define an "os_include" variable that points at the OS-specific generated
6 # headers.  These were generated by running the configure script offline.
7 if (is_linux || is_chromeos || is_android || is_nacl || is_fuchsia || is_tizen) {
8   os_include = "linux"
9 } else if (is_apple) {
10   os_include = "mac"
11 } else if (is_win) {
12   os_include = "win32"
13 }
14
15 import("//third_party/libxml/libxml_visibility.gni")
16
17 config("libxml_config") {
18   # Define LIBXML_STATIC as nothing to match how libxml.h (an internal header)
19   # defines LIBXML_STATIC, otherwise we get the macro redefined warning from
20   # GCC. ("defines" does "-DFOO" which defines the macro FOO as 1.)
21   cflags = [ "-DLIBXML_STATIC=" ]
22
23   include_dirs = [
24     "src/include",
25     "$os_include/include",
26   ]
27 }
28
29 config("libxml_warnings") {
30   if (is_win) {
31     cflags_c = [
32       "/wd4018",  # Signed/unsigned mismatch in comparison.
33       "/wd4267",  # TODO(brucedawson): http://crbug.com/554200 fix C4267
34       "/wd4311",  # and C4311 warnings.
35     ]
36   }
37   if (is_clang) {
38     cflags = [
39       # libxml passes `const unsigned char*` through `const char*`.
40       "-Wno-pointer-sign",
41
42       # pattern.c and uri.c both have an intentional `for (...);` /
43       # `while(...);` loop. I submitted a patch to move the `'` to its own
44       # line, but until that's landed suppress the warning:
45       "-Wno-empty-body",
46
47       # debugXML.c compares array 'arg' to NULL.
48       "-Wno-tautological-pointer-compare",
49
50       # threads.c attempts to forward declare a pthread_equal which doesn't
51       # match the prototype in pthreads.h
52       "-Wno-ignored-attributes",
53
54       # libxml casts from int to long to void*.
55       "-Wno-int-to-void-pointer-cast",
56
57       # libxml passes a volatile LPCRITICAL_SECTION* to a function expecting
58       # a void* volatile*.
59       "-Wno-incompatible-pointer-types",
60
61       # trio_is_special_quantity and trio_is_negative are only
62       # used with certain preprocessor defines set.
63       "-Wno-unused-function",
64
65       # Comparison between xmlElementType and xmlXPathTypeVal.
66       # TODO(hans): See if we can fix upstream (http://crbug.com/763944).
67       "-Wno-enum-compare",
68     ]
69   } else if (is_linux || is_chromeos) {
70     cflags = [
71       # gcc spits out a bunch of warnings about passing too many arguments to
72       # __xmlSimpleError.
73       "-Wno-format-extra-args",
74     ]
75   }
76 }
77
78 # Please keep in sync with //build/linux/unbundle/libxml.gn.
79 static_library("xml_reader") {
80   # Do not expand this visibility list without first consulting with the
81   # Security Team.
82   visibility = [
83     "//base/test:test_support",
84     "//components/policy/core/common:unit_tests",
85     "//services/data_decoder:*",
86   ]
87   if (is_win) {
88     visibility += [ "//components/wifi" ]
89   }
90   sources = [
91     "chromium/xml_reader.cc",
92     "chromium/xml_reader.h",
93   ]
94   deps = [
95     ":libxml",
96     ":libxml_utils",
97   ]
98   configs += [ ":libxml_config" ]
99 }
100
101 # Please keep in sync with //build/linux/unbundle/libxml.gn.
102 static_library("xml_writer") {
103   # The XmlWriter is considered safe to use from any target.
104   visibility = [ "*" ]
105   sources = [
106     "chromium/xml_writer.cc",
107     "chromium/xml_writer.h",
108   ]
109   deps = [
110     ":libxml",
111     ":libxml_utils",
112   ]
113   configs += [ ":libxml_config" ]
114 }
115
116 # Please keep in sync with //build/linux/unbundle/libxml.gn.
117 static_library("libxml_utils") {
118   # Do not expand this visibility list without first consulting with the
119   # Security Team.
120   visibility = [
121     ":xml_reader",
122     ":xml_writer",
123     "//base/test:test_support",
124     "//services/data_decoder:lib",
125     "//services/data_decoder:xml_parser_fuzzer_deps",
126   ]
127   sources = [
128     "chromium/libxml_utils.cc",
129     "chromium/libxml_utils.h",
130   ]
131   deps = [ ":libxml" ]
132   public_deps = [ "//third_party/icu:icuuc" ]
133   public_configs = [ ":libxml_config" ]
134 }
135
136 static_library("libxml") {
137   # Do not expand this visibility list without first consulting with the
138   # Security Team.
139   visibility = [
140     ":libxml_utils",
141     ":xml_reader",
142     ":xml_writer",
143     "//chromecast/internal",
144     "//testing/libfuzzer/*",
145     "//third_party/blink/renderer/*",
146     "//third_party/fontconfig",
147     "//third_party/libxslt",
148     "//third_party/maldoca/*",
149   ]
150   if (is_ios) {
151     foreach(tgt, ios_libxml_visibility_additions) {
152       visibility += [ "//ios_internal/$tgt" ]
153     }
154   }
155
156   output_name = "libxml2"
157
158   # Commented out sources are libxml2 files we do not want to include. They are
159   # here to make it easy to identify files which are new.
160   sources = [
161     "src/HTMLparser.c",
162     "src/HTMLtree.c",
163
164     #"src/SAX.c",
165     "src/SAX2.c",
166     "src/buf.c",
167
168     #"src/c14n.c",
169     #"src/catalog.c",
170     "src/chvalid.c",
171
172     #"src/debugXML.c",
173     "src/dict.c",
174     "src/encoding.c",
175     "src/entities.c",
176     "src/error.c",
177     "src/globals.c",
178     "src/hash.c",
179     "src/include/libxml/HTMLparser.h",
180     "src/include/libxml/HTMLtree.h",
181     "src/include/libxml/SAX.h",
182     "src/include/libxml/SAX2.h",
183     "src/include/libxml/c14n.h",
184     "src/include/libxml/catalog.h",
185     "src/include/libxml/chvalid.h",
186     "src/include/libxml/debugXML.h",
187     "src/include/libxml/dict.h",
188     "src/include/libxml/encoding.h",
189     "src/include/libxml/entities.h",
190     "src/include/libxml/globals.h",
191     "src/include/libxml/hash.h",
192     "src/include/libxml/list.h",
193     "src/include/libxml/nanoftp.h",
194     "src/include/libxml/nanohttp.h",
195     "src/include/libxml/parser.h",
196     "src/include/libxml/parserInternals.h",
197     "src/include/libxml/pattern.h",
198     "src/include/libxml/relaxng.h",
199     "src/include/libxml/schemasInternals.h",
200     "src/include/libxml/schematron.h",
201     "src/include/libxml/threads.h",
202     "src/include/libxml/tree.h",
203     "src/include/libxml/uri.h",
204     "src/include/libxml/valid.h",
205     "src/include/libxml/xinclude.h",
206     "src/include/libxml/xlink.h",
207     "src/include/libxml/xmlIO.h",
208     "src/include/libxml/xmlautomata.h",
209     "src/include/libxml/xmlerror.h",
210     "src/include/libxml/xmlexports.h",
211     "src/include/libxml/xmlmemory.h",
212     "src/include/libxml/xmlmodule.h",
213     "src/include/libxml/xmlreader.h",
214     "src/include/libxml/xmlregexp.h",
215     "src/include/libxml/xmlsave.h",
216     "src/include/libxml/xmlschemas.h",
217     "src/include/libxml/xmlschemastypes.h",
218     "src/include/libxml/xmlstring.h",
219     "src/include/libxml/xmlunicode.h",
220     "src/include/libxml/xmlwriter.h",
221     "src/include/libxml/xpath.h",
222     "src/include/libxml/xpathInternals.h",
223     "src/include/libxml/xpointer.h",
224
225     #"src/legacy.c",
226     "src/libxml.h",
227     "src/list.c",
228     "src/parser.c",
229     "src/parserInternals.c",
230     "src/pattern.c",
231
232     #"src/relaxng.c",
233
234     #"src/schematron.c",
235     "src/threads.c",
236     "src/timsort.h",
237     "src/tree.c",
238     "src/triodef.h",
239     "src/trionan.h",
240
241     #"src/trio.c",
242     #"src/trio.h",
243     #"src/triodef.h",
244     # Note: xpath.c #includes trionan.c
245     #"src/trionan.c",
246     #"src/triop.h",
247     #"src/triostr.c",
248     #"src/triostr.h",
249     "src/uri.c",
250     "src/valid.c",
251
252     #"src/xinclude.c",
253     #"src/xlink.c",
254     "src/xmlIO.c",
255     "src/xmlmemory.c",
256
257     #"src/xmlmodule.c",
258     "src/xmlreader.c",
259
260     #"src/xmlregexp.c",
261     "src/xmlsave.c",
262
263     #"src/xmlschemas.c",
264     #"src/xmlschemastypes.c",
265     "src/xmlstring.c",
266     "src/xmlunicode.c",
267     "src/xmlwriter.c",
268     "src/xpath.c",
269
270     #"src/xpointer.c",
271     #"src/xzlib.c",
272   ]
273
274   configs -= [ "//build/config/compiler:chromium_code" ]
275   configs += [
276     "//build/config/compiler:no_chromium_code",
277
278     # Must be after no_chromium_code for warning flags to be ordered correctly.
279     ":libxml_warnings",
280   ]
281
282   if (is_linux || is_chromeos) {
283     sources += [
284       "linux/config.h",
285       "linux/include/libxml/xmlversion.h",
286     ]
287   }
288
289   if (is_mac) {
290     sources += [
291       "mac/config.h",
292       "mac/include/libxml/xmlversion.h",
293     ]
294   }
295
296   if (is_win) {
297     sources += [
298       "src/include/win32config.h",
299       "src/include/wsockcompat.h",
300       "win32/config.h",
301       "win32/include/libxml/xmlversion.h",
302     ]
303
304     # libxml2 already defines WIN32_LEAN_AND_MEAN.
305     configs -= [ "//build/config/win:lean_and_mean" ]
306   }
307
308   sources += [ "chromium/disabled_libxml_features.cc" ]
309
310   public_configs = [ ":libxml_config" ]
311   public_deps = [ "//third_party/icu:icuuc" ]
312   deps = [ "//third_party/zlib" ]
313
314   if (is_apple || is_android || is_fuchsia) {
315     # http://www.xmlsoft.org/threads.html says that this is required when using
316     # libxml from several threads, which can possibly happen in chrome. On
317     # linux, this is picked up by transitivity from pkg-config output from
318     # build/linux/system.gyp.
319     defines = [ "_REENTRANT" ]
320   }
321
322   include_dirs = [ "$os_include" ]
323 }