@@ -77,6 +77,9 @@ For example: -BuildTo ToolsSupportCore
7777When set, runs the script in a special mode which outputs a listing of command invocations
7878in batch file format instead of executing them.
7979
80+ . PARAMETER PinnedLayout
81+ If "New", uses the new toolchain install layout. Otherwise, the old layout.
82+
8083. EXAMPLE
8184PS> .\Build.ps1
8285
@@ -103,7 +106,8 @@ param(
103106 [string []] $Test = @ (),
104107 [string ] $Stage = " " ,
105108 [string ] $BuildTo = " " ,
106- [switch ] $ToBatch
109+ [switch ] $ToBatch ,
110+ [string ] $PinnedLayout = " old"
107111)
108112
109113$ErrorActionPreference = " Stop"
@@ -460,10 +464,55 @@ function Ensure-SwiftToolchain($Arch) {
460464 New-Item - ItemType Directory - ErrorAction Ignore " $BinaryCache \toolchains" | Out-Null
461465 Write-Output " Extracting Swift toolchain..."
462466 Invoke-Program " $BinaryCache \wix-4.0.1\tools\net6.0\any\wix.exe" -- burn extract " $BinaryCache \${PinnedToolchain} .exe" - out " $BinaryCache \toolchains\"
463- Invoke-Program - OutNull msiexec.exe / lvx! a0.log / qn / a " $BinaryCache \toolchains\a0" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
464- Invoke-Program - OutNull msiexec.exe / lvx! a1.log / qn / a " $BinaryCache \toolchains\a1" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
465- Invoke-Program - OutNull msiexec.exe / lvx! a2.log / qn / a " $BinaryCache \toolchains\a2" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
466- Invoke-Program - OutNull msiexec.exe / lvx! a3.log / qn / a " $BinaryCache \toolchains\a3" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
467+ if ($PinnedLayout -eq " New" ) {
468+ [string []] $Packages = @ (" UNUSED" ,
469+ " rtl.msi" , " bld.msi" , " cli.msi" , " dbg.msi" , " ide.msi" ,
470+ " sdk.x86.msi" , " sdk.amd64.msi" , " sdk.arm64.msi" ,
471+ " rtl.cab" , " bld.cab" , " cli.cab" , " dbg.cab" , " ide.cab" ,
472+ " sdk.x86.cab" , " sdk.amd64.cab" , " sdk.arm64.cab" )
473+ for ($I = 1 ; $I -lt $Packages.length ; $I += 1 ) {
474+ Move-Item - Force " $BinaryCache \toolchains\a${I} " " $BinaryCache \toolchains\$ ( $Packages [$I ]) "
475+ }
476+
477+ # The runtime msi is built to expand files into the immediate directory. So, setup the installation location.
478+ New-Item - ItemType Directory - ErrorAction Ignore " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Runtimes\0.0.0\usr\bin" | Out-Null
479+
480+ Invoke-Program - OutNull msiexec.exe / lvx! bld.log / qn / a " $BinaryCache \toolchains\bld.msi" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
481+ Invoke-Program - OutNull msiexec.exe / lvx! cli.log / qn / a " $BinaryCache \toolchains\cli.msi" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
482+ Invoke-Program - OutNull msiexec.exe / lvx! sdk.x86.log / qn / a " $BinaryCache \toolchains\sdk.x86.msi" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
483+ Invoke-Program - OutNull msiexec.exe / lvx! sdk.amd64.log / qn / a " $BinaryCache \toolchains\sdk.amd64.msi" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
484+ Invoke-Program - OutNull msiexec.exe / lvx! sdk.arm64.log / qn / a " $BinaryCache \toolchains\sdk.arm64.msi" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
485+ Invoke-Program - OutNull msiexec.exe / lvx! rtl.log / qn / a " $BinaryCache \toolchains\rtl.msi" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Runtimes\0.0.0\usr\bin"
486+ } else {
487+ Invoke-Program - OutNull msiexec.exe / lvx! a0.log / qn / a " $BinaryCache \toolchains\a0" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
488+ Invoke-Program - OutNull msiexec.exe / lvx! a1.log / qn / a " $BinaryCache \toolchains\a1" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
489+ Invoke-Program - OutNull msiexec.exe / lvx! a2.log / qn / a " $BinaryCache \toolchains\a2" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
490+ Invoke-Program - OutNull msiexec.exe / lvx! a3.log / qn / a " $BinaryCache \toolchains\a3" ALLUSERS= 1 TARGETDIR= " $BinaryCache \toolchains\${PinnedToolchain} "
491+ }
492+ }
493+
494+ function Get-PinnedToolchainTool () {
495+ if ($PinnedLayout -eq " New" ) {
496+ return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin"
497+ } else {
498+ return " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
499+ }
500+ }
501+
502+ function Get-PinnedToolchainSDK () {
503+ if ($PinnedLayout -eq " New" ) {
504+ return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Platforms\0.0.0\Windows.platform\Developer\SDKs\Windows.sdk"
505+ } else {
506+ return " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk"
507+ }
508+ }
509+
510+ function Get-PinnedToolchainRuntime () {
511+ if ($PinnedLayout -eq " New" ) {
512+ return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Runtimes\0.0.0\usr\bin"
513+ } else {
514+ return " $BinaryCache \toolchains\${PinnedToolchain} \PFiles64\Swift\runtime-development\usr\bin"
515+ }
467516}
468517
469518function TryAdd-KeyValue ([hashtable ]$Hashtable , [string ]$Key , [string ]$Value ) {
@@ -576,7 +625,7 @@ function Build-CMakeProject {
576625 if ($UseBuiltCompilers.Contains (" CXX" )) {
577626 TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER " $BinaryCache \1\bin\clang-cl.exe"
578627 } else {
579- TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\ clang-cl.exe"
628+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER ( Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath " clang-cl.exe" )
580629 }
581630 TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
582631
@@ -596,7 +645,7 @@ function Build-CMakeProject {
596645 if ($UseBuiltCompilers.Contains (" Swift" )) {
597646 TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER " $BinaryCache \1\bin\swiftc.exe"
598647 } else {
599- TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\ swiftc.exe"
648+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER ( Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" )
600649 }
601650 TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER_TARGET $Arch.LLVMTarget
602651 if ($UseBuiltCompilers.Contains (" Swift" )) {
@@ -611,7 +660,7 @@ function Build-CMakeProject {
611660 $SwiftArgs += @ (" -vfsoverlay" , " $RuntimeBinaryCache \stdlib\windows-vfs-overlay.yaml" )
612661 }
613662 } else {
614- $SwiftArgs += @ (" -sdk" , " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk " )
663+ $SwiftArgs += @ (" -sdk" , ( Get-PinnedToolchainSDK ) )
615664 }
616665
617666 # Debug Information
@@ -843,7 +892,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
843892 }
844893 }
845894
846- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
895+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
847896
848897 $LLVM_ENABLE_PDB = switch ($BuildType ) {
849898 " Release" { " NO" }
@@ -865,8 +914,8 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
865914 # give us a sligtly faster build.
866915 CMAKE_BUILD_TYPE = " Release" ;
867916 CMAKE_INSTALL_PREFIX = " $ ( $Arch.ToolchainInstallRoot ) \usr" ;
868- CMAKE_Swift_COMPILER = " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\ swiftc.exe" ;
869- CMAKE_Swift_FLAGS = @ (" -sdk" , " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk " );
917+ CMAKE_Swift_COMPILER = ( Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" ) ;
918+ CMAKE_Swift_FLAGS = @ (" -sdk" , ( Get-PinnedToolchainSDK ) );
870919 LLDB_PYTHON_EXE_RELATIVE_PATH = " python.exe" ;
871920 LLDB_PYTHON_EXT_SUFFIX = " .pyd" ;
872921 LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
@@ -879,7 +928,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
879928 LLVM_TABLEGEN = " $BinaryCache \0\bin\llvm-tblgen.exe" ;
880929 LLVM_USE_HOST_TOOLS = " NO" ;
881930 SWIFT_BUILD_SWIFT_SYNTAX = " YES" ;
882- SWIFT_CLANG_LOCATION = " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin " ;
931+ SWIFT_CLANG_LOCATION = ( Get-PinnedToolchainTool ) ;
883932 SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = " YES" ;
884933 SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = " YES" ;
885934 SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = " YES" ;
@@ -889,7 +938,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
889938 SWIFT_PATH_TO_LIBDISPATCH_SOURCE = " $SourceCache \swift-corelibs-libdispatch" ;
890939 SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
891940 SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = " $SourceCache \swift-experimental-string-processing" ;
892- SWIFT_PATH_TO_SWIFT_SDK = " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk " ;
941+ SWIFT_PATH_TO_SWIFT_SDK = ( Get-PinnedToolchainSDK ) ;
893942 })
894943 }
895944}
@@ -1019,7 +1068,7 @@ function Build-Runtime($Arch) {
10191068 $LLVMBinaryCache = Get-ProjectBinaryCache $Arch 0
10201069
10211070 Isolate- EnvVars {
1022- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
1071+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
10231072
10241073 Build-CMakeProject `
10251074 - Src $SourceCache \swift `
0 commit comments