From 79e8df3e186ff1b3598bd8f1e3633d99164ef9ab Mon Sep 17 00:00:00 2001 From: hmelder Date: Tue, 18 Jun 2024 19:10:17 -0700 Subject: [PATCH 1/8] libxml2: Use CMake --- patches/opt-libxml2-windows-icu.patch | 27 -------------- phases/16-libxml2.bat | 51 ++++++++++----------------- phases/17-libxslt.bat | 1 + 3 files changed, 19 insertions(+), 60 deletions(-) delete mode 100644 patches/opt-libxml2-windows-icu.patch diff --git a/patches/opt-libxml2-windows-icu.patch b/patches/opt-libxml2-windows-icu.patch deleted file mode 100644 index 4355a91..0000000 --- a/patches/opt-libxml2-windows-icu.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/encoding.c b/encoding.c -index 52bc15ac..99232887 100644 ---- a/encoding.c -+++ b/encoding.c -@@ -45,7 +45,7 @@ - #include "private/error.h" - - #ifdef LIBXML_ICU_ENABLED --#include -+#include - /* 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" - \ No newline at end of file diff --git a/phases/16-libxml2.bat b/phases/16-libxml2.bat index 2134bc5..d8badf9 100644 --- a/phases/16-libxml2.bat +++ b/phases/16-libxml2.bat @@ -13,46 +13,31 @@ 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 - -:: check which ICU libraries to link -if exist "%INSTALL_PREFIX%\lib\icuin.lib" ( - set "LIBS_PRIVATE=-licuin -licuuc -licudt" -) else ( - echo Using system-provided ICU DLL ^(requires Windows 10 version 1903 or later^) - git apply "%ROOT_DIR%\patches\opt-libxml2-windows-icu.patch" || exit /b 1 - set "LIBS_PRIVATE=-licu" -) +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 -cd "win32" || 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 "%LIBS_PRIVATE%" || exit /b 1 +:: libxml2-export.cmake is generated while installing libxml2 +ninja install \ No newline at end of file diff --git a/phases/17-libxslt.bat b/phases/17-libxslt.bat index ecd5195..406c384 100644 --- a/phases/17-libxslt.bat +++ b/phases/17-libxslt.bat @@ -27,6 +27,7 @@ cscript configure.js ^ %CONFIGURE_OPTS% ^ "prefix=%INSTALL_PREFIX%" ^ "include=%INSTALL_PREFIX%\include" ^ + "include=%INSTALL_PREFIX%\include\libxml2" ^ "lib=%INSTALL_PREFIX%\lib" ^ "sodir=%INSTALL_PREFIX%\lib" ^ || exit /b 1 From 2ff1a9b600dc98a66bbfbd6c487277a1c588a73d Mon Sep 17 00:00:00 2001 From: hmelder Date: Tue, 18 Jun 2024 19:12:34 -0700 Subject: [PATCH 2/8] Add xml2 patch --- patches/libxml2-windows-icu.patch | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 patches/libxml2-windows-icu.patch diff --git a/patches/libxml2-windows-icu.patch b/patches/libxml2-windows-icu.patch new file mode 100644 index 0000000..07abb3b --- /dev/null +++ b/patches/libxml2-windows-icu.patch @@ -0,0 +1,49 @@ +diff --git a/encoding.c b/encoding.c +index 52bc15ac..99232887 100644 +--- a/encoding.c ++++ b/encoding.c +@@ -45,7 +45,7 @@ + #include "private/error.h" + + #ifdef LIBXML_ICU_ENABLED +-#include ++#include + /* 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" +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 27ddacdc..96bf5e0c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -99,7 +99,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) +@@ -363,7 +363,7 @@ 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") + else() + \ No newline at end of file From c00ff82223e0c8125eedf2224a7315d2a34e47d2 Mon Sep 17 00:00:00 2001 From: hmelder Date: Tue, 18 Jun 2024 19:47:00 -0700 Subject: [PATCH 3/8] libxml2: Remove library prefix --- patches/libxml2-fix-library-prefix.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 patches/libxml2-fix-library-prefix.patch diff --git a/patches/libxml2-fix-library-prefix.patch b/patches/libxml2-fix-library-prefix.patch new file mode 100644 index 0000000..2a3e30a --- /dev/null +++ b/patches/libxml2-fix-library-prefix.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 723e2344..a73c4453 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -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} + ) From f89c2edc364fb308ce8bcecf7952c302241b14f8 Mon Sep 17 00:00:00 2001 From: hmelder Date: Tue, 18 Jun 2024 19:54:30 -0700 Subject: [PATCH 4/8] Mention windows version requirement --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d69dbf8..6c0cd08 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ The toolchain consists of the following libraries: - [libxml2](https://github.com/GNOME/libxml2) - [libxslt](https://github.com/GNOME/libxslt) - [libcurl](https://github.com/curl/curl) -- [ICU](https://docs.microsoft.com/en-us/windows/win32/intl/international-components-for-unicode--icu-) (using system-provided DLL on Windows 10 version 1903 or later) ## Installation @@ -174,9 +173,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. From 9108ff785d8e8042a5dd9b3cdc80605c5e73f347 Mon Sep 17 00:00:00 2001 From: hmelder Date: Tue, 18 Jun 2024 20:18:17 -0700 Subject: [PATCH 5/8] libxml2: use icu.lib on windows --- patches/libxml2-fix-library-prefix.patch | 12 ----- patches/libxml2-windows-icu.patch | 62 ++++++++++++++---------- 2 files changed, 36 insertions(+), 38 deletions(-) delete mode 100644 patches/libxml2-fix-library-prefix.patch diff --git a/patches/libxml2-fix-library-prefix.patch b/patches/libxml2-fix-library-prefix.patch deleted file mode 100644 index 2a3e30a..0000000 --- a/patches/libxml2-fix-library-prefix.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 723e2344..a73c4453 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -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/patches/libxml2-windows-icu.patch b/patches/libxml2-windows-icu.patch index 07abb3b..d517718 100644 --- a/patches/libxml2-windows-icu.patch +++ b/patches/libxml2-windows-icu.patch @@ -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 @@ @@ -12,10 +45,10 @@ index 52bc15ac..99232887 100644 #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 +index ce877a5e..ad9b2197 100644 --- a/win32/Makefile.msvc +++ b/win32/Makefile.msvc -@@ -71,7 +71,7 @@ LIBS = $(LIBS) iconv.lib +@@ -64,7 +64,7 @@ LIBS = $(LIBS) iconv.lib !if "$(STATIC)" == "1" LIBS = $(LIBS) advapi32.lib sicuuc.lib sicuin.lib sicudt.lib !else @@ -24,26 +57,3 @@ index 7cc25b84..107c180b 100644 !endif !endif !if "$(WITH_ZLIB)" == "1" -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 27ddacdc..96bf5e0c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -99,7 +99,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) -@@ -363,7 +363,7 @@ 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") - else() - \ No newline at end of file From ca8cc2634b3e2eead350dc80a0bc95a30d0081bb Mon Sep 17 00:00:00 2001 From: Hugo Melder Date: Thu, 20 Jun 2024 12:09:40 +0200 Subject: [PATCH 6/8] Update phases/16-libxml2.bat Co-authored-by: Frederik Seiffert --- phases/16-libxml2.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phases/16-libxml2.bat b/phases/16-libxml2.bat index d8badf9..310d45a 100644 --- a/phases/16-libxml2.bat +++ b/phases/16-libxml2.bat @@ -40,4 +40,4 @@ ninja || exit /b 1 echo. echo ### Installing :: libxml2-export.cmake is generated while installing libxml2 -ninja install \ No newline at end of file +ninja install || exit /b 1 \ No newline at end of file From 6d8eea7725bac67aec8348e386356b69000009c6 Mon Sep 17 00:00:00 2001 From: Hugo Melder Date: Thu, 20 Jun 2024 12:10:12 +0200 Subject: [PATCH 7/8] Fix indentation Co-authored-by: Frederik Seiffert --- phases/16-libxml2.bat | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phases/16-libxml2.bat b/phases/16-libxml2.bat index 310d45a..661eead 100644 --- a/phases/16-libxml2.bat +++ b/phases/16-libxml2.bat @@ -23,14 +23,14 @@ SET UM_INCLUDE_DIR="%WindowsSdkDir%include\%WindowsSdkVersion%um" echo. 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% ^ + -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. From f9fc444eb37f55af0a54b57766025ec385849809 Mon Sep 17 00:00:00 2001 From: hmelder Date: Thu, 20 Jun 2024 12:32:17 +0200 Subject: [PATCH 8/8] Remove old Makefile.msvc patch --- patches/libxml2-windows-icu.patch | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/patches/libxml2-windows-icu.patch b/patches/libxml2-windows-icu.patch index d517718..fa8eb07 100644 --- a/patches/libxml2-windows-icu.patch +++ b/patches/libxml2-windows-icu.patch @@ -44,16 +44,3 @@ index 04c24e42..74305989 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 ce877a5e..ad9b2197 100644 ---- a/win32/Makefile.msvc -+++ b/win32/Makefile.msvc -@@ -64,7 +64,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"