@@ -403,7 +403,8 @@ function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
403403
404404enum HostComponent {
405405 Compilers = 5
406- System = 10
406+ FoundationMacros = 10
407+ System
407408 ToolsSupportCore
408409 LLBuild
409410 Yams
@@ -435,6 +436,7 @@ function Get-HostProjectCMakeModules([HostComponent]$Project) {
435436enum BuildComponent {
436437 BuildTools
437438 Compilers
439+ FoundationMacros
438440}
439441
440442function Get-BuildProjectBinaryCache ([BuildComponent ]$Project ) {
@@ -1673,7 +1675,6 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
16731675 }
16741676 } else {
16751677 $DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
1676- $SwiftSyntaxDir = Get-HostProjectCMakeModules Compilers
16771678 $FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch Foundation
16781679 $ShortArch = $Arch.LLVMName
16791680
@@ -1682,12 +1683,6 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
16821683 $Targets = @ (" default" )
16831684 $InstallPath = " $ ( $Arch.SDKInstallRoot ) \usr"
16841685
1685- if ($Platform -eq " Android" ) {
1686- $HostDefines = @ { CMAKE_HOST_Swift_FLAGS = " -sdk `" $ ( $HostArch.SDKInstallRoot ) `" " }
1687- } else {
1688- $HostDefines = @ {}
1689- }
1690-
16911686 Build-CMakeProject `
16921687 - Src $SourceCache \swift- corelibs- foundation `
16931688 - Bin $FoundationBinaryCache `
@@ -1713,15 +1708,63 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
17131708 };
17141709 ZLIB_INCLUDE_DIR = " $LibraryRoot \zlib-1.3.1\usr\include" ;
17151710 dispatch_DIR = " $DispatchBinaryCache \cmake\modules" ;
1716- SwiftSyntax_DIR = " $SwiftSyntaxDir " ;
1711+ SwiftSyntax_DIR = ( Get-HostProjectCMakeModules Compilers) ;
17171712 _SwiftFoundation_SourceDIR = " $SourceCache \swift-foundation" ;
17181713 _SwiftFoundationICU_SourceDIR = " $SourceCache \swift-foundation-icu" ;
1719- _SwiftCollections_SourceDIR = " $SourceCache \swift-collections"
1720- } + $HostDefines + $TestingDefines )
1714+ _SwiftCollections_SourceDIR = " $SourceCache \swift-collections" ;
1715+ SwiftFoundation_MACRO = " $ ( Get-BuildProjectBinaryCache FoundationMacros) \bin"
1716+ } + $TestingDefines )
17211717 }
17221718 }
17231719}
17241720
1721+ function Build-FoundationMacros () {
1722+ [CmdletBinding (PositionalBinding = $false )]
1723+ param
1724+ (
1725+ [Parameter (Position = 0 , Mandatory = $true )]
1726+ [Platform ]$Platform ,
1727+ [Parameter (Position = 1 , Mandatory = $true )]
1728+ [hashtable ]$Arch ,
1729+ [switch ] $Build = $false
1730+ )
1731+
1732+ $FoundationMacrosBinaryCache = if ($Build ) {
1733+ Get-BuildProjectBinaryCache FoundationMacros
1734+ } else {
1735+ Get-HostProjectBinaryCache FoundationMacros
1736+ }
1737+
1738+ $SwiftSDK = $null
1739+ if ($Build ) {
1740+ $SwiftSDK = $HostArch.SDKInstallRoot
1741+ }
1742+
1743+ $Targets = if ($Build ) {
1744+ @ (" default" )
1745+ } else {
1746+ @ (" default" , " install" )
1747+ }
1748+
1749+ $InstallDir = $null
1750+ if (-not $Build ) {
1751+ $InstallDir = " $ ( $Arch.ToolchainInstallRoot ) \usr"
1752+ }
1753+
1754+ Build-CMakeProject `
1755+ - Src $SourceCache \swift- foundation\Sources\FoundationMacros `
1756+ - Bin $FoundationMacrosBinaryCache `
1757+ - InstallTo:$InstallDir `
1758+ - Arch $Arch `
1759+ - Platform $Platform `
1760+ - UseBuiltCompilers Swift `
1761+ - SwiftSDK:$SwiftSDK `
1762+ - BuildTargets $Targets `
1763+ - Defines @ {
1764+ SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
1765+ }
1766+ }
1767+
17251768function Build-XCTest ([Platform ]$Platform , $Arch , [switch ]$Test = $false ) {
17261769 $DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
17271770 $FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch Foundation
@@ -2363,6 +2406,7 @@ if (-not $SkipBuild) {
23632406 # Build platform: SDK, Redist and XCTest
23642407 Invoke-BuildStep Build-Runtime Windows $Arch
23652408 Invoke-BuildStep Build-Dispatch Windows $Arch
2409+ Invoke-BuildStep Build-FoundationMacros - Build Windows $BuildArch
23662410 Invoke-BuildStep Build-Foundation Windows $Arch
23672411 Invoke-BuildStep Build-XCTest Windows $Arch
23682412 Invoke-BuildStep Build-SwiftTesting Windows $Arch
@@ -2385,6 +2429,11 @@ if (-not $SkipBuild) {
23852429 }
23862430}
23872431
2432+ if (-not $SkipBuild ) {
2433+ # Build Macros for distribution
2434+ Invoke-BuildStep Build-FoundationMacros Windows $HostArch
2435+ }
2436+
23882437if (-not $ToBatch ) {
23892438 if ($HostArch -in $WindowsSDKArchs ) {
23902439 $RuntimeInstallRoot = [IO.Path ]::Combine((Get-InstallDir $HostArch ), " Runtimes" , $ProductVersion )
0 commit comments