@@ -1271,7 +1271,7 @@ function Build-CMakeProject {
12711271 [string []] $UsePinnedCompilers = @ (),
12721272 [switch ] $AddAndroidCMakeEnv = $false ,
12731273 [switch ] $UseGNUDriver = $false ,
1274- [string ] $SwiftSDK = " " ,
1274+ [string ] $SwiftSDK = $null ,
12751275 [hashtable ] $Defines = @ {}, # Values are either single strings or arrays of flags
12761276 [string []] $BuildTargets = @ ()
12771277 )
@@ -1448,21 +1448,12 @@ function Build-CMakeProject {
14481448 # TODO(compnerd): remove this once we have the early swift-driver
14491449 Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_USE_OLD_DRIVER " YES"
14501450
1451- $SwiftFlags = if ( $UsePinnedCompilers .Contains ( " Swift " )) {
1452- @ ( " -sdk " , ( Get-PinnedToolchainSDK ))
1453- } elseif ($SwiftSDK ) {
1451+ [ string []] $SwiftFlags = @ ();
1452+
1453+ $SwiftFlags += if ($SwiftSDK ) {
14541454 @ (" -sdk" , $SwiftSDK )
14551455 } else {
1456- $RuntimeBinaryCache = Get-ProjectBinaryCache $Platform Runtime
1457- $SwiftResourceDir = " ${RuntimeBinaryCache} \lib\swift"
1458-
1459- @ (
1460- " -vfsoverlay" , " $RuntimeBinaryCache \stdlib\windows-vfs-overlay.yaml" ,
1461- " -strict-implicit-module-context" ,
1462- " -Xcc" , " -Xclang" , " -Xcc" , " -fbuiltin-headers-in-system-modules" ,
1463- " -resource-dir" , $SwiftResourceDir ,
1464- " -L" , " $SwiftResourceDir \$ ( $Platform.OS.ToString ().ToLowerInvariant()) "
1465- )
1456+ @ ()
14661457 }
14671458
14681459 $SwiftFlags += if ($DebugInfo ) {
@@ -1578,22 +1569,12 @@ function Build-CMakeProject {
15781569 # TODO(compnerd) remove this once we have the early swift-driver
15791570 Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_USE_OLD_DRIVER " YES"
15801571
1581- $SwiftFlags = if ($USePinnedCompilers.Contains (" Swift" )) {
1582- @ (" -sdk" , (Get-PinnedToolchainSDK ))
1583- } elseif ($SwiftSDK ) {
1584- @ (
1585- " -sdk" , $SwiftSDK ,
1586- " -sysroot" , $AndroidSysroot
1587- )
1572+ [string []] $SwiftFlags = @ ()
1573+
1574+ $SwiftFlags += if ($SwiftSDK ) {
1575+ @ (" -sdk" , $SwiftSDK , " -sysroot" , $AndroidSysroot )
15881576 } else {
1589- $RuntimeBinaryCache = Get-ProjectBinaryCache $Platform Runtime
1590- $SwiftResourceDir = " ${RuntimeBinaryCache} \lib\swift"
1591-
1592- @ (
1593- " -sdk" , $AndroidSysroot ,
1594- " -resource-dir" , $SwiftResourceDir ,
1595- " -L" , " $SwiftResourceDir \$ ( $Platform.OS.ToString ().ToLowerInvariant()) "
1596- )
1577+ @ ()
15971578 }
15981579
15991580 $SwiftFlags += @ (
@@ -2004,6 +1985,7 @@ function Build-Compilers([Hashtable] $Platform, [string] $Variant) {
20041985 - Platform $Platform `
20051986 - UseMSVCCompilers C, CXX `
20061987 - UsePinnedCompilers Swift `
1988+ - SwiftSDK (Get-PinnedToolchainSDK ) `
20071989 - BuildTargets @ (" install-distribution" ) `
20081990 - CacheScript $SourceCache \swift\cmake\caches\Windows- $ ($Platform.Architecture.LLVMName ).cmake `
20091991 - Defines (Get-CompilersDefines $Platform $Variant )
@@ -2065,6 +2047,7 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test
20652047 - Platform $Platform `
20662048 - UseMSVCCompilers C, CXX `
20672049 - UsePinnedCompilers Swift `
2050+ - SwiftSDK (Get-PinnedToolchainSDK ) `
20682051 - BuildTargets $Targets `
20692052 - CacheScript $SourceCache \swift\cmake\caches\Windows- $ ($Platform.Architecture.LLVMName ).cmake `
20702053 - Defines $TestingDefines
@@ -2400,8 +2383,9 @@ function Build-Runtime([Hashtable] $Platform) {
24002383 - Bin (Get-ProjectBinaryCache $Platform Runtime) `
24012384 - InstallTo " $ ( Get-SwiftSDK $Platform.OS ) \usr" `
24022385 - Platform $Platform `
2403- - CacheScript $SourceCache \swift\cmake\caches\Runtime- $ ($Platform.OS.ToString ())- $ ($Platform.Architecture.LLVMName ).cmake `
24042386 - UseBuiltCompilers C, CXX, Swift `
2387+ - SwiftSDK $null `
2388+ - CacheScript $SourceCache \swift\cmake\caches\Runtime- $ ($Platform.OS.ToString ())- $ ($Platform.Architecture.LLVMName ).cmake `
24052389 - Defines ($PlatformDefines + @ {
24062390 CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform );
24072391 CMAKE_Swift_COMPILER_WORKS = " YES" ;
@@ -2444,6 +2428,7 @@ function Test-Runtime([Hashtable] $Platform) {
24442428 - Bin (Get-ProjectBinaryCache $Platform Runtime) `
24452429 - Platform $Platform `
24462430 - UseBuiltCompilers C, CXX, Swift `
2431+ - SwiftSDK $null `
24472432 - BuildTargets check- swift- validation- only_non_executable `
24482433 - Defines @ {
24492434 SWIFT_INCLUDE_TESTS = " YES" ;
@@ -2518,6 +2503,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25182503 - InstallTo " ${SDKROOT} \usr" `
25192504 - Platform $Platform `
25202505 - UseBuiltCompilers C, CXX, Swift `
2506+ - SwiftSDK $null `
25212507 - UseGNUDriver `
25222508 - Defines @ {
25232509 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
@@ -2546,6 +2532,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25462532 - InstallTo " ${SDKROOT} \usr" `
25472533 - Platform $Platform `
25482534 - UseBuiltCompilers C, CXX, Swift `
2535+ - SwiftSDK $null `
25492536 - UseGNUDriver `
25502537 - Defines @ {
25512538 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
@@ -2564,6 +2551,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25642551 - InstallTo " ${SDKROOT} \usr" `
25652552 - Platform $Platform `
25662553 - UseBuiltCompilers C, Swift `
2554+ - SwiftSDK $null `
25672555 - UseGNUDriver `
25682556 - Defines @ {
25692557 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
@@ -2582,6 +2570,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25822570 - InstallTo " ${SDKROOT} \usr" `
25832571 - Platform $Platform `
25842572 - UseBuiltCompilers C, Swift `
2573+ - SwiftSDK $null `
25852574 - UseGNUDriver `
25862575 - Defines @ {
25872576 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
@@ -2601,6 +2590,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
26012590 - InstallTo " ${SDKROOT} \usr" `
26022591 - Platform $Platform `
26032592 - UseBuiltCompilers C, CXX, Swift `
2593+ - SwiftSDK $null `
26042594 - UseGNUDriver `
26052595 - Defines @ {
26062596 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
@@ -2621,6 +2611,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
26212611 - InstallTo " ${SDKROOT} \usr" `
26222612 - Platform $Platform `
26232613 - UseBuiltCompilers CXX, Swift `
2614+ - SwiftSDK $null `
26242615 - UseGNUDriver `
26252616 - Defines @ {
26262617 BUILD_SHARED_LIBS = if ($Static ) { " NO" } else { " YES" };
@@ -2702,8 +2693,8 @@ function Build-Dispatch([Hashtable] $Platform) {
27022693 - Bin (Get-ProjectBinaryCache $Platform Dispatch) `
27032694 - InstallTo " $ ( Get-SwiftSDK $Platform.OS ) \usr" `
27042695 - Platform $Platform `
2705- - SwiftSDK (Get-SwiftSDK $Platform.OS ) `
27062696 - UseBuiltCompilers C, CXX, Swift `
2697+ - SwiftSDK (Get-SwiftSDK $Platform.OS ) `
27072698 - Defines @ {
27082699 ENABLE_SWIFT = " YES" ;
27092700 }
@@ -2717,9 +2708,9 @@ function Test-Dispatch {
27172708 - Src $SourceCache \swift- corelibs- libdispatch `
27182709 - Bin (Get-ProjectBinaryCache $BuildPlatform Dispatch) `
27192710 - Platform $BuildPlatform `
2711+ - UseBuiltCompilers C, CXX, Swift `
27202712 - SwiftSDK (Get-SwiftSDK $BuildPlatform.OS ) `
27212713 - BuildTargets default , ExperimentalTest `
2722- - UseBuiltCompilers C, CXX, Swift `
27232714 - Defines @ {
27242715 ENABLE_SWIFT = " YES" ;
27252716 }
@@ -2863,14 +2854,19 @@ function Test-XCTest {
28632854 Invoke-IsolatingEnvVars {
28642855 $env: Path = " $ ( Get-ProjectBinaryCache $BuildPlatform XCTest) ;$ ( Get-ProjectBinaryCache $BuildPlatform DynamicFoundation) \bin;$ ( Get-ProjectBinaryCache $BuildPlatform Dispatch) ;$ ( Get-ProjectBinaryCache $BuildPlatform Runtime) \bin;${env: Path} ;$UnixToolsBinDir "
28652856
2857+ $RuntimeBinaryCache = Get-ProjectBinaryCache $BuildPlatform Runtime
2858+ $SwiftRuntimeDirectory = " ${RuntimeBinaryCache} \lib\swift"
2859+
28662860 Build-CMakeProject `
28672861 - Src $SourceCache \swift- corelibs- xctest `
28682862 - Bin (Get-ProjectBinaryCache $BuildPlatform XCTest) `
28692863 - Platform $BuildPlatform `
28702864 - UseBuiltCompilers Swift `
2865+ - SwiftSDK $null `
28712866 - BuildTargets default , check- xctest `
28722867 - Defines @ {
28732868 CMAKE_BUILD_WITH_INSTALL_RPATH = " YES" ;
2869+ CMAKE_Swift_FLAGS = @ (" -resource-dir" , $SwiftRuntimeDirectory , " -vfsoverlay" , " ${RuntimeBinaryCache} \stdlib\windows-vfs-overlay.yaml" );
28742870 ENABLE_TESTING = " YES" ;
28752871 dispatch_DIR = $ (Get-ProjectCMakeModules $BuildPlatform Dispatch);
28762872 Foundation_DIR = $ (Get-ProjectCMakeModules $BuildPlatform DynamicFoundation);
0 commit comments