@@ -632,32 +632,53 @@ function Fetch-Dependencies {
632
632
633
633
Write-Output " Extracting '$ZipFileName ' ..."
634
634
New-Item - ItemType Directory - ErrorAction Ignore - Path $BinaryCache | Out-Null
635
- Expand-Archive - Path $source - DestinationPath $BinaryCache - Force
635
+ Expand-Archive - Path $source - DestinationPath $destination - Force
636
+ }
637
+
638
+ function Extract-Toolchain {
639
+ param (
640
+ [string ]$InstallerExeName ,
641
+ [string ]$BinaryCache ,
642
+ [string ]$ToolchainName
643
+ )
644
+
645
+ $source = Join-Path - Path $BinaryCache - ChildPath $InstallerExeName
646
+ $destination = Join-Path - Path $BinaryCache - ChildPath toolchains\$ToolchainName
647
+
648
+ # Check if the extracted directory already exists and is up to date.
649
+ if (Test-Path $destination ) {
650
+ $installerWriteTime = (Get-Item $source ).LastWriteTime
651
+ $extractedWriteTime = (Get-Item $destination ).LastWriteTime
652
+ if ($installerWriteTime -le $extractedWriteTime ) {
653
+ Write-Output " '$ToolchainName ' is already extracted and up to date."
654
+ return
655
+ }
656
+ }
657
+
658
+ Write-Output " Extracting '$ToolchainName ' ..."
659
+
660
+ # The new runtime MSI is built to expand files into the immediate directory. So, setup the installation location.
661
+ New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache \toolchains\$PinnedToolchain \LocalApp\Programs\Swift\Runtimes\0.0 .0 \usr\bin | Out-Null
662
+ Invoke-Program $BinaryCache \WiX- $WiXVersion \tools\net6.0 \any\wix.exe -- burn extract $BinaryCache \$ToolchainName.exe - out $BinaryCache \toolchains\ - outba $BinaryCache \toolchains\
663
+ Get-ChildItem " $BinaryCache \toolchains\WixAttachedContainer" - Filter " *.msi" | % {
664
+ $LogFile = [System.IO.Path ]::ChangeExtension($_.Name , " log" )
665
+ $TARGETDIR = if ($_.Name -eq " rtl.msi" ) { " $BinaryCache \toolchains\$ToolchainName \LocalApp\Programs\Swift\Runtimes\5.10.1\usr\bin" } else { " $BinaryCache \toolchains\$ToolchainName " }
666
+ Invoke-Program - OutNull msiexec.exe / lvx! $BinaryCache \toolchains\$LogFile / qn / a $BinaryCache \toolchains\WixAttachedContainer\$_ ALLUSERS= 0 TARGETDIR= $TARGETDIR
667
+ }
636
668
}
637
669
638
670
$WiXVersion = " 4.0.4"
639
671
$WiXURL = " https://www.nuget.org/api/v2/package/wix/$WiXVersion "
640
672
$WiXHash = " A9CA12214E61BB49430A8C6E5E48AC5AE6F27DC82573B5306955C4D35F2D34E2"
641
673
DownloadAndVerify $WixURL " $BinaryCache \WiX-$WiXVersion .zip" $WiXHash
642
674
643
- # TODO(compnerd) stamp/validate that we need to re-extract
644
- New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache \WiX- $WiXVersion | Out-Null
645
- Write-Output " Extracting WiX ..."
646
- Expand-Archive - Path $BinaryCache \WiX- $WiXVersion.zip - Destination $BinaryCache \WiX- $WiXVersion - Force
675
+ Extract- ZipFile WiX- $WiXVersion.zip $BinaryCache WiX- $WiXVersion
647
676
648
677
DownloadAndVerify $PinnedBuild " $BinaryCache \$PinnedToolchain .exe" $PinnedSHA256
649
678
650
679
# TODO(compnerd) stamp/validate that we need to re-extract
651
- Write-Output " Extracting $PinnedToolchain ..."
652
680
New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache \toolchains | Out-Null
653
- # The new runtime MSI is built to expand files into the immediate directory. So, setup the installation location.
654
- New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache \toolchains\$PinnedToolchain \LocalApp\Programs\Swift\Runtimes\0.0 .0 \usr\bin | Out-Null
655
- Invoke-Program $BinaryCache \WiX- $WiXVersion \tools\net6.0 \any\wix.exe -- burn extract $BinaryCache \$PinnedToolchain.exe - out $BinaryCache \toolchains\ - outba $BinaryCache \toolchains\
656
- Get-ChildItem " $BinaryCache \toolchains\WixAttachedContainer" - Filter " *.msi" | % {
657
- $LogFile = [System.IO.Path ]::ChangeExtension($_.Name , " log" )
658
- $TARGETDIR = if ($_.Name -eq " rtl.msi" ) { " $BinaryCache \toolchains\$PinnedToolchain \LocalApp\Programs\Swift\Runtimes\5.10.1\usr\bin" } else { " $BinaryCache \toolchains\$PinnedToolchain " }
659
- Invoke-Program - OutNull msiexec.exe / lvx! $BinaryCache \toolchains\$LogFile / qn / a $BinaryCache \toolchains\WixAttachedContainer\$_ ALLUSERS= 0 TARGETDIR= $TARGETDIR
660
- }
681
+ Extract- Toolchain " $PinnedToolchain .exe" $BinaryCache $PinnedToolchain
661
682
662
683
function Download-Python ($ArchName ) {
663
684
$PythonAMD64URL = " https://www.nuget.org/api/v2/package/python/$PythonVersion "
@@ -669,10 +690,7 @@ function Fetch-Dependencies {
669
690
DownloadAndVerify (Get-Variable - Name " Python${ArchName} URL" ).Value $BinaryCache \Python$ArchName - $PythonVersion.zip (Get-Variable - Name " Python${ArchName} Hash" ).Value
670
691
671
692
if (-not $ToBatch ) {
672
- # TODO(compnerd) stamp/validate that we need to re-extract
673
- New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache \Python$ArchName - $PythonVersion | Out-Null
674
- Write-Output " Extracting Python ($ArchName ) ..."
675
- Expand-Archive - Path $BinaryCache \Python$ArchName - $PythonVersion.zip - Destination $BinaryCache \Python$ArchName - $PythonVersion - Force
693
+ Extract- ZipFile Python$ArchName - $PythonVersion.zip $BinaryCache Python$ArchName - $PythonVersion
676
694
}
677
695
}
678
696
0 commit comments