sdt can compile journal and other projects. it using a json config system. this program's Repo exists on the Gitea under stan. Readme included as well.
48 lines
1.3 KiB
PowerShell
48 lines
1.3 KiB
PowerShell
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
function Test-SdtIsWindows {
|
|
if (Get-Variable -Name IsWindows -Scope Global -ErrorAction SilentlyContinue) {
|
|
return [bool]$global:IsWindows
|
|
}
|
|
|
|
return $env:OS -eq 'Windows_NT'
|
|
}
|
|
|
|
function Resolve-SdtPython {
|
|
$candidates = @('python')
|
|
if (Test-SdtIsWindows) { $candidates += 'py' } else { $candidates += 'python3' }
|
|
foreach ($c in $candidates) {
|
|
try {
|
|
& $c --version *> $null
|
|
if ($LASTEXITCODE -eq 0) { return $c }
|
|
} catch {}
|
|
}
|
|
return 'python'
|
|
}
|
|
|
|
function Resolve-SdtScriptPath {
|
|
param([Parameter(Mandatory=$true)][string]$ScriptName)
|
|
|
|
$bundled = Join-Path $PSScriptRoot $ScriptName
|
|
if (Test-Path $bundled) { return $bundled }
|
|
|
|
$project = Join-Path (Join-Path $PSScriptRoot '..') ('scripts\\' + $ScriptName)
|
|
if (Test-Path $project) { return (Resolve-Path $project).Path }
|
|
|
|
throw "Python helper script not found: $ScriptName"
|
|
}
|
|
|
|
function Invoke-SdtPythonScript {
|
|
param(
|
|
[Parameter(Mandatory=$true)][string]$ScriptName,
|
|
[string[]]$ForwardArgs = @()
|
|
)
|
|
|
|
$python = Resolve-SdtPython
|
|
$scriptPath = Resolve-SdtScriptPath -ScriptName $ScriptName
|
|
|
|
& $python $scriptPath @ForwardArgs
|
|
exit $LASTEXITCODE
|
|
}
|