summaryrefslogtreecommitdiff
path: root/chromium/third_party/expat/BUILD.gn
blob: 842d0f9ddd0bd2325cd302b8c4294341757fefb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chromecast_build.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

# On Linux, we implicitly already depend on expat via fontconfig;
# let's not pull it in twice.
# Chromecast doesn't ship expat as a system library.
# Libfuzzer and AFL need to build library from sources.
if (is_linux && !is_chromecast && !use_fuzzing_engine) {
  config("expat_config") {
    libs = [ "expat" ]
  }

  group("expat") {
    public_configs = [ ":expat_config" ]
  }
} else {
  config("expat_config") {
    include_dirs = [ "files/lib" ]
    defines = [ "XML_STATIC" ]
  }

  static_library("expat") {
    sources = [
      "files/lib/expat.h",
      "files/lib/xmlparse.c",
      "files/lib/xmlrole.c",
      "files/lib/xmltok.c",
    ]

    public_configs = [ ":expat_config" ]

    # TODO(thakis): Remove this once clang no longer crashes when building
    # libexpat with -Oz.
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]

    defines = [ "_LIB" ]
    if (is_win) {
      # expat expects to define WIN32_LEAN_AND_MEAN itself
      configs -= [ "//build/config/win:lean_and_mean" ]
      defines += [ "COMPILED_FROM_DSP" ]
    } else {
      defines += [ "HAVE_EXPAT_CONFIG_H" ]
    }
  }
}

fuzzer_test("expat_xml_parse_fuzzer") {
  sources = [
    "fuzz/expat_xml_parse_fuzzer.cc",
  ]
  deps = [
    ":expat",
  ]
  dict = "//third_party/libxml/fuzz/xml.dict"
  seed_corpus = "//third_party/libxml/fuzz/seed_corpus"
}