Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libxml2: Migrate to CMake #48

Merged
merged 9 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ Linking static libraries containing Objective-C categories into an executable or

## Building the Toolchain

The toolchain requires Windows 10 version 1903 or later.

### Prerequisites

Building the toolchain require the following tools to be installed and available in the PATH. Their presence is verified when building the toolchain.
Building the toolchain requires the following tools to be installed and available in the PATH. Their presence is verified when building the toolchain.

The MSYS2 installation is required to provide the Bash shell and Unix tools required to build some of the libraries, but no MinGW packages are needed. The Windows Clang installation is used to build all libraries.

Expand Down
49 changes: 34 additions & 15 deletions patches/libxml2-windows-icu.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 723e2344..c513872e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,7 +102,7 @@ if(LIBXML2_WITH_ICONV)
endif()

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

if(LIBXML2_WITH_LZMA)
@@ -368,9 +368,9 @@ if(LIBXML2_WITH_ICONV)
endif()

if(LIBXML2_WITH_ICU)
- target_link_libraries(LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc)
+ target_link_libraries(LibXml2 PRIVATE ICU::i18n ICU::uc)
if(WIN32)
- set(ICU_LDFLAGS "-licudt -licuin -licuuc")
+ set(ICU_LDFLAGS "-licu")
else()
set(ICU_LDFLAGS "-licudata -licui18n -licuuc")
endif()
@@ -433,7 +433,6 @@ set_target_properties(
IMPORT_PREFIX lib
OUTPUT_NAME xml2
POSITION_INDEPENDENT_CODE ON
- PREFIX lib
VERSION ${PROJECT_VERSION}
SOVERSION ${LIBXML_MAJOR_VERSION}
)
diff --git a/encoding.c b/encoding.c
index 52bc15ac..99232887 100644
index 04c24e42..74305989 100644
--- a/encoding.c
+++ b/encoding.c
@@ -45,7 +45,7 @@
Expand All @@ -11,17 +44,3 @@ index 52bc15ac..99232887 100644
/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
#define ICU_PIVOT_BUF_SIZE 1024
typedef struct _uconv_t uconv_t;
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index 7cc25b84..107c180b 100644
--- a/win32/Makefile.msvc
+++ b/win32/Makefile.msvc
@@ -71,7 +71,7 @@ LIBS = $(LIBS) iconv.lib
!if "$(STATIC)" == "1"
LIBS = $(LIBS) advapi32.lib sicuuc.lib sicuin.lib sicudt.lib
!else
-LIBS = $(LIBS) icuuc.lib icuin.lib icudt.lib
+LIBS = $(LIBS) icu.lib
!endif
!endif
!if "$(WITH_ZLIB)" == "1"

42 changes: 19 additions & 23 deletions phases/16-libxml2.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,32 @@ for /f "usebackq delims=" %%i in (`call %BASH% '../scripts/get-latest-github-rel
:: load environment and prepare project
call "%~dp0\..\scripts\common.bat" prepare_project || exit /b 1

cd "%SRCROOT%\%PROJECT%" || exit \b 1
cd "win32" || exit /b 1
set BUILD_DIR="%SRCROOT%\%PROJECT%\build-%ARCH%-%BUILD_TYPE%"
if exist "%BUILD_DIR%" (rmdir /S /Q "%BUILD_DIR%" || exit /b 1)
mkdir "%BUILD_DIR%" || exit /b 1
cd "%BUILD_DIR%" || exit /b 1

SET UM_INCLUDE_DIR="%WindowsSdkDir%include\%WindowsSdkVersion%um"

echo.
echo ### Running configure
set CONFIGURE_OPTS=
if "%BUILD_TYPE%" == "Debug" (
set "CONFIGURE_OPTS=cruntime=/MDd debug=yes"
)
cscript configure.js ^
compiler=msvc ^
icu=yes xml_debug=no ^
%CONFIGURE_OPTS% ^
"prefix=%INSTALL_PREFIX%" ^
"include=%INSTALL_PREFIX%\include" ^
"lib=%INSTALL_PREFIX%\lib" ^
"sodir=%INSTALL_PREFIX%\lib" ^
echo ### Running cmake
cmake .. %CMAKE_OPTIONS% ^
-D BUILD_SHARED_LIBS=NO ^
-D LIBXML2_WITH_LZMA=NO ^
-D LIBXML2_WITH_PYTHON=NO ^
-D LIBXML2_WITH_ZLIB=NO ^
-D LIBXML2_WITH_TESTS=NO ^
-D LIBXML2_WITH_PROGRAMS=NO ^
-D LIBXML2_WITH_ICU=YES ^
-D ICU_INCLUDE_DIR=%UM_INCLUDE_DIR% ^
|| exit /b 1

echo.
echo ### Building
:: we only build the static library
nmake /f Makefile.msvc libxmla || exit /b 1
ninja || exit /b 1

echo.
echo ### Installing
:: rename libxml2_a.lib to xml2.lib to allow linking using -lxml2
:: (the wildcard suffix is required to suppress the "file or directory" prompt)
xcopy /Y /F "bin.msvc\libxml2_a.lib" "%INSTALL_PREFIX%\lib\xml2.lib*" || exit /b 1
xcopy /Y /F "%SRCROOT%\%PROJECT%\include\libxml\*.h" "%INSTALL_PREFIX%\include\libxml\" || exit /b 1

:: write pkgconfig file
call "%~dp0\..\scripts\common.bat" write_pkgconfig libxml-2.0 %TAG% -DLIBXML_STATIC -lxml2 -licu || exit /b 1
:: libxml2-export.cmake is generated while installing libxml2
ninja install || exit /b 1
1 change: 1 addition & 0 deletions phases/17-libxslt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cscript configure.js ^
%CONFIGURE_OPTS% ^
"prefix=%INSTALL_PREFIX%" ^
"include=%INSTALL_PREFIX%\include" ^
"include=%INSTALL_PREFIX%\include\libxml2" ^
hmelder marked this conversation as resolved.
Show resolved Hide resolved
"lib=%INSTALL_PREFIX%\lib" ^
"sodir=%INSTALL_PREFIX%\lib" ^
|| exit /b 1
Expand Down
Loading