Skip to content

Commit 2e348d2

Browse files
authored
Merge pull request #69575 from compnerd/stage
build: adjust the installer build and artifact staging
2 parents 70a1ac2 + 5da8b3f commit 2e348d2

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

utils/build.ps1

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

262267
function Copy-Directory($Src, $Dst) {
@@ -1558,46 +1563,56 @@ 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+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($Arch.VSName)\rtl.cab" "$Stage\"
1602+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($Arch.VSName)\rtl.msi" "$Stage\"
1603+
foreach ($SDK in $SDKArchs) {
1604+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($SDK.VSName)\sdk.$($SDK.VSName).cab" "$Stage\"
1605+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($SDK.VSName)\sdk.$($SDK.VSName).msi" "$Stage\"
1606+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($SDK.VSName)\rtl.$($SDK.VSName).msm" "$Stage\"
16001607
}
1608+
Copy-File "$($Arch.BinaryCache)\installer\Release\$($Arch.VSName)\installer.exe" "$Stage\"
1609+
# Extract installer engine to ease code-signing on swift.org CI
1610+
if ($ToBatch) {
1611+
Write-Output "md `"$($Arch.BinaryCache)\installer\$($Arch.VSName)\`""
1612+
} else {
1613+
New-Item -Type Directory -Path "$($Arch.BinaryCache)\installer\$($Arch.VSName)\" -ErrorAction Ignore | Out-Null
1614+
}
1615+
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)\"
16011616
}
16021617

16031618
#-------------------------------------------------------------------
@@ -1666,7 +1681,11 @@ if (-not $SkipBuild) {
16661681
}
16671682

16681683
if (-not $SkipPackaging) {
1669-
Invoke-BuildStep Build-Installer
1684+
Invoke-BuildStep Build-Installer $HostArch
1685+
}
1686+
1687+
if ($Stage) {
1688+
Stage-BuildArtifacts $HostArch
16701689
}
16711690

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

0 commit comments

Comments
 (0)