Skip to content

Commit b36cee2

Browse files
authored
Merge pull request #80611 from compnerd/installer
utils: update the installer build invocation
2 parents dfd5957 + b264ff8 commit b36cee2

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

Diff for: utils/build.ps1

+28-31
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,18 @@ function Get-PythonScriptsPath {
542542

543543
function Get-InstallDir([Hashtable] $Platform) {
544544
if ($Platform -eq $HostPlatform) {
545-
$ProgramFilesName = "Program Files"
546-
} elseif ($Platform -eq $KnownPlatforms["WindowsX86"]) {
547-
$ProgramFilesName = "Program Files (x86)"
548-
} elseif (($HostPlatform -eq $KnownPlatforms["WindowsARM64"]) -and ($Platform -eq $KnownPlatforms["WindowsX64"])) {
549-
# x64 programs actually install under "Program Files" on arm64,
550-
# but this would conflict with the native installation.
551-
$ProgramFilesName = "Program Files (Amd64)"
552-
} else {
553-
# arm64 cannot be installed on x64
554-
return $null
545+
return [IO.Path]::Combine("$ImageRoot\", "Program Files", "Swift")
546+
}
547+
if ($Platform -eq $KnownPlatforms["WindowsARM64"]) {
548+
return [IO.Path]::Combine("$ImageRoot\", "Program Files (Arm64)", "Swift")
549+
}
550+
if ($Platform -eq $KnownPlatforms["WindowsX64"]) {
551+
return [IO.Path]::Combine("$ImageRoot\", "Program Files (Amd64)", "Swift")
552+
}
553+
if ($Platform -eq $KnownPlatforms["WindowsX86"]) {
554+
return [IO.Path]::Combine("$ImageRoot\", "Program Files (x86)", "Swift")
555555
}
556-
return "$ImageRoot\$ProgramFilesName\Swift"
556+
throw "Unknown Platform"
557557
}
558558

559559
# For dev productivity, install the host toolchain directly using CMake.
@@ -1607,10 +1607,7 @@ function Build-WiXProject() {
16071607
Add-KeyValueIfNew $Properties ProductArchitecture $Platform.Architecture.VSName
16081608
Add-KeyValueIfNew $Properties ProductVersion $ProductVersionArg
16091609

1610-
$MSBuildArgs = @("$SourceCache\swift-installer-scripts\platforms\Windows\$FileName")
1611-
$MSBuildArgs += "-noLogo"
1612-
$MSBuildArgs += "-restore"
1613-
$MSBuildArgs += "-maxCpuCount"
1610+
$MSBuildArgs = @( "-noLogo", "-maxCpuCount", "-restore", "$SourceCache\swift-installer-scripts\platforms\Windows\$FileName" )
16141611
foreach ($Property in $Properties.GetEnumerator()) {
16151612
if ($Property.Value.Contains(" ")) {
16161613
$MSBuildArgs += "-p:$($Property.Key)=$($Property.Value.Replace('\', '\\'))"
@@ -2190,8 +2187,12 @@ function Build-Runtime([Hashtable] $Platform) {
21902187
$PlatformDefines += @{
21912188
LLVM_ENABLE_LIBCXX = "YES";
21922189
SWIFT_USE_LINKER = "lld";
2193-
# Clang[<18] doesn't provide the _Builtin_float module.
2194-
SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT = "YES";
2190+
}
2191+
2192+
if ((Get-AndroidNDK).ClangVersion -lt 18) {
2193+
$PlatformDefines += @{
2194+
SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT = "YES";
2195+
}
21952196
}
21962197
}
21972198

@@ -3133,14 +3134,14 @@ function Test-PackageManager() {
31333134
function Build-Installer([Hashtable] $Platform) {
31343135
# TODO(hjyamauchi) Re-enable the swift-inspect and swift-docc builds
31353136
# when cross-compiling https://github.com/apple/swift/issues/71655
3136-
$INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling) { "false" } else { "true" }
3137+
$INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling) { "False" } else { "True" }
31373138

31383139
$Properties = @{
31393140
BundleFlavor = "offline";
3140-
TOOLCHAIN_ROOT = "$($Platform.ToolchainInstallRoot)\";
3141+
ImageRoot = "$(Get-InstallDir $Platform)\";
31413142
# When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
31423143
# https://github.com/microsoft/mimalloc/issues/997
3143-
WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling) { "true" } else { "false" };
3144+
WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling) { "True" } else { "False" };
31443145
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC;
31453146
SWIFT_DOCC_BUILD = "$(Get-ProjectBinaryCache $HostPlatform DocC)\release";
31463147
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = "${SourceCache}\swift-docc-render-artifact";
@@ -3155,10 +3156,11 @@ function Build-Installer([Hashtable] $Platform) {
31553156
}
31563157
}
31573158

3159+
$Properties["Platforms"] = "`"windows$(if ($Android) { ";android" })`"";
3160+
$Properties["AndroidArchitectures"] = "`"$(($AndroidSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join ";")`""
3161+
$Properties["WindowsArchitectures"] = "`"$(($WindowsSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join ";")`""
31583162
foreach ($SDKPlatform in $WindowsSDKPlatforms) {
3159-
$Properties["INCLUDE_WINDOWS_$($SDKPlatform.Architecture.VSName.ToUpperInvariant())_SDK"] = "true"
3160-
$Properties["PLATFORM_ROOT_$($SDKPlatform.Architecture.VSName.ToUpperInvariant())"] = "$(Get-PlatformRoot Windows)\";
3161-
$Properties["SDK_ROOT_$($SDKPlatform.Architecture.VSName.ToUpperInvariant())"] = "$(Get-SwiftSDK Windows)\"
3163+
$Properties["WindowsRuntime$($SDKPlatform.Architecture.ShortName.ToUpperInvariant())"] = [IO.Path]::Combine((Get-InstallDir $SDKPlatform), "Runtimes", "$ProductVersion");
31623164
}
31633165

31643166
Build-WiXProject bundle\installer.wixproj -Platform $Platform -Bundle -Properties $Properties
@@ -3167,11 +3169,7 @@ function Build-Installer([Hashtable] $Platform) {
31673169
function Copy-BuildArtifactsToStage([Hashtable] $Platform) {
31683170
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.cab" $Stage
31693171
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.msi" $Stage
3170-
foreach ($SDKPlatform in $WindowsSDKPlatforms) {
3171-
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($SDKPlatform.Architecture.VSName)\sdk.windows.$($SDKPlatform.Architecture.VSName).cab" $Stage
3172-
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($SDKPlatform.Architecture.VSName)\sdk.windows.$($SDKPlatform.Architecture.VSName).msi" $Stage
3173-
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($SDKPlatform.Architecture.VSName)\rtl.$($SDKPlatform.Architecture.VSName).msm" $Stage
3174-
}
3172+
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.msm" $Stage
31753173
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\installer.exe" $Stage
31763174
# Extract installer engine to ease code-signing on swift.org CI
31773175
if ($ToBatch) {
@@ -3237,10 +3235,9 @@ if (-not $SkipBuild) {
32373235
Move-Item $_.FullName "$(Get-SwiftSDK Windows)\usr\lib\swift\windows\$($Platform.Architecture.LLVMName)\" | Out-Null
32383236
}
32393237

3240-
if ($Platform -eq $HostPlatform) {
3241-
Copy-Directory "$(Get-SwiftSDK Windows)\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Platform), "Runtimes", $ProductVersion))\usr"
3242-
}
3238+
Copy-Directory "$(Get-SwiftSDK Windows)\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Platform), "Runtimes", $ProductVersion, "usr"))"
32433239
}
3240+
32443241
Install-Platform $WindowsSDKPlatforms Windows
32453242
Write-PlatformInfoPlist Windows
32463243
Write-SDKSettingsPlist Windows

0 commit comments

Comments
 (0)