Skip to content

Commit 1312cb7

Browse files
[windows] fix sccache installation on arm64
1 parent e8784b8 commit 1312cb7

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
@@ -1153,25 +1153,50 @@ function Get-Dependencies {
11531153
[bool]$CreateExtractPath = $true
11541154
)
11551155

1156-
$source = Join-Path -Path $BinaryCache -ChildPath $ZipFileName
1157-
$destination = Join-Path -Path $BinaryCache -ChildPath $ExtractPath
1156+
$Source = Join-Path -Path $BinaryCache -ChildPath $ZipFileName
1157+
$Destination = Join-Path -Path $BinaryCache -ChildPath $ExtractPath
11581158

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

1170-
$destination = if ($CreateExtractPath) { $destination } else { $BinaryCache }
1170+
$Destination = if ($CreateExtractPath) { $Destination } else { $BinaryCache }
11711171

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

11771202
function Extract-Toolchain {
@@ -1227,8 +1252,13 @@ function Get-Dependencies {
12271252

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

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

0 commit comments

Comments
 (0)