Skip to content

Commit 6c74271

Browse files
authored
Merge pull request #79535 from compnerd/platform-staging
utils: remove per-arch `PlatformInstallRoot`
2 parents ac698a1 + 28256e8 commit 6c74271

File tree

1 file changed

+42
-38
lines changed

1 file changed

+42
-38
lines changed

utils/build.ps1

+42-38
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ $ArchX64 = @{
241241
LLVMTarget = "x86_64-unknown-windows-msvc";
242242
CMakeName = "AMD64";
243243
BinaryDir = "bin64";
244-
PlatformInstallRoot = "$BinaryCache\x64\Windows.platform";
245244
SDKInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\SDKs\Windows.sdk";
246245
ExperimentalSDKInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk";
247246
XCTestInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\Library\XCTest-development";
@@ -257,7 +256,6 @@ $ArchX86 = @{
257256
LLVMTarget = "i686-unknown-windows-msvc";
258257
CMakeName = "i686";
259258
BinaryDir = "bin32";
260-
PlatformInstallRoot = "$BinaryCache\x86\Windows.platform";
261259
SDKInstallRoot = "$BinaryCache\x86\Windows.platform\Developer\SDKs\Windows.sdk";
262260
ExperimentalSDKInstallRoot = "$BinaryCache\x86\Windows.platform\Developer\SDKs\WindowsExperimental.sdk";
263261
XCTestInstallRoot = "$BinaryCache\x86\Windows.platform\Developer\Library\XCTest-development";
@@ -272,7 +270,6 @@ $ArchARM64 = @{
272270
LLVMTarget = "aarch64-unknown-windows-msvc";
273271
CMakeName = "ARM64";
274272
BinaryDir = "bin64a";
275-
PlatformInstallRoot = "$BinaryCache\arm64\Windows.platform";
276273
SDKInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\SDKs\Windows.sdk";
277274
ExperimentalSDKInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk";
278275
XCTestInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\Library\XCTest-development";
@@ -288,7 +285,6 @@ $AndroidARM64 = @{
288285
LLVMName = "aarch64";
289286
LLVMTarget = "aarch64-unknown-linux-android$AndroidAPILevel";
290287
ShortName = "arm64";
291-
PlatformInstallRoot = "$BinaryCache\arm64\Android.platform";
292288
SDKInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\SDKs\Android.sdk";
293289
ExperimentalSDKInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\SDKs\AndroidExperimental.sdk";
294290
XCTestInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\Library\XCTest-development";
@@ -303,7 +299,6 @@ $AndroidARMv7 = @{
303299
LLVMName = "armv7";
304300
LLVMTarget = "armv7-unknown-linux-androideabi$AndroidAPILevel";
305301
ShortName = "armv7";
306-
PlatformInstallRoot = "$BinaryCache\armv7\Android.platform";
307302
SDKInstallRoot = "$BinaryCache\armv7\Android.platform\Developer\SDKs\Android.sdk";
308303
ExperimentalSDKInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\SDKs\AndroidExperimental.sdk";
309304
XCTestInstallRoot = "$BinaryCache\armv7\Android.platform\Developer\Library\XCTest-development";
@@ -318,7 +313,6 @@ $AndroidX86 = @{
318313
LLVMName = "i686";
319314
LLVMTarget = "i686-unknown-linux-android$AndroidAPILevel";
320315
ShortName = "x86";
321-
PlatformInstallRoot = "$BinaryCache\x86\Android.platform";
322316
SDKInstallRoot = "$BinaryCache\x86\Android.platform\Developer\SDKs\Android.sdk";
323317
ExperimentalSDKInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\SDKs\AndroidExperimental.sdk";
324318
XCTestInstallRoot = "$BinaryCache\x86\Android.platform\Developer\Library\XCTest-development";
@@ -333,7 +327,6 @@ $AndroidX64 = @{
333327
LLVMName = "x86_64";
334328
LLVMTarget = "x86_64-unknown-linux-android$AndroidAPILevel";
335329
ShortName = "x64";
336-
PlatformInstallRoot = "$BinaryCache\x64\Android.platform";
337330
SDKInstallRoot = "$BinaryCache\x64\Android.platform\Developer\SDKs\Android.sdk";
338331
ExperimentalSDKInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\SDKs\AndroidExperimental.sdk";
339332
XCTestInstallRoot = "$BinaryCache\x64\Android.platform\Developer\Library\XCTest-development";
@@ -390,10 +383,6 @@ function Get-InstallDir($Arch) {
390383
return "$ImageRoot\$ProgramFilesName\Swift"
391384
}
392385

393-
function Get-HostSwiftSDK() {
394-
return ([IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "Windows.platform", "Developer", "SDKs", "Windows.sdk"))
395-
}
396-
397386
$NugetRoot = "$BinaryCache\nuget"
398387
$PinnedToolchain = [IO.Path]::GetFileNameWithoutExtension($PinnedBuild)
399388

@@ -1003,6 +992,21 @@ enum Platform {
1003992
Android
1004993
}
1005994

995+
function Get-PlatformRoot([Platform] $Platform) {
996+
return ([IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "${Platform}.platform"))
997+
}
998+
999+
function Get-SwiftSDK {
1000+
[CmdletBinding(PositionalBinding = $false)]
1001+
param
1002+
(
1003+
[Parameter(Position = 0, Mandatory = $true)]
1004+
[Platform] $Platform,
1005+
[switch] $Experimental = $false
1006+
)
1007+
return ([IO.Path]::Combine((Get-PlatformRoot $Platform), "Developer", "SDKs", "${Platform}.sdk"))
1008+
}
1009+
10061010
function Build-CMakeProject {
10071011
[CmdletBinding(PositionalBinding = $false)]
10081012
param(
@@ -1403,7 +1407,7 @@ function Build-SPMProject {
14031407
$Stopwatch = [Diagnostics.Stopwatch]::StartNew()
14041408

14051409
Isolate-EnvVars {
1406-
$SDKInstallRoot = [IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "Windows.platform", "Developer", "SDKs", "Windows.sdk")
1410+
$SDKInstallRoot = (Get-SwiftSDK Windows)
14071411
$RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $HostArch), "Runtimes", $ProductVersion)
14081412

14091413
$env:Path = "$RuntimeInstallRoot\usr\bin;$($HostArch.ToolchainInstallRoot)\usr\bin;${env:Path}"
@@ -1912,7 +1916,7 @@ function Build-DS2([Platform]$Platform, $Arch) {
19121916
Build-CMakeProject `
19131917
-Src "$SourceCache\ds2" `
19141918
-Bin "$BinaryCache\$($Arch.LLVMTarget)\ds2" `
1915-
-InstallTo "$($Arch.PlatformInstallRoot)\Developer\Library\$(Get-ModuleTriple $Arch)" `
1919+
-InstallTo "$(Get-PlatformRoot $Platform)\Developer\Library\$(Get-ModuleTriple $Arch)" `
19161920
-Arch $Arch `
19171921
-Platform $Platform `
19181922
-BuildTargets default `
@@ -2382,10 +2386,9 @@ function Build-Testing([Platform]$Platform, $Arch, [switch]$Test = $false) {
23822386
}
23832387
}
23842388

2385-
function Write-PlatformInfoPlist($Arch) {
2386-
$PList = Join-Path -Path $Arch.PlatformInstallRoot -ChildPath "Info.plist"
2389+
function Write-PlatformInfoPlist([Platform] $Platform) {
23872390
Invoke-Program "$(Get-PythonExecutable)" -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'XCTEST_VERSION': 'development', 'SWIFT_TESTING_VERSION': 'development', 'SWIFTC_FLAGS': ['-use-ld=lld'] } }), encoding='utf-8'))" `
2388-
-OutFile "$PList"
2391+
-OutFile ([IO.Path]::Combine((Get-PlatformRoot $Platform), "Info.plist"))
23892392
}
23902393

23912394
# Copies files installed by CMake from the arch-specific platform root,
@@ -2394,7 +2397,7 @@ function Write-PlatformInfoPlist($Arch) {
23942397
function Install-Platform([Platform]$Platform, $Arch) {
23952398
if ($ToBatch) { return }
23962399

2397-
$SDKInstallRoot = [IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "$Platform.platform", "Developer", "SDKs", "$Platform.sdk")
2400+
$SDKInstallRoot = (Get-SwiftSDK $Platform)
23982401

23992402
New-Item -ItemType Directory -ErrorAction Ignore $SDKInstallRoot\usr | Out-Null
24002403

@@ -2446,9 +2449,8 @@ function Install-Platform([Platform]$Platform, $Arch) {
24462449
}
24472450

24482451
# Copy plist files (same across architectures)
2449-
Copy-File "$($Arch.PlatformInstallRoot)\Info.plist" ([IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "${Platform}.platform"))
2450-
Copy-File "$($Arch.SDKInstallRoot)\SDKSettings.json" ([IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "${Platform}.platform", "Developer", "SDKs", "${Platform}.sdk"))
2451-
Copy-File "$($Arch.SDKInstallRoot)\SDKSettings.plist" ([IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "${Platform}.platform", "Developer", "SDKs", "${Platform}.sdk"))
2452+
Copy-File "$($Arch.SDKInstallRoot)\SDKSettings.json" "$(Get-SwiftSDK $Platform)\"
2453+
Copy-File "$($Arch.SDKInstallRoot)\SDKSettings.plist" "$(Get-SwiftSDK $Platform)\"
24522454

24532455
# Copy XCTest
24542456
$XCTestInstallRoot = [IO.Path]::Combine((Get-InstallDir $HostArch), "Platforms", "${Platform}.platform", "Developer", "Library", "XCTest-development")
@@ -2497,7 +2499,7 @@ function Build-System($Arch) {
24972499
-Arch $Arch `
24982500
-Platform Windows `
24992501
-UseBuiltCompilers C,Swift `
2500-
-SwiftSDK (Get-HostSwiftSDK) `
2502+
-SwiftSDK (Get-SwiftSDK Windows) `
25012503
-BuildTargets default `
25022504
-Defines @{
25032505
BUILD_SHARED_LIBS = "NO";
@@ -2513,7 +2515,7 @@ function Build-ToolsSupportCore($Arch) {
25132515
-Arch $Arch `
25142516
-Platform Windows `
25152517
-UseBuiltCompilers C,Swift `
2516-
-SwiftSDK (Get-HostSwiftSDK) `
2518+
-SwiftSDK (Get-SwiftSDK Windows) `
25172519
-Defines @{
25182520
BUILD_SHARED_LIBS = "YES";
25192521
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -2552,7 +2554,7 @@ function Build-LLBuild($Arch, [switch]$Test = $false) {
25522554
-Platform Windows `
25532555
-UseMSVCCompilers CXX `
25542556
-UseBuiltCompilers Swift `
2555-
-SwiftSDK (Get-HostSwiftSDK) `
2557+
-SwiftSDK (Get-SwiftSDK Windows) `
25562558
-BuildTargets $Targets `
25572559
-Defines ($TestingDefines + @{
25582560
BUILD_SHARED_LIBS = "YES";
@@ -2571,7 +2573,7 @@ function Build-ArgumentParser($Arch) {
25712573
-Arch $Arch `
25722574
-Platform Windows `
25732575
-UseBuiltCompilers Swift `
2574-
-SwiftSDK (Get-HostSwiftSDK) `
2576+
-SwiftSDK (Get-SwiftSDK Windows) `
25752577
-Defines @{
25762578
BUILD_SHARED_LIBS = "YES";
25772579
BUILD_TESTING = "NO";
@@ -2587,7 +2589,7 @@ function Build-Driver($Arch) {
25872589
-Arch $Arch `
25882590
-Platform Windows `
25892591
-UseBuiltCompilers C,CXX,Swift `
2590-
-SwiftSDK (Get-HostSwiftSDK) `
2592+
-SwiftSDK (Get-SwiftSDK Windows) `
25912593
-Defines @{
25922594
BUILD_SHARED_LIBS = "YES";
25932595
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -2610,7 +2612,7 @@ function Build-Crypto($Arch) {
26102612
-Arch $Arch `
26112613
-Platform Windows `
26122614
-UseBuiltCompilers Swift `
2613-
-SwiftSDK (Get-HostSwiftSDK) `
2615+
-SwiftSDK (Get-SwiftSDK Windows) `
26142616
-BuildTargets default `
26152617
-Defines @{
26162618
BUILD_SHARED_LIBS = "NO";
@@ -2626,7 +2628,7 @@ function Build-Collections($Arch) {
26262628
-Arch $Arch `
26272629
-Platform Windows `
26282630
-UseBuiltCompilers C,Swift `
2629-
-SwiftSDK (Get-HostSwiftSDK) `
2631+
-SwiftSDK (Get-SwiftSDK Windows) `
26302632
-Defines @{
26312633
BUILD_SHARED_LIBS = "YES";
26322634
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -2639,7 +2641,7 @@ function Build-ASN1($Arch) {
26392641
-Bin (Get-HostProjectBinaryCache ASN1) `
26402642
-Arch $Arch `
26412643
-UseBuiltCompilers Swift `
2642-
-SwiftSDK (Get-HostSwiftSDK) `
2644+
-SwiftSDK (Get-SwiftSDK Windows) `
26432645
-BuildTargets default `
26442646
-Defines @{
26452647
BUILD_SHARED_LIBS = "NO";
@@ -2654,7 +2656,7 @@ function Build-Certificates($Arch) {
26542656
-Arch $Arch `
26552657
-Platform Windows `
26562658
-UseBuiltCompilers Swift `
2657-
-SwiftSDK (Get-HostSwiftSDK) `
2659+
-SwiftSDK (Get-SwiftSDK Windows) `
26582660
-BuildTargets default `
26592661
-Defines @{
26602662
BUILD_SHARED_LIBS = "NO";
@@ -2678,7 +2680,7 @@ function Build-PackageManager($Arch) {
26782680
-Arch $Arch `
26792681
-Platform Windows `
26802682
-UseBuiltCompilers C,Swift `
2681-
-SwiftSDK (Get-HostSwiftSDK) `
2683+
-SwiftSDK (Get-SwiftSDK Windows) `
26822684
-Defines @{
26832685
BUILD_SHARED_LIBS = "YES";
26842686
CMAKE_Swift_FLAGS = @("-DCRYPTO_v2");
@@ -2706,7 +2708,7 @@ function Build-Markdown($Arch) {
27062708
-Arch $Arch `
27072709
-Platform Windows `
27082710
-UseBuiltCompilers C,Swift `
2709-
-SwiftSDK (Get-HostSwiftSDK) `
2711+
-SwiftSDK (Get-SwiftSDK Windows) `
27102712
-Defines @{
27112713
BUILD_SHARED_LIBS = "NO";
27122714
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -2724,7 +2726,7 @@ function Build-Format($Arch) {
27242726
-Platform Windows `
27252727
-UseMSVCCompilers C `
27262728
-UseBuiltCompilers Swift `
2727-
-SwiftSDK (Get-HostSwiftSDK) `
2729+
-SwiftSDK (Get-SwiftSDK Windows) `
27282730
-Defines @{
27292731
BUILD_SHARED_LIBS = "YES";
27302732
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
@@ -2782,7 +2784,7 @@ function Build-LMDB($Arch) {
27822784
}
27832785

27842786
function Build-IndexStoreDB($Arch) {
2785-
$SDKInstallRoot = (Get-HostSwiftSDK);
2787+
$SDKInstallRoot = (Get-SwiftSDK Windows);
27862788

27872789
Build-CMakeProject `
27882790
-Src $SourceCache\indexstore-db `
@@ -2809,7 +2811,7 @@ function Build-SourceKitLSP($Arch) {
28092811
-Arch $Arch `
28102812
-Platform Windows `
28112813
-UseBuiltCompilers C,Swift `
2812-
-SwiftSDK (Get-HostSwiftSDK) `
2814+
-SwiftSDK (Get-SwiftSDK Windows) `
28132815
-Defines @{
28142816
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
28152817
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
@@ -2995,7 +2997,7 @@ function Build-Inspect([Platform]$Platform, $Arch) {
29952997
# since it is currently only built for the host and and cannot be built for Android until
29962998
# the pinned version is >= 1.5.0.
29972999
$ArgumentParserDir = ""
2998-
$InstallPath = "$($Arch.PlatformInstallRoot)\Developer\Library\$(Get-ModuleTriple $Arch)"
3000+
$InstallPath = "$(Get-PlatformRoot $Platform)\Developer\Library\$(Get-ModuleTriple $Arch)"
29993001
}
30003002

30013003
Build-CMakeProject `
@@ -3072,7 +3074,7 @@ function Build-Installer($Arch) {
30723074

30733075
foreach ($SDK in $WindowsSDKArchs) {
30743076
$Properties["INCLUDE_WINDOWS_$($SDK.VSName.ToUpperInvariant())_SDK"] = "true"
3075-
$Properties["PLATFORM_ROOT_$($SDK.VSName.ToUpperInvariant())"] = "$($SDK.PlatformInstallRoot)\"
3077+
$Properties["PLATFORM_ROOT_$($SDK.VSName.ToUpperInvariant())"] = "$(Get-PlatformRoot Windows)\";
30763078
$Properties["SDK_ROOT_$($SDK.VSName.ToUpperInvariant())"] = "$($SDK.SDKInstallRoot)\"
30773079
}
30783080

@@ -3160,7 +3162,6 @@ if (-not $SkipBuild) {
31603162
Invoke-BuildStep Build-XCTest Windows $Arch
31613163
Invoke-BuildStep Build-Testing Windows $Arch
31623164
Invoke-BuildStep Write-SDKSettingsPlist Windows $Arch
3163-
Invoke-BuildStep Write-PlatformInfoPlist $Arch
31643165

31653166
Invoke-BuildStep Build-ExperimentalRuntime -Static Windows $Arch
31663167
Invoke-BuildStep Build-Foundation -Static Windows $Arch
@@ -3189,7 +3190,6 @@ if (-not $SkipBuild) {
31893190
Invoke-BuildStep Build-Inspect -Platform Android -Arch $Arch
31903191
}
31913192
Invoke-BuildStep Write-SDKSettingsPlist Android $Arch
3192-
Invoke-BuildStep Write-PlatformInfoPlist $Arch
31933193

31943194
Invoke-BuildStep Build-ExperimentalRuntime -Static Android $Arch
31953195
Invoke-BuildStep Build-Foundation -Static Android $Arch
@@ -3212,10 +3212,14 @@ if (-not $ToBatch) {
32123212
foreach ($Arch in $WindowsSDKArchs) {
32133213
Install-Platform Windows $Arch
32143214
}
3215+
Invoke-BuildStep Write-PlatformInfoPlist Windows
32153216

32163217
foreach ($Arch in $AndroidSDKArchs) {
32173218
Install-Platform Android $Arch
32183219
}
3220+
if ($Android) {
3221+
Invoke-BuildStep Write-PlatformInfoPlist Android
3222+
}
32193223
}
32203224

32213225
if (-not $SkipBuild) {

0 commit comments

Comments
 (0)