Skip to content

Commit a4fdc33

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 2a9538e commit a4fdc33

File tree

1 file changed

+57
-64
lines changed

1 file changed

+57
-64
lines changed

utils/build.ps1

Lines changed: 57 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,70 +2311,67 @@ function Build-Foundation {
23112311
[Platform] $Platform,
23122312
[Parameter(Position = 1, Mandatory = $true)]
23132313
[hashtable] $Arch,
2314-
[switch] $Static = $false,
2315-
[switch] $Test = $false
2314+
[switch] $Static = $false
23162315
)
23172316

2318-
if ($Test) {
2319-
# Foundation tests build via swiftpm rather than CMake
2320-
Build-SPMProject `
2321-
-Action Test `
2322-
-Src $SourceCache\swift-foundation `
2323-
-Bin "$BinaryCache\$($Arch.LLVMTarget)\CoreFoundationTests" `
2324-
-Arch $HostArch
2325-
2326-
$ShortArch = $Arch.LLVMName
2327-
Invoke-IsolatingEnvVars {
2328-
$env:DISPATCH_INCLUDE_PATH="$(Get-SwiftSDK $Platform)/usr/include"
2329-
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/$Platform/$ShortArch"
2330-
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
2331-
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/$Platform/$ShortArch"
2332-
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/$Platform/$ShortArch"
2333-
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
2334-
Build-SPMProject `
2335-
-Action Test `
2336-
-Src $SourceCache\swift-corelibs-foundation `
2337-
-Bin "$BinaryCache\$($Arch.LLVMTarget)\FoundationTests" `
2338-
-Arch $HostArch
2339-
}
2317+
$FoundationBinaryCache = if ($Static) {
2318+
Get-ProjectBinaryCache $Arch StaticFoundation
23402319
} else {
2341-
$FoundationBinaryCache = if ($Static) {
2342-
Get-ProjectBinaryCache $Arch StaticFoundation
2343-
} else {
2344-
Get-ProjectBinaryCache $Arch DynamicFoundation
2320+
Get-ProjectBinaryCache $Arch DynamicFoundation
2321+
}
2322+
2323+
Build-CMakeProject `
2324+
-Src $SourceCache\swift-corelibs-foundation `
2325+
-Bin $FoundationBinaryCache `
2326+
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform -Identifier "${Platform}Experimental")\usr" } else { "$(Get-SwiftSDK $Platform)\usr" }) `
2327+
-Arch $Arch `
2328+
-Platform $Platform `
2329+
-UseBuiltCompilers ASM,C,CXX,Swift `
2330+
-SwiftSDK (Get-SwiftSDK $Platform) `
2331+
-Defines @{
2332+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2333+
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2334+
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
2335+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2336+
ENABLE_TESTING = "NO";
2337+
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
2338+
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$($Arch.LLVMName)\cmake\CURL";
2339+
LibXml2_DIR = "$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$($Arch.LLVMName)\cmake\libxml2-2.11.5";
2340+
ZLIB_LIBRARY = if ($Platform -eq "Windows") {
2341+
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$($Arch.LLVMName)\zlibstatic.lib"
2342+
} else {
2343+
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$($Arch.LLVMName)\libz.a"
2344+
};
2345+
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
2346+
dispatch_DIR = (Get-ProjectCMakeModules $Arch Dispatch);
2347+
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostArch Compilers);
2348+
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
2349+
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
2350+
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
2351+
SwiftFoundation_MACRO = "$(Get-ProjectBinaryCache $BuildArch FoundationMacros)\bin"
23452352
}
2346-
$ShortArch = $Arch.LLVMName
2353+
}
23472354

2348-
Build-CMakeProject `
2355+
function Test-Foundation {
2356+
# Foundation tests build via swiftpm rather than CMake
2357+
Build-SPMProject `
2358+
-Action Test `
2359+
-Src $SourceCache\swift-foundation `
2360+
-Bin "$BinaryCache\$($BuildArch.LLVMTarget)\CoreFoundationTests" `
2361+
-Arch $BuildArch
2362+
2363+
Invoke-IsolatingEnvVars {
2364+
$env:DISPATCH_INCLUDE_PATH="$(Get-SwiftSDK Windows)/usr/include"
2365+
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/windows/$($BuildArch.LLVMName)"
2366+
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
2367+
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/windows/$($BuildArch.LLVMName)"
2368+
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/windows/$($BuildArch.LLVMName)"
2369+
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
2370+
Build-SPMProject `
2371+
-Action Test `
23492372
-Src $SourceCache\swift-corelibs-foundation `
2350-
-Bin $FoundationBinaryCache `
2351-
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform -Identifier "${Platform}Experimental")\usr" } else { "$(Get-SwiftSDK $Platform)\usr" }) `
2352-
-Arch $Arch `
2353-
-Platform $Platform `
2354-
-UseBuiltCompilers ASM,C,CXX,Swift `
2355-
-SwiftSDK (Get-SwiftSDK $Platform) `
2356-
-Defines @{
2357-
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2358-
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2359-
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
2360-
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2361-
ENABLE_TESTING = "NO";
2362-
FOUNDATION_BUILD_TOOLS = if ($Platform -eq "Windows") { "YES" } else { "NO" };
2363-
CURL_DIR = "$LibraryRoot\curl-8.9.1\usr\lib\$Platform\$ShortArch\cmake\CURL";
2364-
LibXml2_DIR = "$LibraryRoot\libxml2-2.11.5\usr\lib\$Platform\$ShortArch\cmake\libxml2-2.11.5";
2365-
ZLIB_LIBRARY = if ($Platform -eq "Windows") {
2366-
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\zlibstatic.lib"
2367-
} else {
2368-
"$LibraryRoot\zlib-1.3.1\usr\lib\$Platform\$ShortArch\libz.a"
2369-
};
2370-
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
2371-
dispatch_DIR = (Get-ProjectCMakeModules $Arch Dispatch);
2372-
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostArch Compilers);
2373-
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
2374-
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
2375-
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
2376-
SwiftFoundation_MACRO = "$(Get-ProjectBinaryCache $BuildArch FoundationMacros)\bin"
2377-
}
2373+
-Bin "$BinaryCache\$($BuildArch.LLVMTarget)\FoundationTests" `
2374+
-Arch $BuildArch
23782375
}
23792376
}
23802377

@@ -3286,12 +3283,8 @@ if (-not $IsCrossCompiling) {
32863283
if ($Test -contains "dispatch") {
32873284
Build-Dispatch Windows $HostArch -Test
32883285
}
3289-
if ($Test -contains "foundation") {
3290-
Build-Foundation Windows $HostArch -Test
3291-
}
3292-
if ($Test -contains "xctest") {
3293-
Test-XCTest
3294-
}
3286+
if ($Test -contains "foundation") { Test-Foundation }
3287+
if ($Test -contains "xctest") { Test-XCTest }
32953288
if ($Test -contains "testing") { Test-Testing }
32963289
if ($Test -contains "llbuild") { Test-LLBuild }
32973290
if ($Test -contains "swiftpm") { Test-PackageManager }

0 commit comments

Comments
 (0)