@@ -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
@@ -847,7 +896,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
847896 }
848897 }
849898
850- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
899+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
851900
852901 $LLVM_ENABLE_PDB = switch ($BuildType ) {
853902 " Release" { " NO" }
@@ -869,8 +918,8 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
869918 # give us a sligtly faster build.
870919 CMAKE_BUILD_TYPE = " Release" ;
871920 CMAKE_INSTALL_PREFIX = " $ ( $Arch.ToolchainInstallRoot ) \usr" ;
872- CMAKE_Swift_COMPILER = " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\ swiftc.exe" ;
873- CMAKE_Swift_FLAGS = @ (" -sdk" , " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk " );
921+ CMAKE_Swift_COMPILER = ( Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" ) ;
922+ CMAKE_Swift_FLAGS = @ (" -sdk" , ( Get-PinnedToolchainSDK ) );
874923 LLDB_PYTHON_EXE_RELATIVE_PATH = " python.exe" ;
875924 LLDB_PYTHON_EXT_SUFFIX = " .pyd" ;
876925 LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
@@ -883,7 +932,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
883932 LLVM_TABLEGEN = " $BinaryCache \0\bin\llvm-tblgen.exe" ;
884933 LLVM_USE_HOST_TOOLS = " NO" ;
885934 SWIFT_BUILD_SWIFT_SYNTAX = " YES" ;
886- SWIFT_CLANG_LOCATION = " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin " ;
935+ SWIFT_CLANG_LOCATION = ( Get-PinnedToolchainTool ) ;
887936 SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = " YES" ;
888937 SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = " YES" ;
889938 SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = " YES" ;
@@ -893,7 +942,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
893942 SWIFT_PATH_TO_LIBDISPATCH_SOURCE = " $SourceCache \swift-corelibs-libdispatch" ;
894943 SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
895944 SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = " $SourceCache \swift-experimental-string-processing" ;
896- SWIFT_PATH_TO_SWIFT_SDK = " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk " ;
945+ SWIFT_PATH_TO_SWIFT_SDK = ( Get-PinnedToolchainSDK ) ;
897946 })
898947 }
899948}
@@ -1077,7 +1126,7 @@ function Build-Runtime($Arch) {
10771126 $LLVMBinaryCache = Get-ProjectBinaryCache $Arch 0
10781127
10791128 Isolate- EnvVars {
1080- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
1129+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
10811130
10821131 Build-CMakeProject `
10831132 - Src $SourceCache \swift `
0 commit comments