Skip to content

Commit a37a18f

Browse files
committed
build: make libxml2 handling explicit and use in tests
Address the TODO in the build and unify the libxml2 handling with LLVM/clang. Use the information now and propagate this into the lit configuration so that tests can be made aware of libxml2 status.
1 parent 20733ba commit a37a18f

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

CMakeLists.txt

+5-6
Original file line numberDiff line numberDiff line change
@@ -883,12 +883,11 @@ find_package(PythonInterp REQUIRED)
883883
# Find optional dependencies.
884884
#
885885

886-
# Find libxml.
887-
# FIXME: unify with CLANG_HAVE_LIBXML, which is set in LLVM anyway.
888-
find_package(LibXml2)
889-
option(SWIFT_HAVE_LIBXML
890-
"Whether to build with libxml"
891-
${LIBXML2_FOUND})
886+
if(LLVM_ENABLE_LIBXML2)
887+
find_package(Libxml2 REQUIRED)
888+
else()
889+
find_package(LibXml2)
890+
endif()
892891

893892
# You need libedit linked in order to check if you have el_wgets.
894893
cmake_push_check_state()

test/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ foreach(SDK ${SWIFT_SDKS})
172172
set(validation_test_bin_dir
173173
"${CMAKE_CURRENT_BINARY_DIR}/../validation-test${VARIANT_SUFFIX}")
174174

175+
if(LibXml2_FOUND)
176+
set(SWIFT_HAVE_LIBXML2 TRUE)
177+
else()
178+
set(SWIFT_HAVE_LIBXML2 FALSE)
179+
endif()
180+
175181
swift_configure_lit_site_cfg(
176182
"${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in"
177183
"${test_bin_dir}/lit.site.cfg"

test/IDE/comment_to_xml.swift

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
// RUN: %FileCheck %s -check-prefix=WRONG < %t.txt
77

88
// REQUIRES: no_asan
9+
// REQUIRES: libxml2
910
// WRONG-NOT: CommentXMLInvalid

test/lit.site.cfg.in

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ if "@SWIFT_BUILD_SYNTAXPARSERLIB@" == "TRUE":
9191
if "@SWIFT_ENABLE_SOURCEKIT_TESTS@" == "TRUE":
9292
config.available_features.add('sourcekit')
9393

94+
if "@SWIFT_HAVE_LIBXML2@" == "TRUE":
95+
config.available_features.add('libxml2')
96+
9497
if "@SWIFT_ENABLE_LLD_LINKER@" == "TRUE":
9598
config.android_linker_name = "lld"
9699
else:

tools/swift-ide-test/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ target_link_libraries(swift-ide-test
1111
swiftIDE)
1212

1313
# If libxml2 is available, make it available for swift-ide-test.
14-
if(SWIFT_HAVE_LIBXML)
14+
if(LibXml2_FOUND)
1515
include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
1616
target_link_libraries(swift-ide-test PRIVATE ${LIBXML2_LIBRARIES})
17-
add_definitions(-DSWIFT_HAVE_LIBXML="1")
17+
target_compile_definitions(swift-ide-test PRIVATE SWIFT_HAVE_LIBXML=1)
1818
endif()
1919

2020
# Create a symlink for swift-api-dump.py in the bin directory

0 commit comments

Comments
 (0)