Skip to content

Commit b264ff8

Browse files
committed
utils: update the installer build invocation
Adjust the install path computation to support installation of ARM64 on AMD64. This enables the isolation of the runtimes on all architectures for Windows to allow building the isolated runtime distribution.
1 parent 8834f6c commit b264ff8

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

utils/build.ps1

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,18 @@ function Get-PythonScriptsPath {
537537

538538
function Get-InstallDir([Hashtable] $Platform) {
539539
if ($Platform -eq $HostPlatform) {
540-
$ProgramFilesName = "Program Files"
541-
} elseif ($Platform -eq $KnownPlatforms["WindowsX86"]) {
542-
$ProgramFilesName = "Program Files (x86)"
543-
} elseif (($HostPlatform -eq $KnownPlatforms["WindowsARM64"]) -and ($Platform -eq $KnownPlatforms["WindowsX64"])) {
544-
# x64 programs actually install under "Program Files" on arm64,
545-
# but this would conflict with the native installation.
546-
$ProgramFilesName = "Program Files (Amd64)"
547-
} else {
548-
# arm64 cannot be installed on x64
549-
return $null
540+
return [IO.Path]::Combine("$ImageRoot\", "Program Files", "Swift")
541+
}
542+
if ($Platform -eq $KnownPlatforms["WindowsARM64"]) {
543+
return [IO.Path]::Combine("$ImageRoot\", "Program Files (Arm64)", "Swift")
544+
}
545+
if ($Platform -eq $KnownPlatforms["WindowsX64"]) {
546+
return [IO.Path]::Combine("$ImageRoot\", "Program Files (Amd64)", "Swift")
547+
}
548+
if ($Platform -eq $KnownPlatforms["WindowsX86"]) {
549+
return [IO.Path]::Combine("$ImageRoot\", "Program Files (x86)", "Swift")
550550
}
551-
return "$ImageRoot\$ProgramFilesName\Swift"
551+
throw "Unknown Platform"
552552
}
553553

554554
# For dev productivity, install the host toolchain directly using CMake.
@@ -1601,10 +1601,7 @@ function Build-WiXProject() {
16011601
Add-KeyValueIfNew $Properties ProductArchitecture $Platform.Architecture.VSName
16021602
Add-KeyValueIfNew $Properties ProductVersion $ProductVersionArg
16031603

1604-
$MSBuildArgs = @("$SourceCache\swift-installer-scripts\platforms\Windows\$FileName")
1605-
$MSBuildArgs += "-noLogo"
1606-
$MSBuildArgs += "-restore"
1607-
$MSBuildArgs += "-maxCpuCount"
1604+
$MSBuildArgs = @( "-noLogo", "-maxCpuCount", "-restore", "$SourceCache\swift-installer-scripts\platforms\Windows\$FileName" )
16081605
foreach ($Property in $Properties.GetEnumerator()) {
16091606
if ($Property.Value.Contains(" ")) {
16101607
$MSBuildArgs += "-p:$($Property.Key)=$($Property.Value.Replace('\', '\\'))"
@@ -2184,8 +2181,12 @@ function Build-Runtime([Hashtable] $Platform) {
21842181
$PlatformDefines += @{
21852182
LLVM_ENABLE_LIBCXX = "YES";
21862183
SWIFT_USE_LINKER = "lld";
2187-
# Clang[<18] doesn't provide the _Builtin_float module.
2188-
SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT = "YES";
2184+
}
2185+
2186+
if ((Get-AndroidNDK).ClangVersion -lt 18) {
2187+
$PlatformDefines += @{
2188+
SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT = "YES";
2189+
}
21892190
}
21902191
}
21912192

@@ -3127,14 +3128,14 @@ function Test-PackageManager() {
31273128
function Build-Installer([Hashtable] $Platform) {
31283129
# TODO(hjyamauchi) Re-enable the swift-inspect and swift-docc builds
31293130
# when cross-compiling https://github.com/apple/swift/issues/71655
3130-
$INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling) { "false" } else { "true" }
3131+
$INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling) { "False" } else { "True" }
31313132

31323133
$Properties = @{
31333134
BundleFlavor = "offline";
3134-
TOOLCHAIN_ROOT = "$($Platform.ToolchainInstallRoot)\";
3135+
ImageRoot = "$(Get-InstallDir $Platform)\";
31353136
# When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
31363137
# https://github.com/microsoft/mimalloc/issues/997
3137-
WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling) { "true" } else { "false" };
3138+
WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling) { "True" } else { "False" };
31383139
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC;
31393140
SWIFT_DOCC_BUILD = "$(Get-ProjectBinaryCache $HostPlatform DocC)\release";
31403141
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = "${SourceCache}\swift-docc-render-artifact";
@@ -3149,10 +3150,11 @@ function Build-Installer([Hashtable] $Platform) {
31493150
}
31503151
}
31513152

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

31583160
Build-WiXProject bundle\installer.wixproj -Platform $Platform -Bundle -Properties $Properties
@@ -3161,11 +3163,7 @@ function Build-Installer([Hashtable] $Platform) {
31613163
function Copy-BuildArtifactsToStage([Hashtable] $Platform) {
31623164
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.cab" $Stage
31633165
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.msi" $Stage
3164-
foreach ($SDKPlatform in $WindowsSDKPlatforms) {
3165-
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($SDKPlatform.Architecture.VSName)\sdk.windows.$($SDKPlatform.Architecture.VSName).cab" $Stage
3166-
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($SDKPlatform.Architecture.VSName)\sdk.windows.$($SDKPlatform.Architecture.VSName).msi" $Stage
3167-
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($SDKPlatform.Architecture.VSName)\rtl.$($SDKPlatform.Architecture.VSName).msm" $Stage
3168-
}
3166+
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.msm" $Stage
31693167
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\installer.exe" $Stage
31703168
# Extract installer engine to ease code-signing on swift.org CI
31713169
if ($ToBatch) {
@@ -3228,10 +3226,9 @@ if (-not $SkipBuild) {
32283226
Move-Item $_.FullName "$(Get-SwiftSDK Windows)\usr\lib\swift\windows\$($Platform.Architecture.LLVMName)\" | Out-Null
32293227
}
32303228

3231-
if ($Platform -eq $HostPlatform) {
3232-
Copy-Directory "$(Get-SwiftSDK Windows)\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Platform), "Runtimes", $ProductVersion))\usr"
3233-
}
3229+
Copy-Directory "$(Get-SwiftSDK Windows)\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Platform), "Runtimes", $ProductVersion, "usr"))"
32343230
}
3231+
32353232
Install-Platform $WindowsSDKPlatforms Windows
32363233
Write-PlatformInfoPlist Windows
32373234
Write-SDKSettingsPlist Windows

0 commit comments

Comments
 (0)