Skip to content

Commit 8ffe033

Browse files
Merge pull request #84292 from charles-zablit/charles-zablit/windows/fix-sccache-installation-arm64
[windows] fix sccache installation on arm64
2 parents d653b0c + 1312cb7 commit 8ffe033

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

utils/build.ps1

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,25 +1154,50 @@ function Get-Dependencies {
11541154
[bool]$CreateExtractPath = $true
11551155
)
11561156

1157-
$source = Join-Path -Path $BinaryCache -ChildPath $ZipFileName
1158-
$destination = Join-Path -Path $BinaryCache -ChildPath $ExtractPath
1157+
$Source = Join-Path -Path $BinaryCache -ChildPath $ZipFileName
1158+
$Destination = Join-Path -Path $BinaryCache -ChildPath $ExtractPath
11591159

11601160
# Check if the extracted directory already exists and is up to date.
1161-
if (Test-Path $destination) {
1162-
$zipLastWriteTime = (Get-Item $source).LastWriteTime
1163-
$extractedLastWriteTime = (Get-Item $destination).LastWriteTime
1161+
if (Test-Path $Destination) {
1162+
$ZipLastWriteTime = (Get-Item $Source).LastWriteTime
1163+
$ExtractedLastWriteTime = (Get-Item $Destination).LastWriteTime
11641164
# Compare the last write times
1165-
if ($zipLastWriteTime -le $extractedLastWriteTime) {
1165+
if ($ZipLastWriteTime -le $ExtractedLastWriteTime) {
11661166
Write-Output "'$ZipFileName' is already extracted and up to date."
11671167
return
11681168
}
11691169
}
11701170

1171-
$destination = if ($CreateExtractPath) { $destination } else { $BinaryCache }
1171+
$Destination = if ($CreateExtractPath) { $Destination } else { $BinaryCache }
11721172

11731173
Write-Output "Extracting '$ZipFileName' ..."
11741174
New-Item -ItemType Directory -ErrorAction Ignore -Path $BinaryCache | Out-Null
1175-
Expand-Archive -Path $source -DestinationPath $destination -Force
1175+
Expand-Archive -Path $Source -DestinationPath $Destination -Force
1176+
}
1177+
1178+
function Expand-TapeArchive {
1179+
param
1180+
(
1181+
[string]$SourceName,
1182+
[string]$DestinationName
1183+
)
1184+
$Source = Join-Path -Path $BinaryCache -ChildPath $SourceName
1185+
$Destination = Join-Path -Path $BinaryCache -ChildPath $DestinationName
1186+
1187+
# Check if the extracted directory already exists and is up to date.
1188+
if (Test-Path $Destination) {
1189+
$TarLastWriteTime = (Get-Item $Source).LastWriteTime
1190+
$ExtractedLastWriteTime = (Get-Item $Destination).LastWriteTime
1191+
# Compare the last write times
1192+
if ($TarLastWriteTime -le $ExtractedLastWriteTime) {
1193+
Write-Output "'$SourceName' is already extracted and up to date."
1194+
return
1195+
}
1196+
}
1197+
1198+
Write-Output "Extracting '$Source' ..."
1199+
New-Item -ItemType Directory -ErrorAction Ignore -Path $Destination | Out-Null
1200+
tar -xvf $Source -C $Destination | Out-Null
11761201
}
11771202

11781203
function Extract-Toolchain {
@@ -1228,8 +1253,13 @@ function Get-Dependencies {
12281253

12291254
if ($EnableCaching) {
12301255
$SCCache = Get-SCCache
1231-
DownloadAndVerify $SCCache.URL "$BinaryCache\sccache-$SCCacheVersion.zip" $SCCache.SHA256
1232-
Expand-ZipFile sccache-$SCCacheVersion.zip $BinaryCache sccache-$SCCacheVersion
1256+
$FileExtension = [System.IO.Path]::GetExtension($SCCache.URL)
1257+
DownloadAndVerify $SCCache.URL "$BinaryCache\sccache-$SCCacheVersion.$FileExtension" $SCCache.SHA256
1258+
if ($FileExtension -eq "tar.gz") {
1259+
Expand-TapeArchive sccache-$SCCacheVersion.$FileExtension $BinaryCache sccache-$SCCacheVersion
1260+
} else {
1261+
Expand-ZipFile sccache-$SCCacheVersion.$FileExtension $BinaryCache sccache-$SCCacheVersion
1262+
}
12331263
}
12341264

12351265
DownloadAndVerify $PinnedBuild "$BinaryCache\$PinnedToolchain.exe" $PinnedSHA256

0 commit comments

Comments
 (0)