Skip to content

Commit c676c29

Browse files
authored
Merge pull request #84966 from compnerd/test-dependencie
utils: shuffle install order for toolchain dependencies
2 parents a687605 + a5010b2 commit c676c29

File tree

1 file changed

+53
-54
lines changed

1 file changed

+53
-54
lines changed

utils/build.ps1

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,42 +1251,6 @@ function Get-Dependencies {
12511251
Write-Success "syft $SyftVersion"
12521252
}
12531253

1254-
if ($SkipBuild -and $SkipPackaging) { return }
1255-
1256-
DownloadAndVerify $WiX.URL "$BinaryCache\WiX-$($WiX.Version).zip" $WiX.SHA256
1257-
Expand-ZipFile WiX-$($WiX.Version).zip $BinaryCache WiX-$($WiX.Version)
1258-
Write-Success "WiX $($WiX.Version)"
1259-
1260-
if ($SkipBuild) { return }
1261-
1262-
if ($EnableCaching) {
1263-
$SCCache = Get-SCCache
1264-
$FileExtension = [System.IO.Path]::GetExtension($SCCache.URL)
1265-
DownloadAndVerify $SCCache.URL "$BinaryCache\sccache-$SCCacheVersion.$FileExtension" $SCCache.SHA256
1266-
if ($FileExtension -eq "tar.gz") {
1267-
Expand-TapeArchive sccache-$SCCacheVersion.$FileExtension $BinaryCache sccache-$SCCacheVersion
1268-
} else {
1269-
Expand-ZipFile sccache-$SCCacheVersion.$FileExtension $BinaryCache sccache-$SCCacheVersion
1270-
}
1271-
Write-Success "sccache $SCCacheVersion"
1272-
}
1273-
1274-
DownloadAndVerify $PinnedBuild "$BinaryCache\$PinnedToolchain.exe" $PinnedSHA256
1275-
1276-
if ($Test -contains "lldb") {
1277-
# The make tool isn't part of MSYS
1278-
$GnuWin32MakeURL = "https://downloads.sourceforge.net/project/ezwinports/make-4.4.1-without-guile-w32-bin.zip"
1279-
$GnuWin32MakeHash = "fb66a02b530f7466f6222ce53c0b602c5288e601547a034e4156a512dd895ee7"
1280-
DownloadAndVerify $GnuWin32MakeURL "$BinaryCache\GnuWin32Make-4.4.1.zip" $GnuWin32MakeHash
1281-
Expand-ZipFile GnuWin32Make-4.4.1.zip $BinaryCache GnuWin32Make-4.4.1
1282-
Write-Success "GNUWin32 make 4.4.1"
1283-
}
1284-
1285-
# TODO(compnerd) stamp/validate that we need to re-extract
1286-
New-Item -ItemType Directory -ErrorAction Ignore $BinaryCache\toolchains | Out-Null
1287-
Extract-Toolchain "$PinnedToolchain.exe" $BinaryCache $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1288-
Write-Success "Swift Toolchain $PinnedVersion"
1289-
12901254
function Get-KnownPython([string] $ArchName) {
12911255
if (-not $KnownPythons.ContainsKey($PythonVersion)) {
12921256
throw "Unknown python version: $PythonVersion"
@@ -1303,62 +1267,97 @@ function Get-Dependencies {
13031267
}
13041268
}
13051269

1306-
function Install-PIPIfNeeded() {
1270+
function Install-PIPIfNeeded {
13071271
try {
13081272
Invoke-Program -Silent "$(Get-PythonExecutable)" -m pip
13091273
} catch {
1310-
# Write-Output "Installing pip ..."
13111274
Invoke-Program -OutNull "$(Get-PythonExecutable)" '-I' -m ensurepip -U --default-pip
13121275
} finally {
1313-
# Write-Output "pip installed."
13141276
Write-Success "pip"
13151277
}
13161278
}
13171279

13181280
function Test-PythonModuleInstalled([string] $ModuleName) {
13191281
try {
13201282
Invoke-Program -Silent "$(Get-PythonExecutable)" -c "import $ModuleName"
1321-
return $true;
1283+
return $true
13221284
} catch {
1323-
return $false;
1285+
return $false
13241286
}
13251287
}
13261288

13271289
function Install-PythonModule([string] $ModuleName) {
13281290
if (Test-PythonModuleInstalled $ModuleName) {
13291291
# Write-Output "$ModuleName already installed."
1330-
return;
1292+
return
13311293
}
1294+
13321295
$TempRequirementsTxt = New-TemporaryFile
1296+
13331297
$Module = $PythonModules[$ModuleName]
1334-
$Dependencies = $Module["Dependencies"]
1335-
Write-Output "$ModuleName==$($Module.Version) --hash=`"sha256:$($Module.SHA256)`"" >> $TempRequirementsTxt
1336-
for ($i = 0; $i -lt $Dependencies.Length; $i++) {
1337-
$Dependency = $PythonModules[$Dependencies[$i]]
1338-
Write-Output "$($Dependencies[$i])==$($Dependency.Version) --hash=`"sha256:$($Dependency.SHA256)`"" >> $TempRequirementsTxt
1298+
"$ModuleName==$($Module.Version) --hash=`"sha256:$($Module.SHA256)`"" | Out-File -FilePath $TempRequirementsTxt -Append -Encoding utf8
1299+
foreach ($Dependency in $Module.Dependencies) {
1300+
$Module = $PythonModules[$Dependency]
1301+
"$Dependency==$($Dependency.Version) --hash=`"sha256:$($Module.SHA256)`"" | Out-File -FilePath $TempRequirementsTxt -Append -Encoding utf8
13391302
}
1303+
13401304
Invoke-Program -OutNull "$(Get-PythonExecutable)" '-I' -m pip install -r $TempRequirementsTxt --require-hashes --no-binary==:all: --disable-pip-version-check
1341-
# Write-Output "$ModuleName installed."
1342-
Write-Success $ModuleName
1305+
1306+
Write-Success "$ModuleName"
13431307
}
13441308

1345-
function Install-PythonModules() {
1309+
function Install-PythonModules {
13461310
Install-PIPIfNeeded
1347-
Install-PythonModule "packaging" # For building LLVM 18+
1311+
Install-PythonModule "packaging" # For building LLVM 18+
13481312
Install-PythonModule "setuptools" # Required for SWIG support
13491313
if ($Test -contains "lldb") {
1350-
Install-PythonModule "psutil" # Required for testing LLDB
1314+
Install-PythonModule "psutil" # Required for testing LLDB
13511315
}
13521316
}
13531317

1318+
# Ensure Python modules that are required as host build tools
13541319
Install-Python $HostArchName
13551320
if ($IsCrossCompiling) {
13561321
Install-Python $BuildArchName
13571322
}
1358-
1359-
# Ensure Python modules that are required as host build tools
13601323
Install-PythonModules
13611324

1325+
if ($SkipBuild -and $SkipPackaging) { return }
1326+
1327+
DownloadAndVerify $WiX.URL "$BinaryCache\WiX-$($WiX.Version).zip" $WiX.SHA256
1328+
Expand-ZipFile WiX-$($WiX.Version).zip $BinaryCache WiX-$($WiX.Version)
1329+
Write-Success "WiX $($WiX.Version)"
1330+
1331+
if ($SkipBuild) { return }
1332+
1333+
if ($EnableCaching) {
1334+
$SCCache = Get-SCCache
1335+
$FileExtension = [System.IO.Path]::GetExtension($SCCache.URL)
1336+
DownloadAndVerify $SCCache.URL "$BinaryCache\sccache-$SCCacheVersion.$FileExtension" $SCCache.SHA256
1337+
if ($FileExtension -eq "tar.gz") {
1338+
Expand-TapeArchive sccache-$SCCacheVersion.$FileExtension $BinaryCache sccache-$SCCacheVersion
1339+
} else {
1340+
Expand-ZipFile sccache-$SCCacheVersion.$FileExtension $BinaryCache sccache-$SCCacheVersion
1341+
}
1342+
Write-Success "sccache $SCCacheVersion"
1343+
}
1344+
1345+
DownloadAndVerify $PinnedBuild "$BinaryCache\$PinnedToolchain.exe" $PinnedSHA256
1346+
1347+
if ($Test -contains "lldb") {
1348+
# The make tool isn't part of MSYS
1349+
$GnuWin32MakeURL = "https://downloads.sourceforge.net/project/ezwinports/make-4.4.1-without-guile-w32-bin.zip"
1350+
$GnuWin32MakeHash = "fb66a02b530f7466f6222ce53c0b602c5288e601547a034e4156a512dd895ee7"
1351+
DownloadAndVerify $GnuWin32MakeURL "$BinaryCache\GnuWin32Make-4.4.1.zip" $GnuWin32MakeHash
1352+
Expand-ZipFile GnuWin32Make-4.4.1.zip $BinaryCache GnuWin32Make-4.4.1
1353+
Write-Success "GNUWin32 make 4.4.1"
1354+
}
1355+
1356+
# TODO(compnerd) stamp/validate that we need to re-extract
1357+
New-Item -ItemType Directory -ErrorAction Ignore $BinaryCache\toolchains | Out-Null
1358+
Extract-Toolchain "$PinnedToolchain.exe" $BinaryCache $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1359+
Write-Success "Swift Toolchain $PinnedVersion"
1360+
13621361
if ($Android) {
13631362
$NDK = Get-AndroidNDK
13641363
DownloadAndVerify $NDK.URL "$BinaryCache\android-ndk-$AndroidNDKVersion-windows.zip" $NDK.SHA256

0 commit comments

Comments
 (0)