Skip to content

Commit 971d658

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 971d658

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

utils/build-windows-toolchain.bat

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,29 @@ 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)
@@ -280,9 +296,10 @@ 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\usr ^
300+
-D ICU_DATA_LIBRARY_RELEASE=%BuildRoot%\Library\icu-69.1\usr\lib\sicudt69.lib ^
301+
-D ICU_UC_LIBRARY_RELEASE=%BuildRoot%\Library\icu-69.1\usr\lib\sicuuc69.lib ^
302+
-D ICU_I18N_LIBRARY_RELEASE=%BuildRoot%\Library\icu-69.1\usr\lib\sicuin69.lib ^
286303
-D LIBXML2_LIBRARY=%BuildRoot%\Library\libxml2-2.9.12\usr\lib\libxml2s.lib ^
287304
-D LIBXML2_INCLUDE_DIR=%BuildRoot%\Library\libxml2-2.9.12\usr\include\libxml2 ^
288305
-D LIBXML2_DEFINITIONS="/DLIBXML_STATIC" ^
@@ -655,17 +672,6 @@ msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\runtime.wixproj ^
655672
:: TODO(compnerd) actually perform the code-signing
656673
:: signtool sign /f Apple_CodeSign.pfx /p Apple_CodeSign_Password /tr http://timestamp.digicert.com /fd sha256 %PackageRoot%\runtime\runtime.msi
657674

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-
669675
:: Package devtools.msi
670676
msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\devtools.wixproj ^
671677
-p:RunWixToolsOutOfProc=true ^
@@ -679,7 +685,6 @@ msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\devtools.wixproj
679685
move %PackageRoot%\toolchain\toolchain.msi %PackageRoot% || (exit /b)
680686
move %PackageRoot%\sdk\sdk.msi %PackageRoot% || (exit /b)
681687
move %PackageRoot%\runtime\runtime.msi %PackageRoot% || (exit /b)
682-
move %PackageRoot%\icu\icu.msi %PackageRoot% || (exit /b)
683688
move %PackageRoot%\devtools\devtools.msi %PackageRoot% || (exit /b)
684689

685690
:: Build Installer
@@ -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%;%SystemDrive%\Program Files\Git\usr\bin
712717
cmake --build %BuildRoot%\1 --target check-swift || (exit /b)
713718

714719
:: Test dispatch
@@ -735,9 +740,10 @@ 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\usr ^
744+
-D ICU_DATA_LIBRARY_RELEASE=%BuildRoot%\Library\icu-69.1\usr\lib\sicudt69.lib ^
745+
-D ICU_I18N_LIBRARY_RELEASE=%BuildRoot%\Library\icu-69.1\usr\lib\sicuin69.lib ^
746+
-D ICU_UC_LIBRARY_RELEASE=%BuildRoot%\Library\icu-69.1\usr\lib\sicuuc69.lib ^
741747
-D LIBXML2_LIBRARY=%BuildRoot%\Library\libxml2-2.9.12\usr\lib\libxml2s.lib ^
742748
-D LIBXML2_INCLUDE_DIR=%BuildRoot%\Library\libxml2-2.9.12\usr\include\libxml2 ^
743749
-D LIBXML2_DEFINITIONS="/DLIBXML_STATIC" ^
@@ -832,7 +838,7 @@ rd /s /q zlib libxml2 sqlite icu curl
832838
git clone --quiet --no-tags --depth 1 --branch v1.2.11 https://github.com/madler/zlib
833839
git clone --quiet --no-tags --depth 1 --branch v2.9.12 https://github.com/gnome/libxml2
834840
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
841+
git clone --quiet --no-tags --depth 1 --branch maint/maint-69 https://github.com/unicode-org/icu
836842
git clone --quiet --no-tags --depth 1 --branch curl-7_77_0 https://github.com/curl/curl
837843

838844
goto :eof

0 commit comments

Comments
 (0)