@@ -188,17 +188,19 @@ param
188188 [string ] $AndroidNDKVersion = " r27c" ,
189189 [ValidateRange (1 , 36 )]
190190 [int ] $AndroidAPILevel = 28 ,
191+ [string []] $AndroidSDKArchitectures = @ (" aarch64" , " armv7" , " i686" , " x86_64" ),
192+ [string []] $AndroidSDKLinkModes = @ (" dynamic" , " static" ),
191193 [string []] $AndroidSDKVersions = @ (" Android" , " AndroidExperimental" ),
192194 [string ] $AndroidSDKVersionDefault = " Android" ,
193- [string []] $AndroidSDKArchitectures = @ (" aarch64" , " armv7" , " i686" , " x86_64" ),
194195
195196 # Windows SDK Options
196197 [switch ] $Windows = $true ,
197198 [ValidatePattern (" ^\d+\.\d+\.\d+(?:-\w+)?" )]
198199 [string ] $WinSDKVersion = " " ,
200+ [string []] $WindowsSDKArchitectures = @ (" X64" , " X86" , " Arm64" ),
201+ [string []] $WindowsSDKLinkModes = @ (" dynamic" , " static" ),
199202 [string []] $WindowsSDKVersions = @ (" Windows" , " WindowsExperimental" ),
200203 [string ] $WindowsSDKVersionDefault = " Windows" ,
201- [string []] $WindowsSDKArchitectures = @ (" X64" , " X86" , " Arm64" ),
202204
203205 # Incremental Build Support
204206 [switch ] $Clean ,
@@ -294,6 +296,7 @@ $KnownPlatforms = @{
294296 BinaryDir = " bin64a" ;
295297 Cache = @ {};
296298 DefaultSDK = $WindowsSDKVersionDefault ;
299+ LinkModes = $WindowsSDKLinkModes ;
297300 };
298301
299302 WindowsX64 = @ {
@@ -308,6 +311,7 @@ $KnownPlatforms = @{
308311 BinaryDir = " bin64" ;
309312 Cache = @ {};
310313 DefaultSDK = $WindowsSDKVersionDefault ;
314+ LinkModes = $WindowsSDKLinkModes ;
311315 };
312316
313317 WindowsX86 = @ {
@@ -322,6 +326,7 @@ $KnownPlatforms = @{
322326 BinaryDir = " bin32" ;
323327 Cache = @ {};
324328 DefaultSDK = $WindowsSDKVersionDefault ;
329+ LinkModes = $WindowsSDKLinkModes ;
325330 };
326331
327332 AndroidARMv7 = @ {
@@ -336,6 +341,7 @@ $KnownPlatforms = @{
336341 BinaryDir = " bin32a" ;
337342 Cache = @ {};
338343 DefaultSDK = $AndroidSDKVersionDefault ;
344+ LinkModes = $AndroidSDKLinkModes ;
339345 };
340346
341347 AndroidARM64 = @ {
@@ -350,6 +356,7 @@ $KnownPlatforms = @{
350356 BinaryDir = " bin64a" ;
351357 Cache = @ {};
352358 DefaultSDK = $AndroidSDKVersionDefault ;
359+ LinkModes = $AndroidSDKLinkModes ;
353360 };
354361
355362 AndroidX86 = @ {
@@ -364,6 +371,7 @@ $KnownPlatforms = @{
364371 BinaryDir = " bin32" ;
365372 Cache = @ {};
366373 DefaultSDK = $AndroidSDKVersionDefault ;
374+ LinkModes = $AndroidSDKLinkModes ;
367375 };
368376
369377 AndroidX64 = @ {
@@ -378,6 +386,7 @@ $KnownPlatforms = @{
378386 BinaryDir = " bin64" ;
379387 Cache = @ {};
380388 DefaultSDK = $AndroidSDKVersionDefault ;
389+ LinkModes = $AndroidSDKLinkModes ;
381390 };
382391}
383392
@@ -3173,7 +3182,7 @@ function Install-SDK([Hashtable[]] $Platforms, [OS] $OS = $Platforms[0].OS, [str
31733182 foreach ($Platform in $Platforms ) {
31743183 foreach ($ResourceType in (" swift" , " swift_static" )) {
31753184 $PlatformResources = " $ ( Get-SwiftSDK - OS $OS - Identifier $Identifier ) \usr\lib\$ResourceType \$ ( $OS.ToString ().ToLowerInvariant()) "
3176- Get-ChildItem - Recurse " $PlatformResources \$ ( $Platform.Architecture.LLVMName ) " | ForEach-Object {
3185+ Get-ChildItem - ErrorAction SilentlyContinue - Recurse " $PlatformResources \$ ( $Platform.Architecture.LLVMName ) " | ForEach-Object {
31773186 if (" .swiftmodule" , " .swiftdoc" , " .swiftinterface" -contains $_.Extension ) {
31783187 Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not in a thick module layout"
31793188 Copy-File $_.FullName " $PlatformResources \$ ( $_.BaseName ) .swiftmodule\$ ( Get-ModuleTriple $Platform ) $ ( $_.Extension ) "
@@ -3196,14 +3205,16 @@ function Build-SDK([Hashtable] $Platform) {
31963205function Build-ExperimentalSDK ([Hashtable ] $Platform ) {
31973206 Invoke-BuildStep Build-CDispatch $Platform
31983207
3199- Invoke-BuildStep Build-ExperimentalRuntime $Platform
3200- Invoke-BuildStep Build-ExperimentalRuntime $Platform - Static
3208+ if ($Platform.LinkModes.Contains (" dynamic" )) {
3209+ Invoke-BuildStep Build-ExperimentalRuntime $Platform
3210+ }
3211+ if ($Platform.LinkModes.Contains (" static" )) {
3212+ Invoke-BuildStep Build-ExperimentalRuntime $Platform - Static
3213+ }
32013214
32023215 $SDKROOT = Get-SwiftSDK - OS $Platform.OS - Identifier " $ ( $Platform.OS ) Experimental"
32033216
3204- Invoke-IsolatingEnvVars {
3205- $env: Path = " $ ( Get-CMarkBinaryCache $Platform ) \src;$ ( Get-PinnedToolchainRuntime ) ;${env: Path} "
3206-
3217+ if ($Platform.LinkModes.Contains (" dynamic" )) {
32073218 Record- OperationTime $Platform " Build-ExperimentalDynamicDispatch" {
32083219 Build-CMakeProject `
32093220 - Src $SourceCache \swift- corelibs- libdispatch `
@@ -3221,6 +3232,41 @@ function Build-ExperimentalSDK([Hashtable] $Platform) {
32213232 }
32223233 }
32233234
3235+ Record- OperationTime $Platform " Build-ExperimentalDynamicFoundation" {
3236+ Build-CMakeProject `
3237+ - Src $SourceCache \swift- corelibs- foundation `
3238+ - Bin (Get-ProjectBinaryCache $Platform ExperimentalDynamicFoundation) `
3239+ - InstallTo " ${SDKROOT} \usr" `
3240+ - Platform $Platform `
3241+ - UseBuiltCompilers ASM, C, CXX, Swift `
3242+ - SwiftSDK " ${SDKROOT} " `
3243+ - Defines @ {
3244+ BUILD_SHARED_LIBS = " YES" ;
3245+ CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
3246+ CMAKE_NINJA_FORCE_RESPONSE_FILE = " YES" ;
3247+ CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
3248+ ENABLE_TESTING = " NO" ;
3249+
3250+ FOUNDATION_BUILD_TOOLS = " NO" ;
3251+ CURL_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\CURL" ;
3252+ LibXml2_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\libxml2-2.11.5" ;
3253+ ZLIB_INCLUDE_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\include" ;
3254+ ZLIB_LIBRARY = if ($Platform.OS -eq [OS ]::Windows) {
3255+ " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\zlibstatic.lib"
3256+ } else {
3257+ " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\libz.a"
3258+ };
3259+ dispatch_DIR = $ (Get-ProjectCMakeModules $Platform ExperimentalDynamicDispatch);
3260+ SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
3261+ _SwiftFoundation_SourceDIR = " $SourceCache \swift-foundation" ;
3262+ _SwiftFoundationICU_SourceDIR = " $SourceCache \swift-foundation-icu" ;
3263+ _SwiftCollections_SourceDIR = " $SourceCache \swift-collections" ;
3264+ SwiftFoundation_MACRO = " $ ( Get-ProjectBinaryCache $BuildPlatform BootstrapFoundationMacros) \bin"
3265+ }
3266+ }
3267+ }
3268+
3269+ if ($Platform.LinkModes.Contains (" static" )) {
32243270 Record- OperationTime $Platform " Build-ExperimentalStaticDispatch" {
32253271 Build-CMakeProject `
32263272 - Src $SourceCache \swift- corelibs- libdispatch `
@@ -3237,72 +3283,39 @@ function Build-ExperimentalSDK([Hashtable] $Platform) {
32373283 ENABLE_SWIFT = " YES" ;
32383284 }
32393285 }
3240- }
3241-
3242- Record- OperationTime $Platform " Build-ExperimentalDynamicFoundation" {
3243- Build-CMakeProject `
3244- - Src $SourceCache \swift- corelibs- foundation `
3245- - Bin (Get-ProjectBinaryCache $Platform ExperimentalDynamicFoundation) `
3246- - InstallTo " ${SDKROOT} \usr" `
3247- - Platform $Platform `
3248- - UseBuiltCompilers ASM, C, CXX, Swift `
3249- - SwiftSDK " ${SDKROOT} " `
3250- - Defines @ {
3251- BUILD_SHARED_LIBS = " YES" ;
3252- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
3253- CMAKE_NINJA_FORCE_RESPONSE_FILE = " YES" ;
3254- CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
3255- ENABLE_TESTING = " NO" ;
3256-
3257- FOUNDATION_BUILD_TOOLS = " NO" ;
3258- CURL_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\CURL" ;
3259- LibXml2_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\libxml2-2.11.5" ;
3260- ZLIB_INCLUDE_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\include" ;
3261- ZLIB_LIBRARY = if ($Platform.OS -eq [OS ]::Windows) {
3262- " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\zlibstatic.lib"
3263- } else {
3264- " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\libz.a"
3265- };
3266- dispatch_DIR = $ (Get-ProjectCMakeModules $Platform ExperimentalDynamicDispatch);
3267- SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
3268- _SwiftFoundation_SourceDIR = " $SourceCache \swift-foundation" ;
3269- _SwiftFoundationICU_SourceDIR = " $SourceCache \swift-foundation-icu" ;
3270- _SwiftCollections_SourceDIR = " $SourceCache \swift-collections" ;
3271- SwiftFoundation_MACRO = " $ ( Get-ProjectBinaryCache $BuildPlatform BootstrapFoundationMacros) \bin"
3272- }
3273- }
32743286
3275- Record- OperationTime $Platform " Build-ExperimentalStaticFoundation" {
3276- Build-CMakeProject `
3277- - Src $SourceCache \swift- corelibs- foundation `
3278- - Bin (Get-ProjectBinaryCache $Platform ExperimentalStaticFoundation) `
3279- - InstallTo " ${SDKROOT} \usr" `
3280- - Platform $Platform `
3281- - UseBuiltCompilers ASM, C, CXX, Swift `
3282- - SwiftSDK ${SDKROOT} `
3283- - Defines @ {
3284- BUILD_SHARED_LIBS = " NO" ;
3285- CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
3286- CMAKE_NINJA_FORCE_RESPONSE_FILE = " YES" ;
3287- CMAKE_Swift_FLAGS = @ (" -static-stdlib" , " -Xfrontend" , " -use-static-resource-dir" );
3288- CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
3289- ENABLE_TESTING = " NO" ;
3290-
3291- FOUNDATION_BUILD_TOOLS = if ($Platform.OS -eq [OS ]::Windows) { " YES" } else { " NO" };
3292- CURL_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\CURL" ;
3293- LibXml2_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\libxml2-2.11.5" ;
3294- ZLIB_INCLUDE_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\include" ;
3295- ZLIB_LIBRARY = if ($Platform.OS -eq [OS ]::Windows) {
3296- " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\zlibstatic.lib"
3297- } else {
3298- " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\libz.a"
3299- };
3300- dispatch_DIR = $ (Get-ProjectCMakeModules $Platform ExperimentalStaticDispatch);
3301- SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
3302- _SwiftFoundation_SourceDIR = " $SourceCache \swift-foundation" ;
3303- _SwiftFoundationICU_SourceDIR = " $SourceCache \swift-foundation-icu" ;
3304- _SwiftCollections_SourceDIR = " $SourceCache \swift-collections" ;
3305- SwiftFoundation_MACRO = " $ ( Get-ProjectBinaryCache $BuildPlatform BootstrapFoundationMacros) \bin"
3287+ Record- OperationTime $Platform " Build-ExperimentalStaticFoundation" {
3288+ Build-CMakeProject `
3289+ - Src $SourceCache \swift- corelibs- foundation `
3290+ - Bin (Get-ProjectBinaryCache $Platform ExperimentalStaticFoundation) `
3291+ - InstallTo " ${SDKROOT} \usr" `
3292+ - Platform $Platform `
3293+ - UseBuiltCompilers ASM, C, CXX, Swift `
3294+ - SwiftSDK ${SDKROOT} `
3295+ - Defines @ {
3296+ BUILD_SHARED_LIBS = " NO" ;
3297+ CMAKE_FIND_PACKAGE_PREFER_CONFIG = " YES" ;
3298+ CMAKE_NINJA_FORCE_RESPONSE_FILE = " YES" ;
3299+ CMAKE_Swift_FLAGS = @ (" -static-stdlib" , " -Xfrontend" , " -use-static-resource-dir" );
3300+ CMAKE_STATIC_LIBRARY_PREFIX_Swift = " lib" ;
3301+ ENABLE_TESTING = " NO" ;
3302+
3303+ FOUNDATION_BUILD_TOOLS = if ($Platform.OS -eq [OS ]::Windows) { " YES" } else { " NO" };
3304+ CURL_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\CURL" ;
3305+ LibXml2_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\cmake\libxml2-2.11.5" ;
3306+ ZLIB_INCLUDE_DIR = " $BinaryCache \$ ( $Platform.Triple ) \usr\include" ;
3307+ ZLIB_LIBRARY = if ($Platform.OS -eq [OS ]::Windows) {
3308+ " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\zlibstatic.lib"
3309+ } else {
3310+ " $BinaryCache \$ ( $Platform.Triple ) \usr\lib\libz.a"
3311+ };
3312+ dispatch_DIR = $ (Get-ProjectCMakeModules $Platform ExperimentalStaticDispatch);
3313+ SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
3314+ _SwiftFoundation_SourceDIR = " $SourceCache \swift-foundation" ;
3315+ _SwiftFoundationICU_SourceDIR = " $SourceCache \swift-foundation-icu" ;
3316+ _SwiftCollections_SourceDIR = " $SourceCache \swift-collections" ;
3317+ SwiftFoundation_MACRO = " $ ( Get-ProjectBinaryCache $BuildPlatform BootstrapFoundationMacros) \bin"
3318+ }
33063319 }
33073320 }
33083321}
@@ -3818,37 +3831,6 @@ function Install-HostToolchain() {
38183831 Copy-Item - Force `
38193832 - Path $SwiftDriver `
38203833 - Destination " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\bin\swiftc.exe"
3821-
3822- # Copy static dependencies
3823- if ($Windows ) {
3824- foreach ($Build in $WindowsSDKBuilds ) {
3825- $SDKROOT = Get-SwiftSDK - OS $Build.OS - Identifier " $ ( $Build.OS ) Experimental"
3826- Copy-Item - Force `
3827- - Path " ${BinaryCache} \$ ( $Build.Triple ) \curl\lib\libcurl.lib" `
3828- - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libcurl.lib" | Out-Null
3829- Copy-Item - Force `
3830- - Path " ${BinaryCache} \$ ( $Build.Triple ) \libxml2-2.11.5\libxml2s.lib" `
3831- - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libxml2s.lib" | Out-Null
3832- Copy-Item - Force `
3833- - Path " ${BinaryCache} \$ ( $Build.Triple ) \zlib\zlibstatic.lib" `
3834- - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \zlibstatic.lib" | Out-Null
3835- }
3836- }
3837-
3838- if ($Android ) {
3839- foreach ($Build in $AndroidSDKBuilds ) {
3840- $SDKROOT = Get-SwiftSDK - OS $Build.OS - Identifier " $ ( $Build.OS ) Experimental"
3841- Copy-Item - Force `
3842- - Path " ${BinaryCache} \$ ( $Build.Triple ) \curl\lib\libcurl.a" `
3843- - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libcurl.a" | Out-Null
3844- Copy-Item - Force `
3845- - Path " ${BinaryCache} \$ ( $Build.Triple ) \libxml2-2.11.5\libxml2.a" `
3846- - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libxml2.a" | Out-Null
3847- Copy-Item - Force `
3848- - Path " ${BinaryCache} \$ ( $Build.Triple ) \zlib\libz.a" `
3849- - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libz.a" | Out-Null
3850- }
3851- }
38523834}
38533835
38543836function Build-Inspect ([Hashtable ] $Platform ) {
@@ -4131,6 +4113,22 @@ if (-not $SkipBuild) {
41314113 }
41324114
41334115 Write-PlatformInfoPlist Windows
4116+
4117+ # Copy static dependencies
4118+ foreach ($Build in $WindowsSDKBuilds ) {
4119+ if (-not $Build.LinkModes.Contains (" static" )) { continue }
4120+
4121+ $SDKROOT = Get-SwiftSDK - OS $Build.OS - Identifier " $ ( $Build.OS ) Experimental"
4122+ Copy-Item - Force `
4123+ - Path " ${BinaryCache} \$ ( $Build.Triple ) \curl\lib\libcurl.lib" `
4124+ - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libcurl.lib" | Out-Null
4125+ Copy-Item - Force `
4126+ - Path " ${BinaryCache} \$ ( $Build.Triple ) \libxml2-2.11.5\libxml2s.lib" `
4127+ - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libxml2s.lib" | Out-Null
4128+ Copy-Item - Force `
4129+ - Path " ${BinaryCache} \$ ( $Build.Triple ) \zlib\zlibstatic.lib" `
4130+ - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \zlibstatic.lib" | Out-Null
4131+ }
41344132 }
41354133
41364134 if ($Android ) {
@@ -4194,6 +4192,22 @@ if (-not $SkipBuild) {
41944192 $AndroidSDKBuilds | Where-Object { @ (" arm64-v8a" , " x86_64" ) -contains $_.Architecture.ABI } | ForEach-Object {
41954193 Invoke-BuildStep Build-Inspect $_
41964194 }
4195+
4196+ # Copy static dependencies
4197+ foreach ($Build in $AndroidSDKBuilds ) {
4198+ if (-not $Build.LinkModes.Contains (" static" )) { continue }
4199+
4200+ $SDKROOT = Get-SwiftSDK - OS $Build.OS - Identifier " $ ( $Build.OS ) Experimental"
4201+ Copy-Item - Force `
4202+ - Path " ${BinaryCache} \$ ( $Build.Triple ) \curl\lib\libcurl.a" `
4203+ - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libcurl.a" | Out-Null
4204+ Copy-Item - Force `
4205+ - Path " ${BinaryCache} \$ ( $Build.Triple ) \libxml2-2.11.5\libxml2.a" `
4206+ - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libxml2.a" | Out-Null
4207+ Copy-Item - Force `
4208+ - Path " ${BinaryCache} \$ ( $Build.Triple ) \zlib\libz.a" `
4209+ - Destination " ${SDKROOT} \usr\lib\swift_static\$ ( $Build.OS.ToString ().ToLowerInvariant()) \$ ( $Build.Architecture.LLVMName ) \libz.a" | Out-Null
4210+ }
41974211 }
41984212
41994213 # Build Macros for distribution
0 commit comments