Skip to content

Commit e2a344b

Browse files
authored
Merge pull request swiftlang#68319 from compnerd/extraction
Update the windows toolchain build to enable building macros. This is the first step towards enabling the complete toolchain (e.g. regex, bootstraping, etc).
2 parents 9f225d6 + 8f6671c commit e2a344b

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

utils/build-windows-toolchain.bat

Lines changed: 58 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\swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a\PFiles64\Swift\Runtimes\0.0.0\usr\bin;%BuildRoot%\toolchains\swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a\PFiles64\Swift\Toolchains\0.0.0+Asserts\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/swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a/PFiles64/Swift/Toolchains/0.0.0+Asserts/usr/bin/swiftc.exe ^
205+
-D CMAKE_Swift_FLAGS="-sdk %BuildRoot%/toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a/PFiles64/Swift/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/swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a/PFiles64/Swift/Toolchains/0.0.0+Asserts/usr/bin/swiftc.exe" ^
236+
-D CMAKE_Swift_FLAGS="-sdk %BuildRoot%/toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a/PFiles64/Swift/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/swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a/PFiles64/Swift/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^
231265

232266
-G Ninja ^
233267
-S llvm-project\llvm || (exit /b)
@@ -818,6 +852,30 @@ 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+
curl.exe -sL https://www.nuget.org/api/v2/package/wix/4.0.1 -o wix-4.0.1.zip
859+
md WiX-4.0.1 || exit (/b)
860+
cd WiX-4.0.1 || exit (/b)
861+
tar -xf ../wix-4.0.1.zip || exit (/b)
862+
863+
goto :eof
864+
endlocal
865+
866+
:FetchX64Toolchain
867+
setlocal enableextensions enabledelayedexpansion
868+
869+
curl.exe -k -sOL "https://download.swift.org/development/windows10/swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a/swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a-windows10.exe" || (exit /b)
870+
"WiX-4.0.1\tools\net6.0\any\wix.exe" burn extract swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a-windows10.exe -o %BuildRoot%\toolchains || (exit /b)
871+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a0" TARGETDIR="%BuildRoot%\toolchains\swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a\PFiles64\Swift\Runtimes\0.0.0\usr\bin\" || (exit /b)
872+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a1" TARGETDIR="%BuildRoot%\toolchains\swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a\" || (exit /b)
873+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a2" TARGETDIR="%BuildRoot%\toolchains\swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a\" || (exit /b)
874+
msiexec.exe /qn /a "%BuildRoot%\toolchains\a5" TARGETDIR="%BuildRoot%\toolchains\swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a\" || (exit /b)
875+
876+
goto :eof
877+
endlocal
878+
821879
:TestSwift
822880
setlocal enableextensions enabledelayedexpansion
823881

0 commit comments

Comments
 (0)