@@ -77,6 +77,9 @@ For example: -BuildTo ToolsSupportCore
77
77
When set, runs the script in a special mode which outputs a listing of command invocations
78
78
in batch file format instead of executing them.
79
79
80
+ . PARAMETER PinnedLayout
81
+ If "New", uses the new toolchain install layout. Otherwise, the old layout.
82
+
80
83
. EXAMPLE
81
84
PS> .\Build.ps1
82
85
@@ -103,7 +106,8 @@ param(
103
106
[string []] $Test = @ (),
104
107
[string ] $Stage = " " ,
105
108
[string ] $BuildTo = " " ,
106
- [switch ] $ToBatch
109
+ [switch ] $ToBatch ,
110
+ [string ] $PinnedLayout = " old"
107
111
)
108
112
109
113
$ErrorActionPreference = " Stop"
@@ -460,10 +464,55 @@ function Ensure-SwiftToolchain($Arch) {
460
464
New-Item - ItemType Directory - ErrorAction Ignore " $BinaryCache \toolchains" | Out-Null
461
465
Write-Output " Extracting Swift toolchain..."
462
466
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
+ }
467
516
}
468
517
469
518
function TryAdd-KeyValue ([hashtable ]$Hashtable , [string ]$Key , [string ]$Value ) {
@@ -576,7 +625,7 @@ function Build-CMakeProject {
576
625
if ($UseBuiltCompilers.Contains (" CXX" )) {
577
626
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER " $BinaryCache \1\bin\clang-cl.exe"
578
627
} 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" )
580
629
}
581
630
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
582
631
@@ -596,7 +645,7 @@ function Build-CMakeProject {
596
645
if ($UseBuiltCompilers.Contains (" Swift" )) {
597
646
TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER " $BinaryCache \1\bin\swiftc.exe"
598
647
} 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" )
600
649
}
601
650
TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER_TARGET $Arch.LLVMTarget
602
651
if ($UseBuiltCompilers.Contains (" Swift" )) {
@@ -611,7 +660,7 @@ function Build-CMakeProject {
611
660
$SwiftArgs += @ (" -vfsoverlay" , " $RuntimeBinaryCache \stdlib\windows-vfs-overlay.yaml" )
612
661
}
613
662
} else {
614
- $SwiftArgs += @ (" -sdk" , " $BinaryCache \toolchains\ $PinnedToolchain \Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk " )
663
+ $SwiftArgs += @ (" -sdk" , ( Get-PinnedToolchainSDK ) )
615
664
}
616
665
617
666
# Debug Information
@@ -843,7 +892,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
843
892
}
844
893
}
845
894
846
- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
895
+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
847
896
848
897
$LLVM_ENABLE_PDB = switch ($BuildType ) {
849
898
" Release" { " NO" }
@@ -865,8 +914,8 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
865
914
# give us a sligtly faster build.
866
915
CMAKE_BUILD_TYPE = " Release" ;
867
916
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 ) );
870
919
LLDB_PYTHON_EXE_RELATIVE_PATH = " python.exe" ;
871
920
LLDB_PYTHON_EXT_SUFFIX = " .pyd" ;
872
921
LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
@@ -879,7 +928,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
879
928
LLVM_TABLEGEN = " $BinaryCache \0\bin\llvm-tblgen.exe" ;
880
929
LLVM_USE_HOST_TOOLS = " NO" ;
881
930
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 ) ;
883
932
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = " YES" ;
884
933
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = " YES" ;
885
934
SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = " YES" ;
@@ -889,7 +938,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
889
938
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = " $SourceCache \swift-corelibs-libdispatch" ;
890
939
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
891
940
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 ) ;
893
942
})
894
943
}
895
944
}
@@ -1019,7 +1068,7 @@ function Build-Runtime($Arch) {
1019
1068
$LLVMBinaryCache = Get-ProjectBinaryCache $Arch 0
1020
1069
1021
1070
Isolate- EnvVars {
1022
- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
1071
+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
1023
1072
1024
1073
Build-CMakeProject `
1025
1074
- Src $SourceCache \swift `
0 commit comments