61 lines
2.0 KiB
PowerShell
61 lines
2.0 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$Version,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$Architecture,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$InstallDir
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
if (Test-Path (Join-Path $InstallDir "include\\pandaFramework.h")) {
|
|
Write-Host "MetaCore Panda3D SDK already prepared at $InstallDir"
|
|
exit 0
|
|
}
|
|
|
|
$installParent = Split-Path -Parent $InstallDir
|
|
New-Item -ItemType Directory -Force -Path $installParent | Out-Null
|
|
|
|
$downloadCacheDir = Join-Path $PSScriptRoot "..\\.metacore\\downloads"
|
|
New-Item -ItemType Directory -Force -Path $downloadCacheDir | Out-Null
|
|
|
|
$installerName = "Panda3D-SDK-$Version-$Architecture.exe"
|
|
$installerPath = Join-Path $downloadCacheDir $installerName
|
|
$downloadUrl = "https://www.panda3d.org/download/panda3d-$Version/$installerName"
|
|
|
|
if (-not (Test-Path $installerPath)) {
|
|
Write-Host "MetaCore downloading Panda3D SDK from $downloadUrl"
|
|
& curl.exe -L --fail --output $installerPath $downloadUrl
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "MetaCore failed to download Panda3D SDK."
|
|
}
|
|
}
|
|
|
|
if (Test-Path $InstallDir) {
|
|
Remove-Item -Recurse -Force $InstallDir
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
|
|
|
$installDirFullPath = (Resolve-Path $InstallDir).Path
|
|
Write-Host "MetaCore installing Panda3D SDK into $installDirFullPath"
|
|
|
|
$installerLaunchPath = Join-Path $downloadCacheDir ("launch-" + $installerName)
|
|
Copy-Item -Force $installerPath $installerLaunchPath
|
|
|
|
$installProcess = Start-Process -FilePath $installerLaunchPath -ArgumentList @("/S", "/D=$installDirFullPath") -Wait -PassThru
|
|
if ($installProcess.ExitCode -ne 0) {
|
|
throw "MetaCore Panda3D installer failed with exit code $($installProcess.ExitCode)."
|
|
}
|
|
|
|
Remove-Item -Force $installerLaunchPath -ErrorAction SilentlyContinue
|
|
|
|
if (-not (Test-Path (Join-Path $installDirFullPath "include\\pandaFramework.h"))) {
|
|
throw "MetaCore Panda3D installation finished but expected headers were not found."
|
|
}
|
|
|
|
Write-Host "MetaCore Panda3D SDK is ready at $installDirFullPath"
|