Skip to content

Commit 2f080e4

Browse files
committed
Optionally install ICU if not available on the system
1 parent 13cf831 commit 2f080e4

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The toolchain currently consists of the following libraries:
1818
- [libiconv](https://github.com/kiyolee/libiconv-win-build)
1919
- [libxml2](https://github.com/GNOME/libxml2)
2020
- [libxslt](https://github.com/GNOME/libxslt)
21-
- [ICU](https://docs.microsoft.com/en-us/windows/win32/intl/international-components-for-unicode--icu-) (DLL provided by Windows 10 version 1903 or later)
21+
- [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)
2222

2323
Prerequisites for Building
2424
--------------------------

phases/15-icu.bat

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@echo off
2+
setlocal
3+
4+
call "%~dp0\..\scripts\common.bat" loadenv || exit /b 1
5+
6+
:: determine whether we can use the Windows-provided ICU
7+
:: (requires Windows 10 version 1903 / build 18362 or later)
8+
for /f "tokens=4-6 delims=. " %%i in ('ver') do (
9+
set WIN_VERSION=%%i
10+
set WIN_BUILD=%%k
11+
)
12+
if %WIN_VERSION% GTR 10 (
13+
:: Windows 11 or later
14+
set SKIP_ICU=1
15+
) else if %WIN_VERSION% EQU 10 (
16+
if %WIN_BUILD% GEQ 18362 (
17+
:: Windows 10 version 1903 / build 18362 or later
18+
set SKIP_ICU=1
19+
)
20+
)
21+
if defined SKIP_ICU (
22+
echo Using system-provided ICU DLL ^(requires Windows 10 version 1903 or later^)
23+
exit /b 0
24+
)
25+
26+
if "%ARCH%" == "x86" (
27+
set ICU_RELEASE_URL=https://github.com/unicode-org/icu/releases/download/release-69-1/icu4c-69_1-Win32-MSVC2019.zip
28+
) else if "%ARCH%" == "x64" (
29+
set ICU_RELEASE_URL=https://github.com/unicode-org/icu/releases/download/release-69-1/icu4c-69_1-Win64-MSVC2019.zip
30+
) else (
31+
echo Unknown ARCH: %ARCH%
32+
exit /b 1
33+
)
34+
35+
for %%a in ("%ICU_RELEASE_URL%") do (
36+
set ICU_RELEASE_FILE=%%~nxa
37+
set ICU_RELEASE_NAME=%%~na
38+
)
39+
40+
if not exist "%CACHE_ROOT%" (mkdir "%CACHE_ROOT%" || exit /b 1)
41+
cd "%CACHE_ROOT%" || exit /b 1
42+
43+
if not exist %ICU_RELEASE_FILE% (
44+
echo.
45+
echo ### Downloading release
46+
curl -L -O# %ICU_RELEASE_URL% || exit /b 1
47+
)
48+
49+
if not exist %ICU_RELEASE_NAME% (
50+
echo.
51+
echo ### Extracting release
52+
powershell Expand-Archive %ICU_RELEASE_FILE% || exit /b 1
53+
)
54+
55+
echo.
56+
echo ### Installing
57+
cd %ICU_RELEASE_NAME% || exit /b 1
58+
pushd bin* || exit /b 1
59+
xcopy /Y /F "icu*.dll" "%INSTALL_PREFIX%\lib\" || exit /b 1
60+
popd
61+
pushd lib* || exit /b 1
62+
xcopy /Y /F "icu*.lib" "%INSTALL_PREFIX%\lib\" || exit /b 1
63+
popd
64+
xcopy /Y /F /S "include\*" "%INSTALL_PREFIX%\include\" || exit /b 1

phases/16-libxml2.bat

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ for /f "usebackq delims=" %%i in (`call %BASH% '../scripts/get-latest-github-rel
1313
:: load environment and prepare project
1414
call "%~dp0\..\scripts\common.bat" prepare_project || exit /b 1
1515

16-
cd "%SRCROOT%\%PROJECT%\win32" || exit /b 1
16+
cd "%SRCROOT%\%PROJECT%" || exit \b 1
17+
18+
:: apply patch to use system-provided ICU DLL if applicable
19+
if not exist "%INSTALL_PREFIX%\lib\icu*.dll" (
20+
git apply "%ROOT_DIR%\patches\opt-libxml2-windows-icu.patch" || exit /b 1
21+
)
22+
23+
cd "win32" || exit /b 1
1724

1825
echo.
1926
echo ### Running configure

0 commit comments

Comments
 (0)