mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #80082 from compnerd/isolated
utils: split `Build-*` into `Build-` and `Test-`
This commit is contained in:
241
utils/build.ps1
241
utils/build.ps1
@@ -2283,25 +2283,31 @@ function Write-SDKSettingsPlist([Platform]$Platform, $Arch) {
|
|||||||
$SDKSettings | ConvertTo-JSON | Out-FIle -FilePath "$(Get-SwiftSDK $Platform)\SDKSettings.json"
|
$SDKSettings | ConvertTo-JSON | Out-FIle -FilePath "$(Get-SwiftSDK $Platform)\SDKSettings.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Build-Dispatch([Platform]$Platform, $Arch, [switch]$Test = $false) {
|
function Build-Dispatch([Platform]$Platform, $Arch) {
|
||||||
Invoke-IsolatingEnvVars {
|
Build-CMakeProject `
|
||||||
if ($Test) {
|
-Src $SourceCache\swift-corelibs-libdispatch `
|
||||||
$Targets = @("default", "ExperimentalTest")
|
-Bin (Get-ProjectBinaryCache $Arch Dispatch) `
|
||||||
$InstallPath = ""
|
-InstallTo "$(Get-SwiftSDK $Platform)\usr" `
|
||||||
$env:CTEST_OUTPUT_ON_FAILURE = "YES"
|
-Arch $Arch `
|
||||||
} else {
|
-Platform $Platform `
|
||||||
$Targets = @("install")
|
-SwiftSDK (Get-SwiftSDK $Platform) `
|
||||||
$InstallPath = "$(Get-SwiftSDK $Platform)\usr"
|
-UseBuiltCompilers C,CXX,Swift `
|
||||||
|
-Defines @{
|
||||||
|
ENABLE_SWIFT = "YES";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-Dispatch {
|
||||||
|
Invoke-IsolatingEnvVars {
|
||||||
|
$env:CTEST_OUTPUT_ON_FAILURE = "YES"
|
||||||
|
|
||||||
Build-CMakeProject `
|
Build-CMakeProject `
|
||||||
-Src $SourceCache\swift-corelibs-libdispatch `
|
-Src $SourceCache\swift-corelibs-libdispatch `
|
||||||
-Bin (Get-ProjectBinaryCache $Arch Dispatch) `
|
-Bin (Get-ProjectBinaryCache $BuildArch Dispatch) `
|
||||||
-InstallTo $InstallPath `
|
-Arch $BuildArch `
|
||||||
-Arch $Arch `
|
-Platform Windows `
|
||||||
-Platform $Platform `
|
-SwiftSDK (Get-SwiftSDK Windows) `
|
||||||
-BuildTargets $Targets `
|
-BuildTargets default,ExperimentalTest `
|
||||||
-SwiftSDK (Get-SwiftSDK $Platform) `
|
|
||||||
-UseBuiltCompilers C,CXX,Swift `
|
-UseBuiltCompilers C,CXX,Swift `
|
||||||
-Defines @{
|
-Defines @{
|
||||||
ENABLE_SWIFT = "YES";
|
ENABLE_SWIFT = "YES";
|
||||||
@@ -2317,72 +2323,68 @@ function Build-Foundation {
|
|||||||
[Platform] $Platform,
|
[Platform] $Platform,
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
[hashtable] $Arch,
|
[hashtable] $Arch,
|
||||||
[switch] $Static = $false,
|
[switch] $Static = $false
|
||||||
[switch] $Test = $false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($Test) {
|
$FoundationBinaryCache = if ($Static) {
|
||||||
# Foundation tests build via swiftpm rather than CMake
|
Get-ProjectBinaryCache $Arch StaticFoundation
|
||||||
|
} else {
|
||||||
|
Get-ProjectBinaryCache $Arch DynamicFoundation
|
||||||
|
}
|
||||||
|
|
||||||
|
Build-CMakeProject `
|
||||||
|
-Src $SourceCache\swift-corelibs-foundation `
|
||||||
|
-Bin $FoundationBinaryCache `
|
||||||
|
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform -Identifier "${Platform}Experimental")\usr" } else { "$(Get-SwiftSDK $Platform)\usr" }) `
|
||||||
|
-Arch $Arch `
|
||||||
|
-Platform $Platform `
|
||||||
|
-UseBuiltCompilers ASM,C,CXX,Swift `
|
||||||
|
-SwiftSDK (Get-SwiftSDK $Platform) `
|
||||||
|
-Defines @{
|
||||||
|
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
|
||||||
|
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
|
||||||
|
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
|
||||||
|
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\$($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\$($Arch.LLVMName)\zlibstatic.lib"
|
||||||
|
} else {
|
||||||
|
"$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);
|
||||||
|
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostArch Compilers);
|
||||||
|
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
|
||||||
|
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
|
||||||
|
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
|
||||||
|
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 `
|
Build-SPMProject `
|
||||||
-Action Test `
|
-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 `
|
-Src $SourceCache\swift-corelibs-foundation `
|
||||||
-Bin $FoundationBinaryCache `
|
-Bin "$BinaryCache\$($BuildArch.LLVMTarget)\FoundationTests" `
|
||||||
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform -Identifier "${Platform}Experimental")\usr" } else { "$(Get-SwiftSDK $Platform)\usr" }) `
|
-Arch $BuildArch `
|
||||||
-Arch $Arch `
|
-Configuration $FoundationTestConfiguration
|
||||||
-Platform $Platform `
|
|
||||||
-UseBuiltCompilers ASM,C,CXX,Swift `
|
|
||||||
-SwiftSDK (Get-SwiftSDK $Platform) `
|
|
||||||
-Defines @{
|
|
||||||
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
|
|
||||||
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
|
|
||||||
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
|
|
||||||
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";
|
|
||||||
ZLIB_LIBRARY = if ($Platform -eq "Windows") {
|
|
||||||
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\zlibstatic.lib"
|
|
||||||
} else {
|
|
||||||
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\libz.a"
|
|
||||||
};
|
|
||||||
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
|
|
||||||
dispatch_DIR = (Get-ProjectCMakeModules $Arch Dispatch);
|
|
||||||
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostArch Compilers);
|
|
||||||
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
|
|
||||||
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
|
|
||||||
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
|
|
||||||
SwiftFoundation_MACRO = "$(Get-ProjectBinaryCache $BuildArch FoundationMacros)\bin"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2474,6 +2476,10 @@ function Build-Testing([Platform]$Platform, $Arch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Test-Testing {
|
||||||
|
throw "testing Testing is not supported"
|
||||||
|
}
|
||||||
|
|
||||||
function Write-PlatformInfoPlist([Platform] $Platform) {
|
function Write-PlatformInfoPlist([Platform] $Platform) {
|
||||||
$Settings = @{
|
$Settings = @{
|
||||||
DefaultProperties = @{
|
DefaultProperties = @{
|
||||||
@@ -2579,46 +2585,53 @@ function Build-ToolsSupportCore($Arch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Build-LLBuild($Arch, [switch]$Test = $false) {
|
function Build-LLBuild($Arch) {
|
||||||
Invoke-IsolatingEnvVars {
|
Build-CMakeProject `
|
||||||
if ($Test) {
|
-Src $SourceCache\llbuild `
|
||||||
# Build additional llvm executables needed by tests
|
-Bin (Get-ProjectBinaryCache $Arch LLBuild) `
|
||||||
Invoke-IsolatingEnvVars {
|
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
|
||||||
Invoke-VsDevShell $BuildArch
|
-Arch $Arch `
|
||||||
Invoke-Program ninja.exe -C (Get-ProjectBinaryCache $BuildArch BuildTools) FileCheck not
|
-Platform Windows `
|
||||||
}
|
-UseMSVCCompilers CXX `
|
||||||
|
-UseBuiltCompilers Swift `
|
||||||
$Targets = @("default", "test-llbuild")
|
-SwiftSDK (Get-SwiftSDK Windows) `
|
||||||
$TestingDefines = @{
|
-Defines @{
|
||||||
FILECHECK_EXECUTABLE = ([IO.Path]::Combine((Get-ProjectBinaryCache $BuildArch BuildTools), "bin", "FileCheck.exe"));
|
BUILD_SHARED_LIBS = "YES";
|
||||||
LIT_EXECUTABLE = "$SourceCache\llvm-project\llvm\utils\lit\lit.py";
|
LLBUILD_SUPPORT_BINDINGS = "Swift";
|
||||||
}
|
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
|
||||||
$env:Path = "$env:Path;$UnixToolsBinDir"
|
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
|
||||||
$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"
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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"))
|
||||||
|
|
||||||
Build-CMakeProject `
|
Build-CMakeProject `
|
||||||
-Src $SourceCache\llbuild `
|
-Src $SourceCache\llbuild `
|
||||||
-Bin (Get-ProjectBinaryCache $Arch LLBuild) `
|
-Bin (Get-ProjectBinaryCache $BuildArch LLBuild) `
|
||||||
-InstallTo $InstallPath `
|
-Arch $BuildArch `
|
||||||
-Arch $Arch `
|
|
||||||
-Platform Windows `
|
-Platform Windows `
|
||||||
-UseMSVCCompilers CXX `
|
-UseMSVCCompilers CXX `
|
||||||
-UseBuiltCompilers Swift `
|
-UseBuiltCompilers Swift `
|
||||||
-SwiftSDK (Get-SwiftSDK Windows) `
|
-SwiftSDK (Get-SwiftSDK Windows) `
|
||||||
-BuildTargets $Targets `
|
-BuildTargets default,test-llbuild `
|
||||||
-Defines ($TestingDefines + @{
|
-Defines = @{
|
||||||
BUILD_SHARED_LIBS = "YES";
|
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";
|
LLBUILD_SUPPORT_BINDINGS = "Swift";
|
||||||
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
|
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
|
||||||
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
|
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3280,20 +3293,12 @@ if (-not $IsCrossCompiling) {
|
|||||||
Build-Compilers $HostArch @Tests
|
Build-Compilers $HostArch @Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Test -contains "dispatch") {
|
if ($Test -contains "dispatch") { Test-Dispatch }
|
||||||
Build-Dispatch Windows $HostArch -Test
|
if ($Test -contains "foundation") { Test-Foundation }
|
||||||
}
|
if ($Test -contains "xctest") { Test-XCTest }
|
||||||
if ($Test -contains "foundation") {
|
if ($Test -contains "testing") { Test-Testing }
|
||||||
Build-Foundation Windows $HostArch -Test
|
if ($Test -contains "llbuild") { Test-LLBuild }
|
||||||
}
|
if ($Test -contains "swiftpm") { Test-PackageManager }
|
||||||
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 "swift-format") { Test-Format }
|
if ($Test -contains "swift-format") { Test-Format }
|
||||||
if ($Test -contains "sourcekit-lsp") { Test-SourceKitLSP }
|
if ($Test -contains "sourcekit-lsp") { Test-SourceKitLSP }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user