From 20ac790c4283337627f3955b639ab2d064610a84 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Fri, 25 Oct 2024 12:10:45 +0200 Subject: [PATCH] libxslt: migrate to CMake --- patches/libxml2-windows-icu.patch | 30 ++++++++++++++-- patches/libxslt-fix-config-include.patch | 26 ++++++++++++++ patches/libxslt-fix-library-name.patch | 20 +++++++++++ patches/libxslt-fix-pkgconfig.patch | 15 ++++++++ phases/16-libxml2.bat | 5 +-- phases/17-libxslt.bat | 45 ++++++++++------------- scripts/common.bat | 46 ------------------------ 7 files changed, 111 insertions(+), 76 deletions(-) create mode 100644 patches/libxslt-fix-config-include.patch create mode 100644 patches/libxslt-fix-library-name.patch create mode 100644 patches/libxslt-fix-pkgconfig.patch diff --git a/patches/libxml2-windows-icu.patch b/patches/libxml2-windows-icu.patch index fa8eb07..1958200 100644 --- a/patches/libxml2-windows-icu.patch +++ b/patches/libxml2-windows-icu.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 723e2344..c513872e 100644 +index f99fd368..4ca6d21a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ if(LIBXML2_WITH_ICONV) @@ -32,7 +32,7 @@ index 723e2344..c513872e 100644 SOVERSION ${LIBXML_MAJOR_VERSION} ) diff --git a/encoding.c b/encoding.c -index 04c24e42..74305989 100644 +index 14ffafdd..afb027e3 100644 --- a/encoding.c +++ b/encoding.c @@ -45,7 +45,7 @@ @@ -44,3 +44,29 @@ 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/libxml2-config.cmake.cmake.in b/libxml2-config.cmake.cmake.in +index aead949b..cf2f3228 100644 +--- a/libxml2-config.cmake.cmake.in ++++ b/libxml2-config.cmake.cmake.in +@@ -123,7 +123,7 @@ if(NOT LIBXML2_SHARED) + endif() + + if(LIBXML2_WITH_ICU) +- find_dependency(ICU COMPONENTS data i18n uc) ++ find_dependency(ICU COMPONENTS i18n uc) + list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES}) + if(NOT ICU_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) +diff --git a/libxml2-config.cmake.in b/libxml2-config.cmake.in +index 6799fd25..2e71d65d 100644 +--- a/libxml2-config.cmake.in ++++ b/libxml2-config.cmake.in +@@ -75,7 +75,7 @@ if(LIBXML2_WITH_THREADS) + endif() + + if(LIBXML2_WITH_ICU) +- find_dependency(ICU COMPONENTS data i18n uc) ++ find_dependency(ICU COMPONENTS i18n uc) + list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES}) + list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$;\$;\$") + if(NOT ICU_FOUND) diff --git a/patches/libxslt-fix-config-include.patch b/patches/libxslt-fix-config-include.patch new file mode 100644 index 0000000..6a1a93d --- /dev/null +++ b/patches/libxslt-fix-config-include.patch @@ -0,0 +1,26 @@ +diff --git a/libexslt/libexslt.h b/libexslt/libexslt.h +index af68f7d4..5b1ace7f 100644 +--- a/libexslt/libexslt.h ++++ b/libexslt/libexslt.h +@@ -9,7 +9,7 @@ + #ifndef __XSLT_LIBEXSLT_H__ + #define __XSLT_LIBEXSLT_H__ + +-#if defined(_WIN32) && !defined (__MINGW32__) ++#if defined(_WIN32) && !defined (__MINGW32__) && 0 + #include + #else + #include "config.h" +diff --git a/libxslt/libxslt.h b/libxslt/libxslt.h +index f81066c0..3344c570 100644 +--- a/libxslt/libxslt.h ++++ b/libxslt/libxslt.h +@@ -23,7 +23,7 @@ + #endif + #endif + +-#if defined(_WIN32) && !defined (__MINGW32__) ++#if defined(_WIN32) && !defined (__MINGW32__) && 0 + #include + #else + #include "config.h" diff --git a/patches/libxslt-fix-library-name.patch b/patches/libxslt-fix-library-name.patch new file mode 100644 index 0000000..a34ae22 --- /dev/null +++ b/patches/libxslt-fix-library-name.patch @@ -0,0 +1,20 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fb352475..dd306465 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -242,7 +242,6 @@ set_target_properties( + IMPORT_PREFIX lib + OUTPUT_NAME xslt + POSITION_INDEPENDENT_CODE ON +- PREFIX lib + VERSION ${PROJECT_VERSION} + SOVERSION ${LIBXSLT_MAJOR_VERSION} + ) +@@ -335,7 +334,6 @@ set_target_properties( + IMPORT_PREFIX lib + OUTPUT_NAME exslt + POSITION_INDEPENDENT_CODE ON +- PREFIX lib + VERSION ${LIBEXSLT_VERSION} + SOVERSION ${LIBEXSLT_MAJOR_VERSION} + ) diff --git a/patches/libxslt-fix-pkgconfig.patch b/patches/libxslt-fix-pkgconfig.patch new file mode 100644 index 0000000..0f4c8b8 --- /dev/null +++ b/patches/libxslt-fix-pkgconfig.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fb352475..1d8270f1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -526,6 +524,10 @@ set(EXSLT_INCLUDEDIR "-I\${includedir}") + set(EXSLT_LIBDIR "-L\${libdir}") + set(EXSLT_PRIVATE_LIBS "${XSLT_PRIVATE_LIBS} ${LIBGCRYPT_LIBS} ${LIBM}") + ++if(NOT LIBXSLT_SHARED) ++ set(LIBXSLT_CFLAGS -DLIBXSLT_STATIC) ++endif() ++ + file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}") + string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}") + diff --git a/phases/16-libxml2.bat b/phases/16-libxml2.bat index 5d8b351..de401fd 100644 --- a/phases/16-libxml2.bat +++ b/phases/16-libxml2.bat @@ -39,6 +39,7 @@ ninja || exit /b 1 echo. echo ### Installing - -:: libxml2-export.cmake is generated while installing libxml2 ninja install || exit /b 1 + +:: remove installed documentation +rmdir /S /Q "%INSTALL_PREFIX%\share\doc\libxml2" diff --git a/phases/17-libxslt.bat b/phases/17-libxslt.bat index 406c384..ac8b579 100644 --- a/phases/17-libxslt.bat +++ b/phases/17-libxslt.bat @@ -13,38 +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%\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 ^ - crypto=no xslt_debug=no ^ - %CONFIGURE_OPTS% ^ - "prefix=%INSTALL_PREFIX%" ^ - "include=%INSTALL_PREFIX%\include" ^ - "include=%INSTALL_PREFIX%\include\libxml2" ^ - "lib=%INSTALL_PREFIX%\lib" ^ - "sodir=%INSTALL_PREFIX%\lib" ^ +echo ### Running cmake +cmake .. %CMAKE_OPTIONS% ^ + -D BUILD_SHARED_LIBS=NO ^ + -D LIBXSLT_WITH_PYTHON=NO ^ + -D LIBXSLT_WITH_TESTS=NO ^ + -D LIBXSLT_WITH_PROGRAMS=NO ^ + -D CMAKE_STATIC_LIBRARY_PREFIX= ^ + -D ICU_INCLUDE_DIR=%UM_INCLUDE_DIR% ^ || exit /b 1 echo. echo ### Building -:: we only build the static libraries -nmake /f Makefile.msvc libxslta libexslta || exit /b 1 +ninja || exit /b 1 echo. echo ### Installing -:: rename libxslt_a.lib to xslt.lib to allow linking using -lxslt -:: (the wildcard suffix is required to suppress the "file or directory" prompt) -xcopy /Y /F "bin.msvc\libxslt_a.lib" "%INSTALL_PREFIX%\lib\xslt.lib*" || exit /b 1 -xcopy /Y /F "bin.msvc\libexslt_a.lib" "%INSTALL_PREFIX%\lib\exslt.lib*" || exit /b 1 -xcopy /Y /F /S "%SRCROOT%\%PROJECT%\libxslt\*.h" "%INSTALL_PREFIX%\include\libxslt\" || exit /b 1 -xcopy /Y /F /S "%SRCROOT%\%PROJECT%\libexslt\*.h" "%INSTALL_PREFIX%\include\libexslt\" || exit /b 1 - -:: write pkgconfig file -call "%~dp0\..\scripts\common.bat" write_pkgconfig libxslt %TAG% "-DLIBXSLT_STATIC" "-lxslt" "-lxml2" || exit /b 1 +ninja install || exit /b 1 + +:: remove installed documentation +rmdir /S /Q "%INSTALL_PREFIX%\share\doc\libxslt" diff --git a/scripts/common.bat b/scripts/common.bat index d0c1065..923f442 100644 --- a/scripts/common.bat +++ b/scripts/common.bat @@ -111,49 +111,3 @@ exit /b %errorlevel% :set_git_remote set GIT_REMOTE=%1 goto :eof - -:write_pkgconfig - set PKGCONFIG_NAME=%~1 - set PKGCONFIG_VERSION=%~2 - set PKGCONFIG_CFLAGS=%~3 - set PKGCONFIG_LIBS=%~4 - set PKGCONFIG_LIBS_PRIVATE=%~5 - set PKGCONFIG_REQUIRES=%~6 - - :: trim version prefix - call :trim_pkgconfig_version || exit /b 1 - - :: use forward slashes for prefix path - set PKGCONFIG_PREFIX=%INSTALL_PREFIX:\=/% - - if not exist "%INSTALL_PREFIX%\lib\pkgconfig" (mkdir "%INSTALL_PREFIX%\lib\pkgconfig" || exit /b 1) - - echo Writing pkgconfig file... - ( - echo prefix=%PKGCONFIG_PREFIX% - echo exec_prefix=${prefix} - echo libdir=${exec_prefix}/lib - echo includedir=${prefix}/include - echo. - echo Name: %PKGCONFIG_NAME% - echo Version: %PKGCONFIG_VERSION% - echo Description: %PKGCONFIG_NAME% - echo Requires: %PKGCONFIG_REQUIRES% - echo. - echo Cflags: -I${includedir} %PKGCONFIG_CFLAGS% - echo Libs: -L${libdir} %PKGCONFIG_LIBS% - echo Libs.private: %PKGCONFIG_LIBS_PRIVATE% - ) > %INSTALL_PREFIX%\lib\pkgconfig\%PKGCONFIG_NAME%.pc - goto :eof - -:: trims prefix like "v" or "release-" from PKGCONFIG_VERSION -:: and converts underscore version number delimiters to periods -:trim_pkgconfig_version - echo %PKGCONFIG_VERSION:~0,1% | findstr /r [a-z_-] > nul - if %errorlevel% == 0 ( - set PKGCONFIG_VERSION=%PKGCONFIG_VERSION:~1% - call :trim_pkgconfig_version || exit /b 1 - ) else ( - set PKGCONFIG_VERSION=%PKGCONFIG_VERSION:_=.% - ) - exit /b 0