# Copyright 2013 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/cast.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_castos) || is_chromeos) && !use_fuzzing_engine) {
config("expat_config") {
libs = [ "expat" ]
}
group("expat") {
public_configs = [ ":expat_config" ]
}
} else {
config("expat_public_config") {
include_dirs = [
"src/expat/lib",
"include/expat_config",
]
defines = [ "XML_STATIC" ]
}
config("expat_internal_config") {
cflags = [
# xmlparse.c has some |if (0 && ...)| statements.
"-Wno-unreachable-code",
# Various files have fallthrough annotated with comments instead of
# attributes, and switching to attributes is difficult.
"-Wno-implicit-fallthrough",
]
}
static_library("expat") {
sources = [
"src/expat/lib/expat.h",
"src/expat/lib/xmlparse.c",
"src/expat/lib/xmlrole.c",
"src/expat/lib/xmltok.c",
]
public_configs = [ ":expat_public_config" ]
configs += [ ":expat_internal_config" ]
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"
}