Files
NESLite/tools/fetch-third-party.ps1

43 lines
2.0 KiB
PowerShell

[CmdletBinding()]
param()
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$sourceRoot = Join-Path $root 'third_party\sources'
New-Item -ItemType Directory -Force -Path $sourceRoot | Out-Null
function Get-PinnedRepository {
param(
[Parameter(Mandatory)] [string]$Name,
[Parameter(Mandatory)] [string]$Url,
[Parameter(Mandatory)] [string]$Commit,
[string[]]$SparsePath = @()
)
$target = Join-Path $sourceRoot $Name
if (Test-Path $target) {
$actual = (& git -C $target rev-parse HEAD).Trim()
if ($actual -eq $Commit) {
Write-Output "$Name is already locked at $Commit"
return
}
throw "$target exists at $actual, not locked commit $Commit. Resolve it manually; this script never overwrites sources."
}
& git clone --filter=blob:none --no-checkout $Url $target
if ($LASTEXITCODE -ne 0) { throw "Could not clone $Name." }
if ($SparsePath.Count -gt 0) {
& git -C $target sparse-checkout init --cone
& git -C $target sparse-checkout set --no-cone @SparsePath
}
& git -C $target fetch --depth 1 origin $Commit
if ($LASTEXITCODE -ne 0) { throw "Could not fetch locked commit for $Name." }
& git -C $target checkout --detach $Commit
if ($LASTEXITCODE -ne 0) { throw "Could not check out locked commit for $Name." }
}
Get-PinnedRepository -Name 'libretro-fceumm' -Url 'https://github.com/libretro/libretro-fceumm.git' -Commit '236ccdfc911e84c60fea6b9d0699c2d440a8de14'
Get-PinnedRepository -Name 'libretro-headers' -Url 'https://github.com/libretro/RetroArch.git' -Commit '0c9622896333ee62dc4326bbe8784a210ddeb03c' -SparsePath @('libretro-common/include/libretro.h')
Get-PinnedRepository -Name 'oboe' -Url 'https://github.com/google/oboe.git' -Commit 'a81bb9f87d4105b84b682685d3bfbb5beca371d1'
Get-PinnedRepository -Name 'nestopia' -Url 'https://github.com/libretro/nestopia.git' -Commit '224713b257c8620513c1c9ca28dc7f8dea711e18'