Skip to content

Commit 5e5a272

Browse files
committed
utils: flesh out the experimental SDK and prepare to package
Adjust the build of the experimental SDK to build the overlays and the string processing library. Additionally adjust the installer build to allow us to package and distribute the static build of the runtime.
1 parent dfa4bf7 commit 5e5a272

File tree

1 file changed

+94
-3
lines changed

1 file changed

+94
-3
lines changed

utils/build.ps1

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ enum Project {
643643
ClangRuntime
644644
SwiftInspect
645645
ExperimentalRuntime
646+
ExperimentalOverlay
647+
ExperimentalStringProcessing
648+
ExperimentalSynchronization
649+
ExperimentalDispatch
646650
StaticFoundation
647651
}
648652

@@ -2276,21 +2280,96 @@ function Build-ExperimentalRuntime {
22762280
CMAKE_Swift_COMPILER_WORKS = "YES";
22772281
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
22782282
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2283+
2284+
# NOTE(compnerd) we can get away with this currently because we only
2285+
# use the C portion of the dispatch build, which is always built
2286+
# dynamically.
22792287
dispatch_DIR = (Get-ProjectCMakeModules $Platform Dispatch);
22802288
SwiftCore_ENABLE_CONCURRENCY = "YES";
22812289
}
2290+
2291+
Build-CMakeProject `
2292+
-Src $SourceCache\swift\Runtimes\Overlay `
2293+
-Bin (Get-ProjectBinaryCache $Platform ExperimentalOverlay) `
2294+
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
2295+
-Platform $Platform `
2296+
-UseBuiltCompilers C,CXX,Swift `
2297+
-UseGNUDriver `
2298+
-Defines @{
2299+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2300+
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2301+
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
2302+
CMAKE_Swift_COMPILER_WORKS = "YES";
2303+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2304+
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2305+
}
2306+
2307+
Build-CMakeProject `
2308+
-Src $SourceCache\swift\Runtimes\Supplemental\StringProcessing `
2309+
-Bin (Get-ProjectBinaryCache $Platform ExperimentalStringProcessing) `
2310+
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
2311+
-Platform $Platform `
2312+
-UseBuiltCompilers C,Swift `
2313+
-UseGNUDriver `
2314+
-Defines @{
2315+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2316+
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2317+
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
2318+
CMAKE_Swift_COMPILER_WORKS = "YES";
2319+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2320+
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2321+
}
2322+
2323+
Build-CMakeProject `
2324+
-Src $SourceCache\swift\Runtimes\Supplemental\Synchronization `
2325+
-Bin (Get-ProjectBinaryCache $Platform ExperimentalSynchronization) `
2326+
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
2327+
-Platform $Platform `
2328+
-UseBuiltCompilers C,Swift `
2329+
-UseGNUDriver `
2330+
-Defines @{
2331+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2332+
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2333+
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
2334+
CMAKE_Swift_COMPILER_WORKS = "YES";
2335+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2336+
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2337+
}
2338+
2339+
# FIXME(compnerd) workaround the build not copying the clang resources into place
2340+
if ($Static) {
2341+
& "$ninja" -C $(Get-ProjectBinaryCache $BuildPlatform Compilers) symlink_clang_headers_static
2342+
}
2343+
Build-CMakeProject `
2344+
-Src $SourceCache\swift-corelibs-libdispatch `
2345+
-Bin (Get-ProjectBinaryCache $Platform ExperimentalDispatch) `
2346+
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
2347+
-Platform $Platform `
2348+
-UseBuiltCompilers C,CXX,Swift `
2349+
-SwiftSDK (Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental") `
2350+
-Defines @{
2351+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2352+
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2353+
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
2354+
CMAKE_Swift_COMPILER_WORKS = "YES";
2355+
CMAKE_Swift_FLAGS = if ($Static) { @("-static-stdlib", "-Xfrontend", "-use-static-resource-dir") } else { "" };
2356+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2357+
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2358+
2359+
ENABLE_SWIFT = "YES";
2360+
}
22822361
}
22832362
}
22842363

2285-
function Write-SDKSettingsPlist([OS] $OS) {
2364+
function Write-SDKSettingsPlist([OS] $OS, [string] $Identifier = $OS.ToString()) {
22862365
$SDKSettings = @{
22872366
DefaultProperties = @{
22882367
}
22892368
}
22902369
if ($OS -eq [OS]::Windows) {
22912370
$SDKSettings.DefaultProperties.DEFAULT_USE_RUNTIME = "MD"
22922371
}
2293-
Write-PList -Settings $SDKSettings -Path "$(Get-SwiftSDK $OS)\SDKSettings.plist"
2372+
Write-PList -Settings $SDKSettings -Path "$(Get-SwiftSDK $OS -Identifier $Identifier)\SDKSettings.plist"
22942373

22952374
$SDKSettings = @{
22962375
CanonicalName = $OS.ToString()
@@ -2324,7 +2403,7 @@ function Write-SDKSettingsPlist([OS] $OS) {
23242403
$SDKSettings.SupportedTargets.android.Archs = $AndroidSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName } | Sort-Object
23252404
}
23262405
}
2327-
$SDKSettings | ConvertTo-JSON -Depth 4 | Out-FIle -FilePath "$(Get-SwiftSDK $OS)\SDKSettings.json"
2406+
$SDKSettings | ConvertTo-JSON -Depth 4 | Out-FIle -FilePath "$(Get-SwiftSDK $OS -Identifier $Identifier)\SDKSettings.json"
23282407
}
23292408

23302409
function Build-Dispatch([Hashtable] $Platform) {
@@ -3225,12 +3304,18 @@ if (-not $SkipBuild) {
32253304
Move-Item $_.FullName "$(Get-SwiftSDK Windows)\usr\lib\swift\windows\$($Platform.Architecture.LLVMName)\" | Out-Null
32263305
}
32273306

3307+
Get-ChildItem "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift_static\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object {
3308+
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
3309+
Move-Item $_.FullName "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift_static\windows\$($Platform.Architecture.LLVMName)\" | Out-Null
3310+
}
3311+
32283312
Copy-Directory "$(Get-SwiftSDK Windows)\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Platform), "Runtimes", $ProductVersion, "usr"))"
32293313
}
32303314

32313315
Install-Platform $WindowsSDKPlatforms Windows
32323316
Write-PlatformInfoPlist Windows
32333317
Write-SDKSettingsPlist Windows
3318+
Write-SDKSettingsPlist Windows -Identifier WindowsExperimental
32343319

32353320
if ($Android) {
32363321
foreach ($Platform in $AndroidSDKPlatforms) {
@@ -3241,11 +3326,17 @@ if (-not $SkipBuild) {
32413326
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
32423327
Move-Item $_.FullName "$(Get-SwiftSDK Android)\usr\lib\swift\android\$($Platform.Architecture.LLVMName)\" | Out-Null
32433328
}
3329+
3330+
Get-ChildItem "$(Get-SwiftSDK Android -Identifier AndroidExperimental)\usr\lib\swift_static\android" -File | Where-Object { $_.Name -match "*.a$|*.so$" } | ForEach-Object {
3331+
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
3332+
Move-Item $_.FullName "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift_static\windows\$($Platform.Architecture.LLVMName)\" | Out-Null
3333+
}
32443334
}
32453335

32463336
Install-Platform $AndroidSDKPlatforms Android
32473337
Write-PlatformInfoPlist Android
32483338
Write-SDKSettingsPlist Android
3339+
Write-SDKSettingsPlist Android -Identifier AndroidExperimental
32493340

32503341
# Android swift-inspect only supports 64-bit platforms.
32513342
$AndroidSDKPlatforms | Where-Object { @("arm64-v8a", "x86_64") -contains $_.Architecture.ABI } | ForEach-Object {

0 commit comments

Comments
 (0)