Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge "Upgrade libxml2 to 4f132bc" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sadafebrahimi authored and Gerrit Code Review committed Oct 30, 2023
2 parents 533c93f + 1b0f38f commit 8264890
Show file tree
Hide file tree
Showing 207 changed files with 7,027 additions and 9,326 deletions.
14 changes: 10 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
gcc:
extends: .test
variables:
CONFIG: "--without-tls"
CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=600"

gcc:minimum:
Expand All @@ -20,6 +21,13 @@ gcc:minimum:
BASE_CONFIG: "--with-minimum"
CFLAGS: "-O2"

gcc:medium:
extends: .test
variables:
BASE_CONFIG: "--with-minimum"
CONFIG: "--with-threads --with-tree --with-xpath --with-output --with-html"
CFLAGS: "-O2"

gcc:legacy:
extends: .test
only:
Expand Down Expand Up @@ -47,7 +55,7 @@ clang:asan:
variables:
CONFIG: "--without-python"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,integer -fno-sanitize-recover=all -Wno-error=cast-align"
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,integer -fno-sanitize-recover=all"
UBSAN_OPTIONS: "print_stacktrace=1"
ASAN_SYMBOLIZER_PATH: "$CI_PROJECT_DIR/.gitlab-ci/llvm-symbolizer"

Expand All @@ -58,7 +66,7 @@ clang:msan:
variables:
CONFIG: "--without-python --without-zlib --without-lzma"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory -Wno-error=cast-align"
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory"
MSAN_SYMBOLIZER_PATH: "$CI_PROJECT_DIR/.gitlab-ci/llvm-symbolizer"

.mingw:
Expand Down Expand Up @@ -134,7 +142,6 @@ cmake:linux:clang:shared:
variables:
BUILD_SHARED_LIBS: "ON"
CC: clang
CFLAGS: "-Wno-error=cast-align"
SUFFIX: linux-clang-shared

cmake:linux:clang:static:
Expand All @@ -144,7 +151,6 @@ cmake:linux:clang:static:
variables:
BUILD_SHARED_LIBS: "OFF"
CC: clang
CFLAGS: "-Wno-error=cast-align"
SUFFIX: linux-clang-static

.cmake:mingw:
Expand Down
4 changes: 0 additions & 4 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ cc_defaults {
stl: "none",
export_include_dirs: ["include"],
cflags: [
"-DLIBXML_THREAD_ENABLED=1",

// Poison various things that should not be defined.
"-DLIBXML_LEGACY_ENABLED=NO",
"-DLIBXML_FTP_ENABLED=NO",
Expand Down Expand Up @@ -194,8 +192,6 @@ cc_binary_host {
name: "xmllint",
srcs: ["xmllint.c"],
cflags: [
"-DLIBXML_THREAD_ENABLED=1",

"-Wall",
"-Werror",
],
Expand Down
153 changes: 101 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include(CheckLinkerFlag)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CMakePackageConfigHelpers)
include(FindPkgConfig)
include(GNUInstallDirs)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
Expand Down Expand Up @@ -63,18 +64,6 @@ option(LIBXML2_WITH_XPTR_LOCS "Add support for XPointer locations" OFF)
option(LIBXML2_WITH_ZLIB "Use libz" ON)
set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite")

if(LIBXML2_WITH_ICONV)
find_package(Iconv REQUIRED)
endif()

if(LIBXML2_WITH_ICU)
find_package(ICU REQUIRED COMPONENTS data i18n uc)
endif()

if(LIBXML2_WITH_LZMA)
find_package(LibLZMA REQUIRED)
endif()

if(LIBXML2_WITH_PYTHON)
check_include_files(unistd.h HAVE_UNISTD_H)
check_symbol_exists(F_GETFL fcntl.h HAVE_F_GETFL)
Expand All @@ -84,14 +73,6 @@ if(LIBXML2_WITH_PYTHON)
CACHE PATH "Python bindings install directory")
endif()

if(LIBXML2_WITH_THREADS)
find_package(Threads REQUIRED)
endif()

if(LIBXML2_WITH_ZLIB)
find_package(ZLIB REQUIRED)
endif()

foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB)
if(LIBXML2_${VARIABLE})
set(${VARIABLE} 1)
Expand All @@ -118,16 +99,26 @@ set(PACKAGE_TARNAME "libxml2")
set(PACKAGE_URL "https://gitlab.gnome.org/GNOME/libxml2")
set(PACKAGE_VERSION ${VERSION})

if(LIBLZMA_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES LibLZMA::LibLZMA)
if(LIBXML2_WITH_ICONV)
find_package(Iconv REQUIRED)
endif()

if(LIBXML2_WITH_ICU)
find_package(ICU REQUIRED COMPONENTS data i18n uc)
endif()

if(Threads_FOUND)
if(LIBXML2_WITH_LZMA)
find_package(LibLZMA REQUIRED)
endif()

if(LIBXML2_WITH_THREADS)
find_package(Threads REQUIRED)
set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
endif()

if(ZLIB_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
if(LIBXML2_WITH_ZLIB)
find_package(ZLIB REQUIRED)
endif()

if (NOT MSVC)
Expand Down Expand Up @@ -157,7 +148,6 @@ if (NOT MSVC)
check_include_files(netdb.h HAVE_NETDB_H)
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
check_include_files(poll.h HAVE_POLL_H)
check_function_exists(rand_r HAVE_RAND_R)
check_library_exists(dld shl_load "" HAVE_SHLLOAD)
check_function_exists(stat HAVE_STAT)
check_include_files(stdint.h HAVE_STDINT_H)
Expand Down Expand Up @@ -207,6 +197,30 @@ if (NOT MSVC)
endif()
endif()

check_c_source_compiles(
"_Thread_local int v; int main(){return 0;}"
XML_THREAD_LOCAL_C11
)
if (XML_THREAD_LOCAL_C11)
set(XML_THREAD_LOCAL "_Thread_local")
else()
check_c_source_compiles(
"__thread int v; int main(){return 0;}"
XML_THREAD_LOCAL_THREAD
)
if (XML_THREAD_LOCAL_THREAD)
set(XML_THREAD_LOCAL "__thread")
else()
check_c_source_compiles(
"__declspec(thread) int v; int main(){return 0;}"
XML_THREAD_LOCAL_DECLSPEC
)
if (XML_THREAD_LOCAL_DECLSPEC)
set(XML_THREAD_LOCAL "__declspec(thread)")
endif()
endif()
endif()

set(
LIBXML2_HDRS
include/libxml/c14n.h
Expand Down Expand Up @@ -325,26 +339,6 @@ add_library(LibXml2::LibXml2 ALIAS LibXml2)

target_compile_definitions(LibXml2 PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")

if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(LibXml2 PUBLIC LIBXML_STATIC)
set(XML_CFLAGS "-DLIBXML_STATIC")
endif()

if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wshadow \
-Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return \
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline \
-Wredundant-decls -Wno-long-long -Wno-format-extra-args")

if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
check_linker_flag(C "LINKER:--undefined-version" FLAG_UNDEFINED_VERSION)
if (FLAG_UNDEFINED_VERSION)
target_link_options(LibXml2 PRIVATE "LINKER:--undefined-version")
endif()
target_link_options(LibXml2 PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms")
endif()
endif()

if(LIBXML2_WITH_THREADS)
target_compile_definitions(LibXml2 PRIVATE _REENTRANT)
if(NOT WIN32)
Expand Down Expand Up @@ -392,25 +386,61 @@ endif()
if(LIBXML2_WITH_ICU)
target_link_libraries(LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc)
if(WIN32)
set(ICU_LIBS "-licudt -licuin -licuuc")
set(ICU_LDFLAGS "-licudt -licuin -licuuc")
else()
set(ICU_LDFLAGS "-licudata -licui18n -licuuc")
endif()
list(APPEND XML_PRIVATE_LIBS "${ICU_LDFLAGS}")
pkg_check_modules(ICU_PC IMPORTED_TARGET icu-i18n)
if(ICU_PC_FOUND)
list(APPEND XML_PC_REQUIRES icu-i18n)
else()
set(ICU_LIBS "-licudata -licui18n -licuuc")
list(APPEND XML_PC_LIBS "${ICU_LDFLAGS}")
endif()
endif()

if(LIBXML2_WITH_LZMA)
target_link_libraries(LibXml2 PRIVATE LibLZMA::LibLZMA)
set(LZMA_LIBS "-llzma")
set(LibLZMA_LDFLAGS "-llzma")
list(APPEND XML_PRIVATE_LIBS "${LibLZMA_LDFLAGS}")
pkg_check_modules(LibLZMA_PC IMPORTED_TARGET liblzma)
if(LibLZMA_PC_FOUND)
list(APPEND XML_PC_REQUIRES liblzma)
else()
list(APPEND XML_PC_LIBS "${LibLZMA_LDFLAGS}")
endif()
endif()

if(LIBXML2_WITH_THREADS)
target_link_libraries(LibXml2 PRIVATE Threads::Threads)
set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
endif()

if(LIBXML2_WITH_ZLIB)
target_link_libraries(LibXml2 PRIVATE ZLIB::ZLIB)
set(Z_LIBS "-lz")
set(ZLIB_LDFLAGS "-lz")
list(APPEND XML_PRIVATE_LIBS "${ZLIB_LDFLAGS}")
pkg_check_modules(ZLIB_PC IMPORTED_TARGET zlib)
if(ZLIB_PC_FOUND)
list(APPEND XML_PC_REQUIRES zlib)
else()
list(APPEND XML_PC_LIBS "${ZLIB_LDFLAGS}")
endif()
endif()

if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
# These compiler flags can break the checks above so keep them here.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wshadow \
-Wpointer-arith -Wcast-align -Wwrite-strings \
-Wstrict-prototypes -Wmissing-prototypes \
-Wno-long-long -Wno-format-extra-args")

if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
check_linker_flag(C "LINKER:--undefined-version" FLAG_UNDEFINED_VERSION)
if (FLAG_UNDEFINED_VERSION)
target_link_options(LibXml2 PRIVATE "LINKER:--undefined-version")
endif()
target_link_options(LibXml2 PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms")
endif()
endif()

set_target_properties(
Expand Down Expand Up @@ -625,10 +655,29 @@ if(LIBXML2_WITH_PYTHON)
configure_file(python/setup.py.in setup.py @ONLY)
endif()

set(NON_PC_LIBS "${THREAD_LIBS} ${ICONV_LIBS} ${LIBM} ${WINSOCK_LIBS}")
list(APPEND XML_PC_LIBS "${NON_PC_LIBS}")
list(APPEND XML_PRIVATE_LIBS "${NON_PC_LIBS}")
list(REMOVE_DUPLICATES XML_PC_LIBS)
list(REMOVE_DUPLICATES XML_PRIVATE_LIBS)

list(JOIN XML_PC_REQUIRES " " XML_PC_REQUIRES)
list(JOIN XML_PC_LIBS " " XML_PC_LIBS)
list(JOIN XML_PRIVATE_LIBS " " XML_PRIVATE_LIBS)

set(XML_INCLUDEDIR "-I\${includedir}/libxml2")
set(XML_LIBDIR "-L\${libdir}")
set(XML_LIBS "-lxml2")
set(XML_PRIVATE_LIBS "${Z_LIBS} ${LZMA_LIBS} ${THREAD_LIBS} ${ICONV_LIBS} ${ICU_LIBS} ${LIBM} ${WINSOCK_LIBS}")

if(BUILD_SHARED_LIBS)
set(XML_PC_PRIVATE ".private")
set(XML_PC_LIBS_PRIVATE "
Libs.private:")
else()
target_compile_definitions(LibXml2 PUBLIC LIBXML_STATIC)
set(XML_CFLAGS "-DLIBXML_STATIC")
set(XML_PRIVATE_LIBS_NO_SHARED "${XML_PRIVATE_LIBS}")
endif()

file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}")
Expand Down
2 changes: 1 addition & 1 deletion Copyright
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Except where otherwise noted in the source code (e.g. the files hash.c,
Except where otherwise noted in the source code (e.g. the files dict.c,
list.c and the trio files, which are covered by a similar licence but
with different Copyright notices) all the files are:

Expand Down
Loading

0 comments on commit 8264890

Please sign in to comment.