@@ -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
@@ -847,7 +896,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
847
896
}
848
897
}
849
898
850
- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
899
+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
851
900
852
901
$LLVM_ENABLE_PDB = switch ($BuildType ) {
853
902
" Release" { " NO" }
@@ -869,8 +918,8 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
869
918
# give us a sligtly faster build.
870
919
CMAKE_BUILD_TYPE = " Release" ;
871
920
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 ) );
874
923
LLDB_PYTHON_EXE_RELATIVE_PATH = " python.exe" ;
875
924
LLDB_PYTHON_EXT_SUFFIX = " .pyd" ;
876
925
LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
@@ -883,7 +932,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
883
932
LLVM_TABLEGEN = " $BinaryCache \0\bin\llvm-tblgen.exe" ;
884
933
LLVM_USE_HOST_TOOLS = " NO" ;
885
934
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 ) ;
887
936
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = " YES" ;
888
937
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = " YES" ;
889
938
SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = " YES" ;
@@ -893,7 +942,7 @@ function Build-Compilers($Arch, [switch]$Test = $false) {
893
942
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = " $SourceCache \swift-corelibs-libdispatch" ;
894
943
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
895
944
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 ) ;
897
946
})
898
947
}
899
948
}
@@ -1077,7 +1126,7 @@ function Build-Runtime($Arch) {
1077
1126
$LLVMBinaryCache = Get-ProjectBinaryCache $Arch 0
1078
1127
1079
1128
Isolate- EnvVars {
1080
- $env: Path = " $BinaryCache \toolchains\ $PinnedToolchain \PFiles64\Swift\runtime-development\usr\bin ;${env: Path} "
1129
+ $env: Path = " $ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
1081
1130
1082
1131
Build-CMakeProject `
1083
1132
- Src $SourceCache \swift `
0 commit comments