Skip to content

Commit 7b0e8a9

Browse files
committed
build: adjust the installer build and artifact staging
Adjust the installer to allow it to be built for foreign architectures. Additionally, adjust the artifact staging to include additional content that was missed previously in order to enable code signing.
1 parent b74e4a2 commit 7b0e8a9

File tree

1 file changed

+41
-24
lines changed

1 file changed

+41
-24
lines changed

utils/build.ps1

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,13 @@ function Copy-File($Src, $Dst) {
254254
# Create the directory tree first so Copy-Item succeeds
255255
# If $Dst is the target directory, make sure it ends with "\"
256256
$DstDir = [IO.Path]::GetDirectoryName($Dst)
257-
New-Item -ItemType Directory -ErrorAction Ignore $DstDir | Out-Null
258-
Copy-Item -Force $Src $Dst
257+
if ($ToBatch) {
258+
Write-Output "md `"$DstDir`""
259+
Write-Output "copy /Y `"$Src`" `"$Dst`""
260+
} else {
261+
New-Item -ItemType Directory -ErrorAction Ignore $DstDir | Out-Null
262+
Copy-Item -Force $Src $Dst
263+
}
259264
}
260265

261266
function Copy-Directory($Src, $Dst) {
@@ -1558,46 +1563,54 @@ function Build-DocC() {
15581563
}
15591564
}
15601565

1561-
function Build-Installer() {
1566+
function Build-Installer($Arch) {
15621567
$Properties = @{
15631568
BundleFlavor = "offline";
1564-
DEVTOOLS_ROOT = "$($HostArch.ToolchainInstallRoot)\";
1565-
TOOLCHAIN_ROOT = "$($HostArch.ToolchainInstallRoot)\";
1569+
DEVTOOLS_ROOT = "$($Arch.ToolchainInstallRoot)\";
1570+
TOOLCHAIN_ROOT = "$($Arch.ToolchainInstallRoot)\";
15661571
INCLUDE_SWIFT_FORMAT = "true";
1567-
SWIFT_FORMAT_BUILD = "$($HostArch.BinaryCache)\swift-format\release";
1572+
SWIFT_FORMAT_BUILD = "$($Arch.BinaryCache)\swift-format\release";
15681573
INCLUDE_SWIFT_INSPECT = "true";
1569-
SWIFT_INSPECT_BUILD = "$($HostArch.BinaryCache)\swift-inspect\release";
1574+
SWIFT_INSPECT_BUILD = "$($Arch.BinaryCache)\swift-inspect\release";
15701575
INCLUDE_SWIFT_DOCC = "true";
1571-
SWIFT_DOCC_BUILD = "$($HostArch.BinaryCache)\swift-docc\release";
1576+
SWIFT_DOCC_BUILD = "$($Arch.BinaryCache)\swift-docc\release";
15721577
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = "${SourceCache}\swift-docc-render-artifact";
15731578
}
15741579

15751580
Isolate-EnvVars {
1576-
Invoke-VsDevShell $HostArch
1577-
$VCRedistInstallerPath = "${env:VCToolsRedistDir}\vc_redist.$($HostArch.ShortName).exe"
1581+
Invoke-VsDevShell $Arch
1582+
$VCRedistInstallerPath = "${env:VCToolsRedistDir}\vc_redist.$($Arch.ShortName).exe"
15781583
if (Test-Path $VCRedistInstallerPath) {
15791584
$Properties["VCRedistInstaller"] = $VCRedistInstallerPath
15801585
$Properties["VSVersion"] = $env:VSCMD_VER
15811586
}
15821587
}
15831588

1584-
foreach ($Arch in $SDKArchs) {
1585-
$Properties["INCLUDE_$($Arch.VSName.ToUpperInvariant())_SDK"] = "true"
1586-
$Properties["PLATFORM_ROOT_$($Arch.VSName.ToUpperInvariant())"] = "$($Arch.PlatformInstallRoot)\"
1587-
$Properties["SDK_ROOT_$($Arch.VSName.ToUpperInvariant())"] = "$($Arch.SDKInstallRoot)\"
1589+
foreach ($SDK in $SDKArchs) {
1590+
$Properties["INCLUDE_$($SDK.VSName.ToUpperInvariant())_SDK"] = "true"
1591+
$Properties["PLATFORM_ROOT_$($SDK.VSName.ToUpperInvariant())"] = "$($SDK.PlatformInstallRoot)\"
1592+
$Properties["SDK_ROOT_$($SDK.VSName.ToUpperInvariant())"] = "$($SDK.SDKInstallRoot)\"
15881593
}
15891594

1590-
Build-WiXProject bundle\installer.wixproj -Arch $HostArch -Properties $Properties
1595+
Build-WiXProject bundle\installer.wixproj -Arch $Arch -Properties $Properties
1596+
}
15911597

1592-
if ($Stage -and (-not $ToBatch)) {
1593-
Copy-File "$($HostArch.BinaryCache)\installer\Release\$($HostArch.VSName)\*.cab" "$Stage\"
1594-
Copy-File "$($HostArch.BinaryCache)\installer\Release\$($HostArch.VSName)\*.msi" "$Stage\"
1595-
Copy-File "$($HostArch.BinaryCache)\installer\Release\$($HostArch.VSName)\*.msm" "$Stage\"
1596-
Copy-File "$($HostArch.BinaryCache)\installer\Release\$($HostArch.VSName)\installer.exe" "$Stage\"
1597-
# Extract installer engine to ease code-signing on swift.org CI
1598-
New-Item -Type Directory -Path "$($HostArch.BinaryCache)\installer\$($HostArch.VSName)\" -ErrorAction Ignore | Out-Null
1599-
Invoke-Program "$BinaryCache\wix-4.0.1\tools\net6.0\any\wix.exe" -- burn detach "$($HostArch.BinaryCache)\installer\Release\$($HostArch.VSName)\installer.exe" -engine "$Stage\installer-engine.exe" -intermediateFolder "$($HostArch.BinaryCache)\installer\$($HostArch.VSName)\"
1598+
function Stage-BuildArtifacts($Arch) {
1599+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($Arch.VSName)\*.cab" "$Stage\"
1600+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($Arch.VSName)\*.msi" "$Stage\"
1601+
foreach ($SDK in $SDKArchs) {
1602+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($SDK.VSName)\sdk.$($SDK.VSName).cab" "$Stage\"
1603+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($SDK.VSName)\sdk.$($SDK.VSName).msi" "$Stage\"
1604+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($SDK.VSName)\sdk.$($SDK.VSName).msm" "$Stage\"
16001605
}
1606+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($Arch.VSName)\installer.exe" "$Stage\"
1607+
# Extract installer engine to ease code-signing on swift.org CI
1608+
if ($ToBatch) {
1609+
Write-Output "md `"$($Arch.BinaryCache)\installer\$($Arch.VSName)\`""
1610+
} else {
1611+
New-Item -Type Directory -Path "$($Arch.BinaryCache)\installer\$($Arch.VSName)\" -ErrorAction Ignore | Out-Null
1612+
}
1613+
Invoke-Program "$BinaryCache\wix-4.0.1\tools\net6.0\any\wix.exe" -- burn detach "$($Arch.BinaryCache)\installer\Release\$($Arch.VSName)\installer.exe" -engine "$Stage\installer-engine.exe" -intermediateFolder "$($Arch.BinaryCache)\installer\$($Arch.VSName)\"
16011614
}
16021615

16031616
#-------------------------------------------------------------------
@@ -1667,7 +1680,11 @@ if (-not $SkipBuild) {
16671680
}
16681681

16691682
if (-not $SkipPackaging) {
1670-
Invoke-BuildStep Build-Installer
1683+
Invoke-BuildStep Build-Installer $HostArch
1684+
}
1685+
1686+
if ($Stage) {
1687+
Stage-BuildArtifacts $HostArch
16711688
}
16721689

16731690
if ($Test -contains "swift") { Build-Compilers $HostArch -Test }

0 commit comments

Comments
 (0)