Skip to content

Commit c291cf5

Browse files
committed
build: start building static version of ICU for Windows
This builds ICU from source, statically builds and links it into the toolchain image. This removes the last piece that we were using that is not auditable. We now fully build the toolchain on the host on swift-ci.
1 parent 3ee8034 commit c291cf5

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

utils/build-windows-toolchain.bat

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,33 @@ call :CloneRepositories || (exit /b)
4545

4646
md "%BuildRoot%\Library"
4747

48-
:: TODO(compnerd) build ICU from source
49-
curl.exe -sOL "https://github.com/unicode-org/icu/releases/download/release-67-1/icu4c-67_1-Win64-MSVC2017.zip" || (exit /b)
50-
"%SystemDrive%\Program Files\Git\usr\bin\unzip.exe" -o icu4c-67_1-Win64-MSVC2017.zip -d %BuildRoot%\Library\icu-67.1
51-
md %BuildRoot%\Library\icu-67.1\usr\bin
52-
copy %BuildRoot%\Library\icu-67.1\bin64\icudt67.dll %BuildRoot%\Library\icu-67.1\usr\bin || (exit /b)
53-
copy %BuildRoot%\Library\icu-67.1\bin64\icuin67.dll %BuildRoot%\Library\icu-67.1\usr\bin || (exit /b)
54-
copy %BuildRoot%\Library\icu-67.1\bin64\icuuc67.dll %BuildRoot%\Library\icu-67.1\usr\bin || (exit /b)
48+
:: Build ICU
49+
copy %SourceRoot%\swift-installer-scripts\shared\ICU\CMakeLists.txt %SourceRoot%\icu\icu4c\ || (exit /b)
50+
cmake ^
51+
-B %BuildRoot%\icu ^
52+
53+
-D BUILD_SHARED_LIBS=NO ^
54+
-D CMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ^
55+
-D CMAKE_C_COMPILER=cl ^
56+
-D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^
57+
-D CMAKE_CXX_COMPILER=cl ^
58+
-D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy" ^
59+
-D CMAKE_MT=mt ^
60+
-D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^
61+
-D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^
62+
63+
-D CMAKE_INSTALL_PREFIX=%BuildRoot%\Library\icu-69.1\usr ^
64+
65+
-D BUILD_TOOLS=YES ^
66+
67+
-G Ninja ^
68+
-S %SourceRoot%\icu\icu4c || (exit /b)
69+
cmake --build "%BuildRoot%\icu" || (exit /b)
70+
cmake --build "%BuildRoot%\icu" --target install || (exit /b)
5571

5672
:: FIXME(compnerd) is there a way to build the sources without downloading the amalgamation?
5773
curl.exe -sOL "https://sqlite.org/2021/sqlite-amalgamation-3360000.zip" || (exit /b)
58-
"%SystemDrive%\Program Files\Git\usr\bin\unzip.exe" -o sqlite-amalgamation-3360000.zip -d %SourceRoot%
74+
"%ProgramFiles%\Git\usr\bin\unzip.exe" -o sqlite-amalgamation-3360000.zip -d %SourceRoot%
5975

6076
:: TODO(compnerd) use CMakeLists.txt from compnerd/swift-build
6177
md %BuildRoot%\sqlite
@@ -280,9 +296,9 @@ cmake ^
280296
-D CMAKE_INSTALL_PREFIX=%SDKInstallRoot%\usr ^
281297

282298
-D CURL_DIR=%BuildRoot%\Library\curl-7.77.0\usr\lib\cmake\CURL ^
283-
-D ICU_ROOT=%BuildRoot%\Library\icu-67.1 ^
284-
-D ICU_UC_LIBRARY=%BuildRoot%\Library\icu-67.1\lib64\icuuc67.lib ^
285-
-D ICU_I18N_LIBRARY=%BuildRoot%\Library\icu-67.1\lib64\icuin67.lib ^
299+
-D ICU_ROOT=%BuildRoot%\Library\icu-69.1 ^
300+
-D ICU_UC_LIBRARY=%BuildRoot%\Library\icu-69.1\lib\sicuuc69.lib ^
301+
-D ICU_I18N_LIBRARY=%BuildRoot%\Library\icu-69.1\lib\sicuin69.lib ^
286302
-D LIBXML2_LIBRARY=%BuildRoot%\Library\libxml2-2.9.12\usr\lib\libxml2s.lib ^
287303
-D LIBXML2_INCLUDE_DIR=%BuildRoot%\Library\libxml2-2.9.12\usr\include\libxml2 ^
288304
-D LIBXML2_DEFINITIONS="/DLIBXML_STATIC" ^
@@ -655,17 +671,6 @@ msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\runtime.wixproj ^
655671
:: TODO(compnerd) actually perform the code-signing
656672
:: signtool sign /f Apple_CodeSign.pfx /p Apple_CodeSign_Password /tr http://timestamp.digicert.com /fd sha256 %PackageRoot%\runtime\runtime.msi
657673

658-
:: Package icu.msi
659-
msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\icu.wixproj ^
660-
-p:RunWixToolsOutOfProc=true ^
661-
-p:OutputPath=%PackageRoot%\icu\ ^
662-
-p:IntermediateOutputPath=%PackageRoot%\icu\ ^
663-
-p:ProductVersion=67.1 ^
664-
-p:ProductVersionMajor=67 ^
665-
-p:ICU_ROOT=%BuildRoot%
666-
:: TODO(compnerd) actually perform the code-signing
667-
:: signtool sign /f Apple_CodeSign.pfx /p Apple_CodeSign_Password /tr http://timestamp.digicert.com /fd sha256 %PackageRoot%\icu\icu.msi
668-
669674
:: Package devtools.msi
670675
msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\devtools.wixproj ^
671676
-p:RunWixToolsOutOfProc=true ^
@@ -708,7 +713,7 @@ move %PackageRoot%\installer\installer.exe %BuildRoot%\artifacts || (exit /b)
708713

709714
:: Test Swift
710715
:: TODO(compnerd) make lit adjust the path properly
711-
path %BuildRoot%\3;%BuildRoot%\1\bin;%BuildRoot%\Library\icu-67.1\usr\bin;%PATH%;%SystemDrive%\Program Files\Git\usr\bin
716+
path %BuildRoot%\3;%BuildRoot%\1\bin;%PATH%;%ProgramFiles%\Git\usr\bin
712717
cmake --build %BuildRoot%\1 --target check-swift || (exit /b)
713718

714719
:: Test dispatch
@@ -735,9 +740,9 @@ cmake ^
735740
-D CMAKE_INSTALL_PREFIX=%SDKInstallRoot%\usr ^
736741

737742
-D CURL_DIR=%BuildRoot%\Library\curl-7.77.0\usr\lib\cmake\CURL ^
738-
-D ICU_ROOT=%BuildRoot%\Library\icu-67.1 ^
739-
-D ICU_UC_LIBRARY=%BuildRoot%\Library\icu-67.1\lib64\icuuc67.lib ^
740-
-D ICU_I18N_LIBRARY=%BuildRoot%\Library\icu-67.1\lib64\icuin67.lib ^
743+
-D ICU_ROOT=%BuildRoot%\Library\icu-69.1 ^
744+
-D ICU_UC_LIBRARY=%BuildRoot%\Library\icu-69.1\lib\sicuuc69.lib ^
745+
-D ICU_I18N_LIBRARY=%BuildRoot%\Library\icu-69.1\lib\sicuin69.lib ^
741746
-D LIBXML2_LIBRARY=%BuildRoot%\Library\libxml2-2.9.12\usr\lib\libxml2s.lib ^
742747
-D LIBXML2_INCLUDE_DIR=%BuildRoot%\Library\libxml2-2.9.12\usr\include\libxml2 ^
743748
-D LIBXML2_DEFINITIONS="/DLIBXML_STATIC" ^
@@ -832,7 +837,7 @@ rd /s /q zlib libxml2 sqlite icu curl
832837
git clone --quiet --no-tags --depth 1 --branch v1.2.11 https://github.com/madler/zlib
833838
git clone --quiet --no-tags --depth 1 --branch v2.9.12 https://github.com/gnome/libxml2
834839
git clone --quiet --no-tags --depth 1 --branch version-3.36.0 https://github.com/sqlite/sqlite
835-
git clone --quiet --no-tags --depth 1 --branch maint/maint-67 https://github.com/unicode-org/icu
840+
git clone --quiet --no-tags --depth 1 --branch maint/maint-69 https://github.com/unicode-org/icu
836841
git clone --quiet --no-tags --depth 1 --branch curl-7_77_0 https://github.com/curl/curl
837842

838843
goto :eof

0 commit comments

Comments
 (0)