Skip to content

utils: build Foundation macros for distribution #75785

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 1 commit into from
Aug 12, 2024
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
71 changes: 60 additions & 11 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {

enum HostComponent {
Compilers = 5
System = 10
FoundationMacros = 10
System
ToolsSupportCore
LLBuild
Yams
Expand Down Expand Up @@ -426,6 +427,7 @@ function Get-HostProjectCMakeModules([HostComponent]$Project) {
enum BuildComponent {
BuildTools
Compilers
FoundationMacros
}

function Get-BuildProjectBinaryCache([BuildComponent]$Project) {
Expand Down Expand Up @@ -1664,7 +1666,6 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
}
} else {
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
$SwiftSyntaxDir = Get-HostProjectCMakeModules Compilers
$FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch Foundation
$ShortArch = $Arch.LLVMName

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

if ($Platform -eq "Android") {
$HostDefines = @{ CMAKE_HOST_Swift_FLAGS = "-sdk `"$($HostArch.SDKInstallRoot)`"" }
} else {
$HostDefines = @{}
}

Build-CMakeProject `
-Src $SourceCache\swift-corelibs-foundation `
-Bin $FoundationBinaryCache `
Expand All @@ -1704,15 +1699,63 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
};
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
dispatch_DIR = "$DispatchBinaryCache\cmake\modules";
SwiftSyntax_DIR = "$SwiftSyntaxDir";
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections"
} + $HostDefines + $TestingDefines)
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
SwiftFoundation_MACRO = "$(Get-BuildProjectBinaryCache FoundationMacros)\bin"
} + $TestingDefines)
}
}
}

function Build-FoundationMacros() {
[CmdletBinding(PositionalBinding = $false)]
param
(
[Parameter(Position = 0, Mandatory = $true)]
[Platform]$Platform,
[Parameter(Position = 1, Mandatory = $true)]
[hashtable]$Arch,
[switch] $Build = $false
)

$FoundationMacrosBinaryCache = if ($Build) {
Get-BuildProjectBinaryCache FoundationMacros
} else {
Get-HostProjectBinaryCache FoundationMacros
}

$SwiftSDK = $null
if ($Build) {
$SwiftSDK = $HostArch.SDKInstallRoot
}

$Targets = if ($Build) {
@("default")
} else {
@("default", "install")
}

$InstallDir = $null
if (-not $Build) {
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
}

Build-CMakeProject `
-Src $SourceCache\swift-foundation\Sources\FoundationMacros `
-Bin $FoundationMacrosBinaryCache `
-InstallTo:$InstallDir `
-Arch $Arch `
-Platform $Platform `
-UseBuiltCompilers Swift `
-SwiftSDK:$SwiftSDK `
-BuildTargets $Targets `
-Defines @{
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
}
}

function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
$FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch Foundation
Expand Down Expand Up @@ -2341,6 +2384,7 @@ if (-not $SkipBuild) {
# Build platform: SDK, Redist and XCTest
Invoke-BuildStep Build-Runtime Windows $Arch
Invoke-BuildStep Build-Dispatch Windows $Arch
Invoke-BuildStep Build-FoundationMacros -Build Windows $BuildArch
Invoke-BuildStep Build-Foundation Windows $Arch
Invoke-BuildStep Build-XCTest Windows $Arch
}
Expand All @@ -2359,6 +2403,11 @@ if (-not $SkipBuild) {
}
}

if (-not $SkipBuild) {
# Build Macros for distribution
Invoke-BuildStep Build-FoundationMacros Windows $HostArch
}

if (-not $ToBatch) {
if ($HostArch -in $WindowsSDKArchs) {
$RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $HostArch), "Runtimes", $ProductVersion)
Expand Down