Skip to content

utils: prepare for enabling the dynamic experimental SDK #83332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 83 additions & 47 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -707,15 +707,15 @@ enum Project {
ClangBuiltins
ClangRuntime
SwiftInspect
ExperimentalRuntime
ExperimentalOverlay
ExperimentalStringProcessing
ExperimentalSynchronization
ExperimentalDistributed
ExperimentalObservation
ExperimentalDispatch
ExperimentalDifferentiation
StaticFoundation
ExperimentalStaticRuntime
ExperimentalStaticOverlay
ExperimentalStaticStringProcessing
ExperimentalStaticSynchronization
ExperimentalStaticDistributed
ExperimentalStaticObservation
ExperimentalStaticDifferentiation
ExperimentalStaticDispatch
ExperimentalStaticFoundation
}

function Get-ProjectBinaryCache([Hashtable] $Platform, [Project] $Project) {
Expand Down Expand Up @@ -2455,15 +2455,7 @@ function Test-Runtime([Hashtable] $Platform) {
}
}

function Build-ExperimentalRuntime {
[CmdletBinding(PositionalBinding = $false)]
param
(
[Parameter(Position = 0, Mandatory = $true)]
[Hashtable] $Platform,
[switch] $Static = $false
)

function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $false) {
# TODO: remove this once the migration is completed.
Invoke-IsolatingEnvVars {
Invoke-VsDevShell $BuildPlatform
Expand All @@ -2476,10 +2468,54 @@ function Build-ExperimentalRuntime {
Invoke-IsolatingEnvVars {
$env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-PinnedToolchainRuntime);${env:Path}"

$SDKRoot = Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental"

$RuntimeBinaryCache = if ($Static) {
Get-ProjectBinaryCache $Platform ExperimentalStaticRuntime
} else {
throw "dynamic Experimental Runtime is not yet implemented"
}

$OverlayBinaryCache = if ($Static) {
Get-ProjectBinaryCache $Platform ExperimentalStaticOverlay
} else {
throw "dynamic Experimental Runtime is not yet implemented"
}

$StringProcessingBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticStringProcessing
} else {
throw "dynamic Experimental Runtime is not yet implemented"
}

$SynchronizationBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticSynchronization
} else {
throw "dynamic Experimental Runtime is not yet implemented"
}

$DistributedBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticDistributed
} else {
throw "dynamic Experimental Runtime is not yet implemented"
}

$ObservationBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticObservation
} else {
throw "dynamic Experimental Runtime is not yet implemented"
}

$DifferentiationBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticDifferentiation
} else {
throw "dynamic Experimental Differentiation is not yet implemented"
}

Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Core `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalRuntime) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Bin $RuntimeBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-UseGNUDriver `
Expand All @@ -2506,8 +2542,8 @@ function Build-ExperimentalRuntime {

Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Overlay `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalOverlay) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Bin $OverlayBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-UseGNUDriver `
Expand All @@ -2519,13 +2555,13 @@ function Build-ExperimentalRuntime {
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();

SwiftCore_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\cmake\SwiftCore";
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
}

Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Supplemental\StringProcessing `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalStringProcessing) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Bin $StringProcessingBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-UseGNUDriver `
Expand All @@ -2537,13 +2573,13 @@ function Build-ExperimentalRuntime {
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();

SwiftCore_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\cmake\SwiftCore";
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
}

Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Supplemental\Synchronization `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalSynchronization) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Bin $SynchronizationBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-UseGNUDriver `
Expand All @@ -2555,54 +2591,54 @@ function Build-ExperimentalRuntime {
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();

SwiftCore_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\cmake\SwiftCore";
SwiftOverlay_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalOverlay)\cmake\SwiftOverlay";
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
}

Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Supplemental\Distributed `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalDistributed) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Bin $DistributedBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
CMAKE_CXX_FLAGS = @("-I$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\include");
CMAKE_CXX_FLAGS = @("-I${RuntimeBinaryCache}\include");
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
CMAKE_Swift_COMPILER_WORKS = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();

SwiftCore_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\cmake\SwiftCore";
SwiftOverlay_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalOverlay)\cmake\SwiftOverlay";
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
}

Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Supplemental\Observation `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalObservation) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Bin $ObservationBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers CXX,Swift `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
CMAKE_CXX_FLAGS = @("-I$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\include");
CMAKE_CXX_FLAGS = @("-I${RuntimeBinaryCache}\include");
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
CMAKE_Swift_COMPILER_WORKS = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();

SwiftCore_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\cmake\SwiftCore";
SwiftOverlay_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalOverlay)\cmake\SwiftOverlay";
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
}

Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Supplemental\Differentiation `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalDifferentiation) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Bin $DifferentiationBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-UseGNUDriver `
Expand All @@ -2614,8 +2650,8 @@ function Build-ExperimentalRuntime {
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();

SwiftCore_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalRuntime)\cmake\SwiftCore";
SwiftOverlay_DIR = "$(Get-ProjectBinaryCache $Platform ExperimentalOverlay)\cmake\SwiftOverlay";
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
}
}
}
Expand Down Expand Up @@ -2700,7 +2736,7 @@ function Build-Foundation {
)

$FoundationBinaryCache = if ($Static) {
Get-ProjectBinaryCache $Platform StaticFoundation
Get-ProjectBinaryCache $Platform ExperimentalStaticFoundation
} else {
Get-ProjectBinaryCache $Platform DynamicFoundation
}
Expand All @@ -2724,7 +2760,7 @@ function Build-Foundation {
}

$DispatchCMakeModules = if ($Static) {
Get-ProjectCMakeModules $Platform ExperimentalDispatch
Get-ProjectCMakeModules $Platform ExperimentalStaticDispatch
} else {
Get-ProjectCMakeModules $Platform Dispatch
}
Expand Down Expand Up @@ -2945,7 +2981,7 @@ function Build-ExperimentalSDK([Hashtable] $Platform) {
$env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-PinnedToolchainRuntime);${env:Path}"
Build-CMakeProject `
-Src $SourceCache\swift-corelibs-libdispatch `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalDispatch) `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalStaticDispatch) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
Expand Down