Skip to content

Commit f99db42

Browse files
committed
utils: split Build-Foundation into Build- and Test- function
Split up the test routines from the build routines. This is motivated by the desire to simplify (remove logic flow) and to help get more accurate timing data.
1 parent e325955 commit f99db42

File tree

1 file changed

+57
-65
lines changed

1 file changed

+57
-65
lines changed

utils/build.ps1

Lines changed: 57 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,71 +2350,67 @@ function Build-Foundation {
23502350
[Platform] $Platform,
23512351
[Parameter(Position = 1, Mandatory = $true)]
23522352
[hashtable] $Arch,
2353-
[switch] $Static = $false,
2354-
[switch] $Test = $false
2353+
[switch] $Static = $false
23552354
)
23562355

2357-
if ($Test) {
2358-
# Foundation tests build via swiftpm rather than CMake
2359-
Build-SPMProject `
2360-
-Action Test `
2361-
-Src $SourceCache\swift-foundation `
2362-
-Bin "$BinaryCache\$($Arch.LLVMTarget)\CoreFoundationTests" `
2363-
-Arch $HostArch
2364-
2365-
$ShortArch = $Arch.LLVMName
2366-
Invoke-IsolatingEnvVars {
2367-
$env:DISPATCH_INCLUDE_PATH="$(Get-SwiftSDK $Platform)/usr/include"
2368-
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/$Platform/$ShortArch"
2369-
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
2370-
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/$Platform/$ShortArch"
2371-
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/$Platform/$ShortArch"
2372-
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
2373-
Build-SPMProject `
2374-
-Action Test `
2375-
-Src $SourceCache\swift-corelibs-foundation `
2376-
-Bin "$BinaryCache\$($Arch.LLVMTarget)\FoundationTests" `
2377-
-Arch $HostArch
2378-
}
2356+
$FoundationBinaryCache = if ($Static) {
2357+
Get-TargetProjectBinaryCache $Arch StaticFoundation
23792358
} else {
2380-
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
2381-
$FoundationBinaryCache = if ($Static) {
2382-
Get-TargetProjectBinaryCache $Arch StaticFoundation
2383-
} else {
2384-
Get-TargetProjectBinaryCache $Arch DynamicFoundation
2359+
Get-TargetProjectBinaryCache $Arch DynamicFoundation
2360+
}
2361+
2362+
Build-CMakeProject `
2363+
-Src $SourceCache\swift-corelibs-foundation `
2364+
-Bin $FoundationBinaryCache `
2365+
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform -Identifier "${Platform}Experimental")\usr" } else { "$(Get-SwiftSDK $Platform)\usr" }) `
2366+
-Arch $Arch `
2367+
-Platform $Platform `
2368+
-UseBuiltCompilers ASM,C,CXX,Swift `
2369+
-SwiftSDK (Get-SwiftSDK $Platform) `
2370+
-Defines @{
2371+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2372+
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2373+
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
2374+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2375+
ENABLE_TESTING = "NO";
2376+
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
2377+
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$($Arch.LLVMName)\cmake\CURL";
2378+
LibXml2_DIR = "$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$($Arch.LLVMName)\cmake\libxml2-2.11.5";
2379+
ZLIB_LIBRARY = if ($Platform -eq "Windows") {
2380+
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$($Arch.LLVMName)\zlibstatic.lib"
2381+
} else {
2382+
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$($Arch.LLVMName)\libz.a"
2383+
};
2384+
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
2385+
dispatch_DIR = "$(Get-TargetProjectBinaryCache $Arch Dispatch)\cmake\modules";
2386+
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
2387+
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
2388+
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
2389+
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
2390+
SwiftFoundation_MACRO = "$(Get-BuildProjectBinaryCache FoundationMacros)\bin"
23852391
}
2386-
$ShortArch = $Arch.LLVMName
2392+
}
23872393

2388-
Build-CMakeProject `
2394+
function Test-Foundation {
2395+
# Foundation tests build via swiftpm rather than CMake
2396+
Build-SPMProject `
2397+
-Action Test `
2398+
-Src $SourceCache\swift-foundation `
2399+
-Bin "$BinaryCache\$($BuildArch.LLVMTarget)\CoreFoundationTests" `
2400+
-Arch $BuildArch
2401+
2402+
Invoke-IsolatingEnvVars {
2403+
$env:DISPATCH_INCLUDE_PATH="$(Get-SwiftSDK Windows)/usr/include"
2404+
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/windows/$($BuildArch.LLVMName)"
2405+
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
2406+
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/windows/$($BuildArch.LLVMName)"
2407+
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/windows/$($BuildArch.LLVMName)"
2408+
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
2409+
Build-SPMProject `
2410+
-Action Test `
23892411
-Src $SourceCache\swift-corelibs-foundation `
2390-
-Bin $FoundationBinaryCache `
2391-
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform -Identifier "${Platform}Experimental")\usr" } else { "$(Get-SwiftSDK $Platform)\usr" }) `
2392-
-Arch $Arch `
2393-
-Platform $Platform `
2394-
-UseBuiltCompilers ASM,C,CXX,Swift `
2395-
-SwiftSDK (Get-SwiftSDK $Platform) `
2396-
-Defines @{
2397-
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2398-
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2399-
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
2400-
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2401-
ENABLE_TESTING = "NO";
2402-
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
2403-
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$ShortArch\cmake\CURL";
2404-
LibXml2_DIR = "$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$ShortArch\cmake\libxml2-2.11.5";
2405-
ZLIB_LIBRARY = if ($Platform -eq "Windows") {
2406-
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\zlibstatic.lib"
2407-
} else {
2408-
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\libz.a"
2409-
};
2410-
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
2411-
dispatch_DIR = "$DispatchBinaryCache\cmake\modules";
2412-
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
2413-
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
2414-
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
2415-
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
2416-
SwiftFoundation_MACRO = "$(Get-BuildProjectBinaryCache FoundationMacros)\bin"
2417-
}
2412+
-Bin "$BinaryCache\$($BuildArch.LLVMTarget)\FoundationTests" `
2413+
-Arch $BuildArch
24182414
}
24192415
}
24202416

@@ -3387,12 +3383,8 @@ if (-not $IsCrossCompiling) {
33873383
if ($Test -contains "dispatch") {
33883384
Build-Dispatch Windows $HostArch -Test
33893385
}
3390-
if ($Test -contains "foundation") {
3391-
Build-Foundation Windows $HostArch -Test
3392-
}
3393-
if ($Test -contains "xctest") {
3394-
Test-XCTest
3395-
}
3386+
if ($Test -contains "foundation") { Test-Foundation }
3387+
if ($Test -contains "xctest") { Test-XCTest }
33963388
if ($Test -contains "testing") { Test-Testing }
33973389
if ($Test -contains "llbuild") { Test-LLBuild }
33983390
if ($Test -contains "swiftpm") { Test-PackageManager }

0 commit comments

Comments
 (0)