Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ function Build-CMakeProject {
[string[]] $UsePinnedCompilers = @(),
[switch] $AddAndroidCMakeEnv = $false,
[switch] $UseGNUDriver = $false,
[string] $SwiftSDK = "",
[string] $SwiftSDK = $null,
[hashtable] $Defines = @{}, # Values are either single strings or arrays of flags
[string[]] $BuildTargets = @()
)
Expand Down Expand Up @@ -1448,21 +1448,12 @@ function Build-CMakeProject {
# TODO(compnerd): remove this once we have the early swift-driver
Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_USE_OLD_DRIVER "YES"

$SwiftFlags = if ($UsePinnedCompilers.Contains("Swift")) {
@("-sdk", (Get-PinnedToolchainSDK))
} elseif ($SwiftSDK) {
[string[]] $SwiftFlags = @();

$SwiftFlags += if ($SwiftSDK) {
@("-sdk", $SwiftSDK)
} else {
$RuntimeBinaryCache = Get-ProjectBinaryCache $Platform Runtime
$SwiftResourceDir = "${RuntimeBinaryCache}\lib\swift"

@(
"-vfsoverlay", "$RuntimeBinaryCache\stdlib\windows-vfs-overlay.yaml",
"-strict-implicit-module-context",
"-Xcc", "-Xclang", "-Xcc", "-fbuiltin-headers-in-system-modules",
"-resource-dir", $SwiftResourceDir,
"-L", "$SwiftResourceDir\$($Platform.OS.ToString().ToLowerInvariant())"
)
@()
}

$SwiftFlags += if ($DebugInfo) {
Expand Down Expand Up @@ -1578,22 +1569,12 @@ function Build-CMakeProject {
# TODO(compnerd) remove this once we have the early swift-driver
Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_USE_OLD_DRIVER "YES"

$SwiftFlags = if ($USePinnedCompilers.Contains("Swift")) {
@("-sdk", (Get-PinnedToolchainSDK))
} elseif ($SwiftSDK) {
@(
"-sdk", $SwiftSDK,
"-sysroot", $AndroidSysroot
)
[string[]] $SwiftFlags = @()

$SwiftFlags += if ($SwiftSDK) {
@("-sdk", $SwiftSDK, "-sysroot", $AndroidSysroot)
} else {
$RuntimeBinaryCache = Get-ProjectBinaryCache $Platform Runtime
$SwiftResourceDir = "${RuntimeBinaryCache}\lib\swift"

@(
"-sdk", $AndroidSysroot,
"-resource-dir", $SwiftResourceDir,
"-L", "$SwiftResourceDir\$($Platform.OS.ToString().ToLowerInvariant())"
)
@()
}

$SwiftFlags += @(
Expand Down Expand Up @@ -2004,6 +1985,7 @@ function Build-Compilers([Hashtable] $Platform, [string] $Variant) {
-Platform $Platform `
-UseMSVCCompilers C,CXX `
-UsePinnedCompilers Swift `
-SwiftSDK (Get-PinnedToolchainSDK) `
-BuildTargets @("install-distribution") `
-CacheScript $SourceCache\swift\cmake\caches\Windows-$($Platform.Architecture.LLVMName).cmake `
-Defines (Get-CompilersDefines $Platform $Variant)
Expand Down Expand Up @@ -2065,6 +2047,7 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test
-Platform $Platform `
-UseMSVCCompilers C,CXX `
-UsePinnedCompilers Swift `
-SwiftSDK (Get-PinnedToolchainSDK) `
-BuildTargets $Targets `
-CacheScript $SourceCache\swift\cmake\caches\Windows-$($Platform.Architecture.LLVMName).cmake `
-Defines $TestingDefines
Expand Down Expand Up @@ -2400,8 +2383,9 @@ function Build-Runtime([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform Runtime) `
-InstallTo "$(Get-SwiftSDK $Platform.OS)\usr" `
-Platform $Platform `
-CacheScript $SourceCache\swift\cmake\caches\Runtime-$($Platform.OS.ToString())-$($Platform.Architecture.LLVMName).cmake `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK $null `
-CacheScript $SourceCache\swift\cmake\caches\Runtime-$($Platform.OS.ToString())-$($Platform.Architecture.LLVMName).cmake `
-Defines ($PlatformDefines + @{
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
CMAKE_Swift_COMPILER_WORKS = "YES";
Expand Down Expand Up @@ -2444,6 +2428,7 @@ function Test-Runtime([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform Runtime) `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK $null `
-BuildTargets check-swift-validation-only_non_executable `
-Defines @{
SWIFT_INCLUDE_TESTS = "YES";
Expand Down Expand Up @@ -2518,6 +2503,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK $null `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
Expand Down Expand Up @@ -2546,6 +2532,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK $null `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
Expand All @@ -2564,6 +2551,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK $null `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
Expand All @@ -2582,6 +2570,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK $null `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
Expand All @@ -2601,6 +2590,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK $null `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
Expand All @@ -2621,6 +2611,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers CXX,Swift `
-SwiftSDK $null `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
Expand Down Expand Up @@ -2702,8 +2693,8 @@ function Build-Dispatch([Hashtable] $Platform) {
-Bin (Get-ProjectBinaryCache $Platform Dispatch) `
-InstallTo "$(Get-SwiftSDK $Platform.OS)\usr" `
-Platform $Platform `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-Defines @{
ENABLE_SWIFT = "YES";
}
Expand All @@ -2717,9 +2708,9 @@ function Test-Dispatch {
-Src $SourceCache\swift-corelibs-libdispatch `
-Bin (Get-ProjectBinaryCache $BuildPlatform Dispatch) `
-Platform $BuildPlatform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $BuildPlatform.OS) `
-BuildTargets default,ExperimentalTest `
-UseBuiltCompilers C,CXX,Swift `
-Defines @{
ENABLE_SWIFT = "YES";
}
Expand Down Expand Up @@ -2863,14 +2854,19 @@ function Test-XCTest {
Invoke-IsolatingEnvVars {
$env:Path = "$(Get-ProjectBinaryCache $BuildPlatform XCTest);$(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation)\bin;$(Get-ProjectBinaryCache $BuildPlatform Dispatch);$(Get-ProjectBinaryCache $BuildPlatform Runtime)\bin;${env:Path};$UnixToolsBinDir"

$RuntimeBinaryCache = Get-ProjectBinaryCache $BuildPlatform Runtime
$SwiftRuntimeDirectory = "${RuntimeBinaryCache}\lib\swift"

Build-CMakeProject `
-Src $SourceCache\swift-corelibs-xctest `
-Bin (Get-ProjectBinaryCache $BuildPlatform XCTest) `
-Platform $BuildPlatform `
-UseBuiltCompilers Swift `
-SwiftSDK $null `
-BuildTargets default,check-xctest `
-Defines @{
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
CMAKE_Swift_FLAGS = @("-resource-dir", $SwiftRuntimeDirectory, "-vfsoverlay", "${RuntimeBinaryCache}\stdlib\windows-vfs-overlay.yaml");
ENABLE_TESTING = "YES";
dispatch_DIR = $(Get-ProjectCMakeModules $BuildPlatform Dispatch);
Foundation_DIR = $(Get-ProjectCMakeModules $BuildPlatform DynamicFoundation);
Expand Down