Merge pull request #80082 from compnerd/isolated

utils: split `Build-*` into `Build-` and `Test-`
This commit is contained in:
Saleem Abdulrasool
2025-03-19 16:31:04 -07:00
committed by GitHub

View File

@@ -2283,30 +2283,36 @@ function Write-SDKSettingsPlist([Platform]$Platform, $Arch) {
$SDKSettings | ConvertTo-JSON | Out-FIle -FilePath "$(Get-SwiftSDK $Platform)\SDKSettings.json"
}
function Build-Dispatch([Platform]$Platform, $Arch, [switch]$Test = $false) {
Invoke-IsolatingEnvVars {
if ($Test) {
$Targets = @("default", "ExperimentalTest")
$InstallPath = ""
$env:CTEST_OUTPUT_ON_FAILURE = "YES"
} else {
$Targets = @("install")
$InstallPath = "$(Get-SwiftSDK $Platform)\usr"
}
function Build-Dispatch([Platform]$Platform, $Arch) {
Build-CMakeProject `
-Src $SourceCache\swift-corelibs-libdispatch `
-Bin (Get-ProjectBinaryCache $Arch Dispatch) `
-InstallTo $InstallPath `
-InstallTo "$(Get-SwiftSDK $Platform)\usr" `
-Arch $Arch `
-Platform $Platform `
-BuildTargets $Targets `
-SwiftSDK (Get-SwiftSDK $Platform) `
-UseBuiltCompilers C,CXX,Swift `
-Defines @{
ENABLE_SWIFT = "YES";
}
}
function Test-Dispatch {
Invoke-IsolatingEnvVars {
$env:CTEST_OUTPUT_ON_FAILURE = "YES"
Build-CMakeProject `
-Src $SourceCache\swift-corelibs-libdispatch `
-Bin (Get-ProjectBinaryCache $BuildArch Dispatch) `
-Arch $BuildArch `
-Platform Windows `
-SwiftSDK (Get-SwiftSDK Windows) `
-BuildTargets default,ExperimentalTest `
-UseBuiltCompilers C,CXX,Swift `
-Defines @{
ENABLE_SWIFT = "YES";
}
}
}
function Build-Foundation {
@@ -2317,41 +2323,14 @@ function Build-Foundation {
[Platform] $Platform,
[Parameter(Position = 1, Mandatory = $true)]
[hashtable] $Arch,
[switch] $Static = $false,
[switch] $Test = $false
[switch] $Static = $false
)
if ($Test) {
# Foundation tests build via swiftpm rather than CMake
Build-SPMProject `
-Action Test `
-Src $SourceCache\swift-foundation `
-Bin "$BinaryCache\$($Arch.LLVMTarget)\CoreFoundationTests" `
-Arch $HostArch `
-Configuration $FoundationTestConfiguration
$ShortArch = $Arch.LLVMName
Invoke-IsolatingEnvVars {
$env:DISPATCH_INCLUDE_PATH="$(Get-SwiftSDK $Platform)/usr/include"
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/$Platform/$ShortArch"
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/$Platform/$ShortArch"
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/$Platform/$ShortArch"
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
Build-SPMProject `
-Action Test `
-Src $SourceCache\swift-corelibs-foundation `
-Bin "$BinaryCache\$($Arch.LLVMTarget)\FoundationTests" `
-Arch $HostArch `
-Configuration $FoundationTestConfiguration
}
} else {
$FoundationBinaryCache = if ($Static) {
Get-ProjectBinaryCache $Arch StaticFoundation
} else {
Get-ProjectBinaryCache $Arch DynamicFoundation
}
$ShortArch = $Arch.LLVMName
Build-CMakeProject `
-Src $SourceCache\swift-corelibs-foundation `
@@ -2368,12 +2347,12 @@ function Build-Foundation {
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
ENABLE_TESTING = "NO";
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$ShortArch\cmake\CURL";
LibXml2_DIR = "$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$ShortArch\cmake\libxml2-2.11.5";
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$($Arch.LLVMName)\cmake\CURL";
LibXml2_DIR = "$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$($Arch.LLVMName)\cmake\libxml2-2.11.5";
ZLIB_LIBRARY = if ($Platform -eq "Windows") {
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\zlibstatic.lib"
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$($Arch.LLVMName)\zlibstatic.lib"
} else {
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\libz.a"
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$($Arch.LLVMName)\libz.a"
};
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
dispatch_DIR = (Get-ProjectCMakeModules $Arch Dispatch);
@@ -2384,6 +2363,29 @@ function Build-Foundation {
SwiftFoundation_MACRO = "$(Get-ProjectBinaryCache $BuildArch FoundationMacros)\bin"
}
}
function Test-Foundation {
# Foundation tests build via swiftpm rather than CMake
Build-SPMProject `
-Action Test `
-Src $SourceCache\swift-foundation `
-Bin "$BinaryCache\$($BuildArch.LLVMTarget)\CoreFoundationTests" `
-Arch $BuildArch
Invoke-IsolatingEnvVars {
$env:DISPATCH_INCLUDE_PATH="$(Get-SwiftSDK Windows)/usr/include"
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/windows/$($BuildArch.LLVMName)"
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/windows/$($BuildArch.LLVMName)"
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/windows/$($BuildArch.LLVMName)"
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
Build-SPMProject `
-Action Test `
-Src $SourceCache\swift-corelibs-foundation `
-Bin "$BinaryCache\$($BuildArch.LLVMTarget)\FoundationTests" `
-Arch $BuildArch `
-Configuration $FoundationTestConfiguration
}
}
function Build-FoundationMacros() {
@@ -2474,6 +2476,10 @@ function Build-Testing([Platform]$Platform, $Arch) {
}
}
function Test-Testing {
throw "testing Testing is not supported"
}
function Write-PlatformInfoPlist([Platform] $Platform) {
$Settings = @{
DefaultProperties = @{
@@ -2579,46 +2585,53 @@ function Build-ToolsSupportCore($Arch) {
}
}
function Build-LLBuild($Arch, [switch]$Test = $false) {
Invoke-IsolatingEnvVars {
if ($Test) {
function Build-LLBuild($Arch) {
Build-CMakeProject `
-Src $SourceCache\llbuild `
-Bin (Get-ProjectBinaryCache $Arch LLBuild) `
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
-Arch $Arch `
-Platform Windows `
-UseMSVCCompilers CXX `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK Windows) `
-Defines @{
BUILD_SHARED_LIBS = "YES";
LLBUILD_SUPPORT_BINDINGS = "Swift";
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
}
}
function Test-LLBuild {
# Build additional llvm executables needed by tests
Invoke-IsolatingEnvVars {
Invoke-VsDevShell $BuildArch
Invoke-Program ninja.exe -C (Get-ProjectBinaryCache $BuildArch BuildTools) FileCheck not
}
$Targets = @("default", "test-llbuild")
$TestingDefines = @{
FILECHECK_EXECUTABLE = ([IO.Path]::Combine((Get-ProjectBinaryCache $BuildArch BuildTools), "bin", "FileCheck.exe"));
LIT_EXECUTABLE = "$SourceCache\llvm-project\llvm\utils\lit\lit.py";
}
Invoke-IsolatingEnvVars {
$env:Path = "$env:Path;$UnixToolsBinDir"
$env:AR = ([IO.Path]::Combine((Get-ProjectBinaryCache $BuildArch Compilers), "bin", "llvm-ar.exe"))
$env:CLANG = ([IO.Path]::Combine((Get-ProjectBinaryCache $BuildArch Compilers), "bin", "clang.exe"))
$InstallPath = ""
} else {
$Targets = @()
$TestingDefines = @{}
$InstallPath = "$($Arch.ToolchainInstallRoot)\usr"
}
Build-CMakeProject `
-Src $SourceCache\llbuild `
-Bin (Get-ProjectBinaryCache $Arch LLBuild) `
-InstallTo $InstallPath `
-Arch $Arch `
-Bin (Get-ProjectBinaryCache $BuildArch LLBuild) `
-Arch $BuildArch `
-Platform Windows `
-UseMSVCCompilers CXX `
-UseBuiltCompilers Swift `
-SwiftSDK (Get-SwiftSDK Windows) `
-BuildTargets $Targets `
-Defines ($TestingDefines + @{
-BuildTargets default,test-llbuild `
-Defines = @{
BUILD_SHARED_LIBS = "YES";
FILECHECK_EXECUTABLE = ([IO.Path]::Combine((Get-ProjectBinaryCache $BuildArch BuildTools), "bin", "FileCheck.exe"));
LIT_EXECUTABLE = "$SourceCache\llvm-project\llvm\utils\lit\lit.py";
LLBUILD_SUPPORT_BINDINGS = "Swift";
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
})
}
}
}
@@ -3280,20 +3293,12 @@ if (-not $IsCrossCompiling) {
Build-Compilers $HostArch @Tests
}
if ($Test -contains "dispatch") {
Build-Dispatch Windows $HostArch -Test
}
if ($Test -contains "foundation") {
Build-Foundation Windows $HostArch -Test
}
if ($Test -contains "xctest") {
Test-XCTest
}
if ($Test -contains "testing") {
Build-Testing Windows $HostArch -Test
}
if ($Test -contains "llbuild") { Build-LLBuild $HostArch -Test }
if ($Test -contains "swiftpm") { Test-PackageManager $HostArch }
if ($Test -contains "dispatch") { Test-Dispatch }
if ($Test -contains "foundation") { Test-Foundation }
if ($Test -contains "xctest") { Test-XCTest }
if ($Test -contains "testing") { Test-Testing }
if ($Test -contains "llbuild") { Test-LLBuild }
if ($Test -contains "swiftpm") { Test-PackageManager }
if ($Test -contains "swift-format") { Test-Format }
if ($Test -contains "sourcekit-lsp") { Test-SourceKitLSP }