Skip to content

Commit

Permalink
Optionally install ICU if not available on the system
Browse files Browse the repository at this point in the history
  • Loading branch information
triplef committed Aug 6, 2021
1 parent 13cf831 commit e0e42fc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The toolchain currently consists of the following libraries:
- [libiconv](https://github.com/kiyolee/libiconv-win-build)
- [libxml2](https://github.com/GNOME/libxml2)
- [libxslt](https://github.com/GNOME/libxslt)
- [ICU](https://docs.microsoft.com/en-us/windows/win32/intl/international-components-for-unicode--icu-) (DLL provided by Windows 10 version 1903 or later)
- [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)

Prerequisites for Building
--------------------------
Expand Down
File renamed without changes.
64 changes: 64 additions & 0 deletions phases/15-icu.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@echo off
setlocal

call "%~dp0\common.bat" loadenv || exit /b 1

:: determine whether we can use the Windows-provided ICU
:: (requires Windows 10 version 1903 / build 18362 or later)
for /f "tokens=4-6 delims=. " %%i in ('ver') do (
set WIN_VERSION=%%i
set WIN_BUILD=%%k
)
if %WIN_VERSION% GTR 10 (
:: Windows 11 or later
set SKIP_ICU=1
) else if %WIN_VERSION% EQU 10 (
if %WIN_BUILD% GEQ 18362 (
:: Windows 10 version 1903 / build 18362 or later
set SKIP_ICU=1
)
)
if defined SKIP_ICU (
echo Using system-provided ICU DLL ^(requires Windows 10 version 1903 or later^)
exit /b 0
)

if "%ARCH%" == "x86" (
set ICU_RELEASE_URL=https://github.com/unicode-org/icu/releases/download/release-69-1/icu4c-69_1-Win32-MSVC2019.zip
) else if "%ARCH%" == "x64" (
set ICU_RELEASE_URL=https://github.com/unicode-org/icu/releases/download/release-69-1/icu4c-69_1-Win64-MSVC2019.zip
) else (
echo Unknown ARCH: %ARCH%
exit /b 1
)

for %%a in ("%ICU_RELEASE_URL%") do (
set ICU_RELEASE_FILE=%%~nxa
set ICU_RELEASE_NAME=%%~na
)

if not exist "%CACHE_ROOT%" (mkdir "%CACHE_ROOT%" || exit /b 1)
cd "%CACHE_ROOT%" || exit /b 1

if not exist %ICU_RELEASE_FILE% (
echo.
echo ### Downloading release
curl -L -O# %ICU_RELEASE_URL% || exit /b 1
)

if not exist %ICU_RELEASE_NAME% (
echo.
echo ### Extracting release
powershell Expand-Archive %ICU_RELEASE_FILE% || exit /b 1
)

echo.
echo ### Installing
cd %ICU_RELEASE_NAME% || exit /b 1
pushd bin* || exit /b 1
xcopy /Y /F "icu*.dll" "%INSTALL_PREFIX%\lib\" || exit /b 1
popd
pushd lib* || exit /b 1
xcopy /Y /F "icu*.lib" "%INSTALL_PREFIX%\lib\" || exit /b 1
popd
xcopy /Y /F /S "include\*" "%INSTALL_PREFIX%\include\" || exit /b 1
9 changes: 8 additions & 1 deletion phases/16-libxml2.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ 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
cd "%SRCROOT%\%PROJECT%" || exit \b 1

:: apply patch to use system-provided ICU DLL if applicable
if not exist "%INSTALL_PREFIX%\lib\icu*.dll" (
git apply "%ROOT_DIR%\patches\opt-libxml2-windows-icu.patch" || exit /b 1
)

cd "win32" || exit /b 1

echo.
echo ### Running configure
Expand Down

0 comments on commit e0e42fc

Please sign in to comment.