BUILD.gn 8.7 KB

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