From f9587f3ad7f65900f0faa0bb7087a01dfe54a811 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 9 Sep 2025 19:15:39 -0700 Subject: [PATCH] build.ps1: extract XCTest from `Build-SDK` Strip out `Build-XCTest` from `Build-SDK`. This is done against the default SDK now for each architecture after the full SDK is built. --- utils/build.ps1 | 86 ++++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 76951ed1392a5..cb28d6455a4ed 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -188,6 +188,7 @@ param [string] $AndroidNDKVersion = "r27c", [ValidateRange(1, 36)] [int] $AndroidAPILevel = 28, + [string] $AndroidSDKDefault = "Android", [string[]] $AndroidSDKVersions = @("Android", "AndroidExperimental"), [string[]] $AndroidSDKArchitectures = @("aarch64", "armv7", "i686", "x86_64"), @@ -195,6 +196,7 @@ param [switch] $Windows = $true, [ValidatePattern("^\d+\.\d+\.\d+(?:-\w+)?")] [string] $WinSDKVersion = "", + [string] $WindowsSDKDefault = "Windows", [string[]] $WindowsSDKVersions = @("Windows", "WindowsExperimental"), [string[]] $WindowsSDKArchitectures = @("X64","X86","Arm64"), @@ -291,6 +293,7 @@ $KnownPlatforms = @{ }; BinaryDir = "bin64a"; Cache = @{}; + DefaultSDK = $WindowsSDKDefault; }; WindowsX64 = @{ @@ -304,6 +307,7 @@ $KnownPlatforms = @{ }; BinaryDir = "bin64"; Cache = @{}; + DefaultSDK = $WindowsSDKDefault; }; WindowsX86 = @{ @@ -317,6 +321,7 @@ $KnownPlatforms = @{ }; BinaryDir = "bin32"; Cache = @{}; + DefaultSDK = $WindowsSDKDefault; }; AndroidARMv7 = @{ @@ -330,6 +335,7 @@ $KnownPlatforms = @{ }; BinaryDir = "bin32a"; Cache = @{}; + DefaultSDK = $AndroidSDKDefault; }; AndroidARM64 = @{ @@ -343,6 +349,7 @@ $KnownPlatforms = @{ }; BinaryDir = "bin64a"; Cache = @{}; + DefaultSDK = $AndroidSDKDefault; }; AndroidX86 = @{ @@ -356,6 +363,7 @@ $KnownPlatforms = @{ }; BinaryDir = "bin32"; Cache = @{}; + DefaultSDK = $AndroidSDKDefault; }; AndroidX64 = @{ @@ -369,6 +377,7 @@ $KnownPlatforms = @{ }; BinaryDir = "bin64"; Cache = @{}; + DefaultSDK = $AndroidSDKDefault; }; } @@ -1865,8 +1874,13 @@ function Build-SPMProject { $Stopwatch = [Diagnostics.Stopwatch]::StartNew() Invoke-IsolatingEnvVars { - $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) + $RuntimeInstallRoot = if ($BuildPlatform.DefaultSDK -match "Experimental") { + [IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion.experimental"); + } else { + [IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion"); + } + Write-Host "Path = $RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}" $env:Path = "$RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}" $env:SDKROOT = (Get-SwiftSDK $Platform.OS) $env:SWIFTCI_USE_LOCAL_DEPS = "1" @@ -2988,7 +3002,7 @@ function Build-FoundationMacros([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ SwiftSyntax_DIR = $SwiftSyntaxDir; } @@ -3001,40 +3015,31 @@ function Build-XCTest([Hashtable] $Platform) { -InstallTo "$([IO.Path]::Combine((Get-PlatformRoot $Platform.OS), "Developer", "Library", "XCTest-$ProductVersion", "usr"))" ` -Platform $Platform ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_INSTALL_BINDIR = $Platform.BinaryDir; ENABLE_TESTING = "NO"; - dispatch_DIR = $(Get-ProjectCMakeModules $Platform Dispatch); - Foundation_DIR = $(Get-ProjectCMakeModules $Platform DynamicFoundation); XCTest_INSTALL_NESTED_SUBDIR = "YES"; } } function Test-XCTest { Invoke-IsolatingEnvVars { + $env:SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK $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 C,CXX,Swift ` - -SwiftSDK $null ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -BuildTargets default,check-xctest ` -Defines @{ - CMAKE_Swift_FLAGS = @("-resource-dir", $SwiftRuntimeDirectory, "-vfsoverlay", "${RuntimeBinaryCache}\stdlib\windows-vfs-overlay.yaml"); + BUILD_SHARED_LIBS = "YES"; ENABLE_TESTING = "YES"; - dispatch_DIR = $(Get-ProjectCMakeModules $BuildPlatform Dispatch); - Foundation_DIR = $(Get-ProjectCMakeModules $BuildPlatform DynamicFoundation); - LLVM_DIR = "$(Get-ProjectBinaryCache $BuildPlatform LLVM)\lib\cmake\llvm"; - XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation); - XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-ProjectBinaryCache $BuildPlatform Dispatch); - XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch"; + LLVM_MAIN_SRC_DIR = "$SourceCache/llvm-project/llvm"; } } } @@ -3111,8 +3116,7 @@ function Build-SDK([Hashtable] $Platform) { Invoke-BuildStep Build-Runtime $Platform Invoke-BuildStep Build-Dispatch $Platform Invoke-BuildStep Build-Foundation $Platform - Invoke-BuildStep Build-CompilerRuntime $Platform - Invoke-BuildStep Build-XCTest $Platform + Invoke-BuildStep Build-Testing $Platform } @@ -3241,7 +3245,7 @@ function Build-System([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform System) ` -Platform $Platform ` -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3255,7 +3259,7 @@ function Build-Subprocess([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform Subprocess) ` -Platform $Platform ` -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "NO"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3273,7 +3277,7 @@ function Build-Build([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers C,CXX,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines (@{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3294,7 +3298,7 @@ function Build-ToolsSupportCore([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3313,7 +3317,7 @@ function Build-LLBuild([Hashtable] $Platform) { -UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) ` -UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; LLBUILD_SUPPORT_BINDINGS = "Swift"; @@ -3341,7 +3345,7 @@ function Test-LLBuild { -UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) ` -UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $BuildPlatform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -BuildTargets default,test-llbuild ` -Defines = @{ BUILD_SHARED_LIBS = "YES"; @@ -3361,7 +3365,7 @@ function Build-ArgumentParser([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; BUILD_TESTING = "NO"; @@ -3376,7 +3380,7 @@ function Build-Driver([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers C,CXX,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3398,7 +3402,7 @@ function Build-Crypto([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform Crypto) ` -Platform $Platform ` -UseBuiltCompilers ASM, C, CXX, Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3414,7 +3418,7 @@ function Build-Collections([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3427,7 +3431,7 @@ function Build-ASN1([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform ASN1) ` -Platform $Platform ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3441,7 +3445,7 @@ function Build-Certificates([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform Certificates) ` -Platform $Platform ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3464,7 +3468,7 @@ function Build-PackageManager([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_Swift_FLAGS = @("-DCRYPTO_v2"); @@ -3492,7 +3496,7 @@ function Build-Markdown([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "NO"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3510,7 +3514,7 @@ function Build-Format([Hashtable] $Platform) { -UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) ` -UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; ArgumentParser_DIR = (Get-ProjectCMakeModules $Platform ArgumentParser); @@ -3569,7 +3573,7 @@ function Build-LMDB([Hashtable] $Platform) { } function Build-IndexStoreDB([Hashtable] $Platform) { - $SDKROOT = Get-SwiftSDK $Platform.OS + $SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK Build-CMakeProject ` -Src $SourceCache\indexstore-db ` -Bin (Get-ProjectBinaryCache $Platform IndexStoreDB) ` @@ -3593,7 +3597,7 @@ function Build-SourceKitLSP([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers); @@ -3705,7 +3709,7 @@ function Build-TestingMacros([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK $Platform.OS) ` + -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` -Defines @{ SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers); } @@ -3749,7 +3753,7 @@ function Build-Inspect([Hashtable] $Platform) { $InstallPath = "$(Get-PlatformRoot $Platform.OS)\Developer\Library\$(Get-ModuleTriple $Platform)" } - $SDKROOT = Get-SwiftSDK $Platform.OS + $SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK Build-CMakeProject ` -Src $SourceCache\swift\tools\swift-inspect ` @@ -4009,6 +4013,10 @@ if (-not $SkipBuild) { } } + foreach ($Build in $WindowsSDKBuilds) { + Invoke-BuildStep Build-XCTest $Build + } + Write-PlatformInfoPlist Windows } @@ -4062,6 +4070,10 @@ if (-not $SkipBuild) { } } + foreach ($Build in $AndroidSDKBuilds) { + Invoke-BuildStep Build-XCTest $Build + } + Write-PlatformInfoPlist Android # Android swift-inspect only supports 64-bit platforms.