Read the source URLs and revisions directly from the selected runtime. Retire the six patches now in the organization forks and record the resolved URLs in the manifest and source package.
32 lines
1.6 KiB
PowerShell
32 lines
1.6 KiB
PowerShell
param([Parameter(Mandatory)][string]$RuntimeRepo)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$githubUrl = 'https://github\.com/[\w.-]+/[\w.-]+'
|
|
$util = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'crates/reims-ctl/src/reims_util.rs')
|
|
$utilUrl = [regex]::Match($util, "pub const REPO: &str = ""($githubUrl)"";").Groups[1].Value
|
|
$utilRev = [regex]::Match($util, 'pub const REV: &str = "([0-9a-f]{40})";').Groups[1].Value
|
|
if (-not $utilUrl -or -not $utilRev) { throw 'reims-util REPO or REV is missing from reims_util.rs' }
|
|
|
|
$cargo = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'Cargo.toml')
|
|
$metal = foreach ($name in 'metal2vulkan', 'metal2vulkan-runtime') {
|
|
$entry = [regex]::Match($cargo, "(?m)^$name\s*=\s*\{([^}]+)\}").Groups[1].Value
|
|
$url = [regex]::Match($entry, "git\s*=\s*""($githubUrl)""").Groups[1].Value
|
|
if (-not $url) { throw "$name git URL is missing from Cargo.toml" }
|
|
$rev = [regex]::Match($entry, 'rev\s*=\s*"([0-9a-f]{40})"').Groups[1].Value
|
|
if (-not $rev) {
|
|
$lock = Get-Content -Raw -LiteralPath (Join-Path $RuntimeRepo 'Cargo.lock')
|
|
$pin = '(?m)^source = "git\+' + [regex]::Escape($url) + '\?rev=([0-9a-f]{40})#[0-9a-f]{40}"'
|
|
$rev = [regex]::Match($lock, $pin).Groups[1].Value
|
|
}
|
|
if (-not $rev) { throw "$name revision is missing from Cargo.toml and Cargo.lock" }
|
|
[pscustomobject]@{ Url = $url; Rev = $rev }
|
|
}
|
|
if ($metal[0].Url -cne $metal[1].Url -or $metal[0].Rev -cne $metal[1].Rev) {
|
|
throw 'metal2vulkan and metal2vulkan-runtime must use the same repository and commit'
|
|
}
|
|
|
|
[pscustomobject]@{
|
|
Util = [pscustomobject]@{ Url = $utilUrl; Rev = $utilRev }
|
|
Metal = $metal[0]
|
|
}
|