Skip to content

Commit d16f8ad

Browse files
compnerdbnbarham
authored andcommitted
[Build] Enable macros on 5.10
Fetch and extract a prebuilt toolchain to enable macros support on 5.10. This is a squashed cherry-pick of swiftlang#68319, swiftlang#68641, and swiftlang#68835.
1 parent 4553515 commit d16f8ad

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

utils/build-windows-toolchain.bat

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ del /f /q "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap"
5050
del /f /q "%VCToolsInstallDir%\include\module.modulemap"
5151
del /f /q "%VCToolsInstallDir%\include\vcruntime.apinotes"
5252

53+
call :FetchWiX || (exit /b)
54+
call :FetchX64Toolchain || (exit /b)
5355
call :CloneDependencies || (exit /b)
5456
call :CloneRepositories || (exit /b)
5557

@@ -186,6 +188,33 @@ cmake ^
186188
cmake --build "%BuildRoot%\curl" || (exit /b)
187189
cmake --build "%BuildRoot%\curl" --target install || (exit /b)
188190

191+
path %BuildRoot%\toolchains\5.9.0\PFiles64\Swift\runtime-development\usr\bin;%BuildRoot%\toolchains\5.9.0\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin;%Path%
192+
193+
:: Build Swift Syntax
194+
cmake ^
195+
-B "%BuildRoot%\99" ^
196+
197+
-D BUILD_SHARED_LIBS=YES ^
198+
-D CMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ^
199+
-D CMAKE_C_COMPILER=cl.exe ^
200+
-D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^
201+
-D CMAKE_CXX_COMPILER=cl ^
202+
-D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy" ^
203+
-D CMAKE_MT=mt ^
204+
-D CMAKE_Swift_COMPILER=%BuildRoot%/toolchains/5.9.0/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe ^
205+
-D CMAKE_Swift_FLAGS="-sdk %BuildRoot%/toolchains/5.9.0/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^
206+
-D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^
207+
-D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^
208+
209+
-D CMAKE_INSTALL_PREFIX="%InstallRoot%" ^
210+
211+
-D SWIFT_SYNTAX_ENABLE_WMO_PRE_3_26=YES ^
212+
213+
-G Ninja ^
214+
-S %SourceRoot%\swift-syntax || (exit /b)
215+
cmake --build %BuildRoot%\99 || (exit /b)
216+
cmake --build %BuildRoot%\99 --target install || (exit /b)
217+
189218
:: Build Toolchain
190219
cmake ^
191220
-B "%BuildRoot%\1" ^
@@ -203,6 +232,9 @@ cmake ^
203232

204233
-D CMAKE_INSTALL_PREFIX="%InstallRoot%" ^
205234

235+
-D CMAKE_Swift_COMPILER="%BuildRoot%/toolchains/5.9.0/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe" ^
236+
-D CMAKE_Swift_FLAGS="-sdk %BuildRoot%/toolchains/5.9.0/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^
237+
206238
-D LLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc ^
207239

208240
-D PACKAGE_VENDOR="swift.org" ^
@@ -225,9 +257,11 @@ cmake ^
225257
-D LLVM_EXTERNAL_CMARK_SOURCE_DIR="%SourceRoot%\cmark" ^
226258
-D PYTHON_HOME=%PYTHON_HOME% ^
227259
-D PYTHON_EXECUTABLE=%PYTHON_HOME%\python.exe ^
260+
-D SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR="%BuildRoot%\99" ^
228261
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE="%SourceRoot%\swift-corelibs-libdispatch" ^
229262
-D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="%SourceRoot%\swift-syntax" ^
230263
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=%SourceRoot%\swift-experimental-string-processing ^
264+
-D SWIFT_PATH_TO_SWIFT_SDK="%BuildRoot%/toolchains/5.9.0/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^
231265

232266
-G Ninja ^
233267
-S llvm-project\llvm || (exit /b)
@@ -818,6 +852,31 @@ git clone --quiet --no-tags --depth 1 --branch curl-7_77_0 https://github.com/cu
818852
goto :eof
819853
endlocal
820854

855+
:FetchWiX
856+
setlocal enableextensions enabledelayedexpansion
857+
858+
if exist wix-4.0.1 goto :eof
859+
curl.exe -sL https://www.nuget.org/api/v2/package/wix/4.0.1 -o wix-4.0.1.zip
860+
md WiX-4.0.1
861+
cd WiX-4.0.1 || exit (/b)
862+
tar -xf ../wix-4.0.1.zip || exit (/b)
863+
864+
goto :eof
865+
endlocal
866+
867+
:FetchX64Toolchain
868+
setlocal enableextensions enabledelayedexpansion
869+
870+
curl.exe -k -sOL "https://download.swift.org/swift-5.9-release/windows10/swift-5.9-RELEASE/swift-5.9-RELEASE-windows10.exe" || (exit /b)
871+
"WiX-4.0.1\tools\net6.0\any\wix.exe" burn extract swift-5.9-RELEASE-windows10.exe -o %BuildRoot%\toolchains || (exit /b)
872+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a0" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)
873+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a1" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)
874+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a2" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)
875+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a3" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)
876+
877+
goto :eof
878+
endlocal
879+
821880
:TestSwift
822881
setlocal enableextensions enabledelayedexpansion
823882

0 commit comments

Comments
 (0)