mirror of
https://github.com/actions/runner-images.git
synced 2025-12-10 19:16:48 +00:00
[macOS] Add MetalToolchain component for Xcode 26+ (#13088)
--------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -10,7 +10,7 @@ Import-Module "$env:HOME/image-generation/helpers/Xcode.Installer.psm1" -Disable
|
||||
|
||||
$arch = Get-Architecture
|
||||
[Array]$xcodeVersions = (Get-ToolsetContent).xcode.$arch.versions
|
||||
write-host $xcodeVersions
|
||||
Write-Host $xcodeVersions
|
||||
$defaultXcode = (Get-ToolsetContent).xcode.default
|
||||
[Array]::Reverse($xcodeVersions)
|
||||
$threadCount = "5"
|
||||
@@ -33,7 +33,10 @@ Write-Host "Configuring Xcode versions..."
|
||||
$xcodeVersions | ForEach-Object {
|
||||
Write-Host "Configuring Xcode $($_.link) ..."
|
||||
Invoke-XcodeRunFirstLaunch -Version $_.link
|
||||
Install-AdditionalSimulatorRuntimes -Version $_.link -Arch $arch -Runtimes $_.install_runtimes
|
||||
Install-XcodeAdditionalSimulatorRuntimes -Version $_.link -Arch $arch -Runtimes $_.install_runtimes
|
||||
if ($_.link -match '\d{2}(?=[._])' -and [int]$matches[0] -ge 26) {
|
||||
Install-XcodeAdditionalComponents -Version $_.link
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-XcodeRunFirstLaunch -Version $defaultXcode
|
||||
|
||||
@@ -42,46 +42,6 @@ function Invoke-DownloadXcodeArchive {
|
||||
return $tempXipDirectory
|
||||
}
|
||||
|
||||
function Resolve-ExactXcodeVersion {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Version
|
||||
)
|
||||
|
||||
# if toolset string contains spaces, consider it as a full name of Xcode
|
||||
if ($Version -match "\s") {
|
||||
return $Version
|
||||
}
|
||||
|
||||
$semverVersion = [SemVer]::Parse($Version)
|
||||
$availableVersions = Get-AvailableXcodeVersions
|
||||
$satisfiedVersions = $availableVersions | Where-Object { $semverVersion -eq $_.stableSemver }
|
||||
|
||||
return $satisfiedVersions | Select-Object -Last 1 -ExpandProperty rawVersion
|
||||
}
|
||||
|
||||
function Get-AvailableXcodeVersions {
|
||||
$rawVersionsList = Invoke-XCVersion -Arguments "list" | ForEach-Object { $_.Trim() } | Where-Object { $_ -match "^\d" }
|
||||
$availableVersions = $rawVersionsList | ForEach-Object {
|
||||
$partStable,$partMajor = $_.Split(" ", 2)
|
||||
$semver = $stableSemver = [SemVer]::Parse($partStable)
|
||||
|
||||
if ($partMajor) {
|
||||
# Convert 'beta 3' -> 'beta.3', 'Release Candidate' -> 'releasecandidate', 'GM Seed 2' -> 'gmseed.2'
|
||||
$normalizedLabel = $partMajor.toLower() -replace " (\d)", '.$1' -replace " ([a-z])", '$1'
|
||||
$semver = [SemVer]::new($stableSemver.Major, $stableSemver.Minor, $stableSemver.Patch, $normalizedLabel)
|
||||
}
|
||||
|
||||
return [PSCustomObject]@{
|
||||
semver = $semver
|
||||
rawVersion = $_
|
||||
stableSemver = $stableSemver
|
||||
}
|
||||
}
|
||||
|
||||
return $availableVersions | Sort-Object -Property semver
|
||||
}
|
||||
|
||||
function Expand-XcodeXipArchive {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
@@ -145,18 +105,16 @@ function Approve-XcodeLicense {
|
||||
}
|
||||
}
|
||||
|
||||
function Install-XcodeAdditionalPackages {
|
||||
function Install-XcodeAdditionalComponents {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Version
|
||||
)
|
||||
|
||||
Write-Host "Installing additional packages for Xcode $Version..."
|
||||
Write-Host "Installing additional MetalToolchain component for Xcode $Version..."
|
||||
$xcodeRootPath = Get-XcodeRootPath -Version $Version
|
||||
$packages = Get-ChildItem -Path "$xcodeRootPath/Contents/Resources/Packages" -Filter "*.pkg" -File
|
||||
$packages | ForEach-Object {
|
||||
Invoke-ValidateCommand "sudo installer -pkg $($_.FullName) -target / -allowUntrusted"
|
||||
}
|
||||
$xcodeBuildPath = Get-XcodeToolPath -XcodeRootPath $xcodeRootPath -ToolName "xcodebuild"
|
||||
Invoke-ValidateCommand "$xcodeBuildPath -downloadComponent MetalToolchain" | Out-Null
|
||||
}
|
||||
|
||||
function Invoke-XcodeRunFirstLaunch {
|
||||
@@ -170,7 +128,7 @@ function Invoke-XcodeRunFirstLaunch {
|
||||
Invoke-ValidateCommand "sudo $xcodeRootPath -runFirstLaunch"
|
||||
}
|
||||
|
||||
function Install-AdditionalSimulatorRuntimes {
|
||||
function Install-XcodeAdditionalSimulatorRuntimes {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Version,
|
||||
|
||||
Reference in New Issue
Block a user