Skip to content

Commit e97499b

Browse files
committed
utils: build Foundation macros for distribution
This adds a build of the Foundation macros for distribution in the toolchain.
1 parent f4d6eda commit e97499b

File tree

1 file changed

+60
-11
lines changed

1 file changed

+60
-11
lines changed

utils/build.ps1

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
395395

396396
enum HostComponent {
397397
Compilers = 5
398-
System = 10
398+
FoundationMacros = 10
399+
System
399400
ToolsSupportCore
400401
LLBuild
401402
Yams
@@ -426,6 +427,7 @@ function Get-HostProjectCMakeModules([HostComponent]$Project) {
426427
enum BuildComponent {
427428
BuildTools
428429
Compilers
430+
FoundationMacros
429431
}
430432

431433
function Get-BuildProjectBinaryCache([BuildComponent]$Project) {
@@ -1664,7 +1666,6 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
16641666
}
16651667
} else {
16661668
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
1667-
$SwiftSyntaxDir = Get-HostProjectCMakeModules Compilers
16681669
$FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch Foundation
16691670
$ShortArch = $Arch.LLVMName
16701671

@@ -1673,12 +1674,6 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
16731674
$Targets = @("default")
16741675
$InstallPath = "$($Arch.SDKInstallRoot)\usr"
16751676

1676-
if ($Platform -eq "Android") {
1677-
$HostDefines = @{ CMAKE_HOST_Swift_FLAGS = "-sdk `"$($HostArch.SDKInstallRoot)`"" }
1678-
} else {
1679-
$HostDefines = @{}
1680-
}
1681-
16821677
Build-CMakeProject `
16831678
-Src $SourceCache\swift-corelibs-foundation `
16841679
-Bin $FoundationBinaryCache `
@@ -1704,15 +1699,63 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
17041699
};
17051700
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
17061701
dispatch_DIR = "$DispatchBinaryCache\cmake\modules";
1707-
SwiftSyntax_DIR = "$SwiftSyntaxDir";
1702+
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
17081703
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
17091704
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
1710-
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections"
1711-
} + $HostDefines + $TestingDefines)
1705+
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
1706+
SwiftFoundation_MACRO = "$(Get-BuildProjectBinaryCache FoundationMacros)\bin"
1707+
} + $TestingDefines)
17121708
}
17131709
}
17141710
}
17151711

1712+
function Build-FoundationMacros() {
1713+
[CmdletBinding(PositionalBinding = $false)]
1714+
param
1715+
(
1716+
[Parameter(Position = 0, Mandatory = $true)]
1717+
[Platform]$Platform,
1718+
[Parameter(Position = 1, Mandatory = $true)]
1719+
[hashtable]$Arch,
1720+
[switch] $Build = $false
1721+
)
1722+
1723+
$FoundationMacrosBinaryCache = if ($Build) {
1724+
Get-BuildProjectBinaryCache FoundationMacros
1725+
} else {
1726+
Get-HostProjectBinaryCache FoundationMacros
1727+
}
1728+
1729+
$SwiftSDK = $null
1730+
if ($Build) {
1731+
$SwiftSDK = $HostArch.SDKInstallRoot
1732+
}
1733+
1734+
$Targets = if ($Build) {
1735+
@("default")
1736+
} else {
1737+
@("default", "install")
1738+
}
1739+
1740+
$InstallDir = $null
1741+
if (-not $Build) {
1742+
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
1743+
}
1744+
1745+
Build-CMakeProject `
1746+
-Src $SourceCache\swift-foundation\Sources\FoundationMacros `
1747+
-Bin $FoundationMacrosBinaryCache `
1748+
-InstallTo:$InstallDir `
1749+
-Arch $Arch `
1750+
-Platform $Platform `
1751+
-UseBuiltCompilers Swift `
1752+
-SwiftSDK:$SwiftSDK `
1753+
-BuildTargets $Targets `
1754+
-Defines @{
1755+
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
1756+
}
1757+
}
1758+
17161759
function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
17171760
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
17181761
$FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch Foundation
@@ -2341,6 +2384,7 @@ if (-not $SkipBuild) {
23412384
# Build platform: SDK, Redist and XCTest
23422385
Invoke-BuildStep Build-Runtime Windows $Arch
23432386
Invoke-BuildStep Build-Dispatch Windows $Arch
2387+
Invoke-BuildStep Build-FoundationMacros -Build Windows $BuildArch
23442388
Invoke-BuildStep Build-Foundation Windows $Arch
23452389
Invoke-BuildStep Build-XCTest Windows $Arch
23462390
}
@@ -2359,6 +2403,11 @@ if (-not $SkipBuild) {
23592403
}
23602404
}
23612405

2406+
if (-not $SkipBuild) {
2407+
# Build Macros for distribution
2408+
Invoke-BuildStep Build-FoundationMacros Windows $HostArch
2409+
}
2410+
23622411
if (-not $ToBatch) {
23632412
if ($HostArch -in $WindowsSDKArchs) {
23642413
$RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $HostArch), "Runtimes", $ProductVersion)

0 commit comments

Comments
 (0)