feat(v2): add CMD release packaging entrypoint
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$batchEntrypoint = Join-Path $PSScriptRoot 'build-v2-release.bat'
|
||||
$powerShellEntrypoint = Join-Path $PSScriptRoot 'build-v2-release.ps1'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $batchEntrypoint -PathType Leaf)) {
|
||||
throw "Batch entrypoint is missing: $batchEntrypoint"
|
||||
}
|
||||
|
||||
$sandbox = Join-Path ([System.IO.Path]::GetTempPath()) ("silver-pose-v2-bat-test-" + [guid]::NewGuid().ToString('N'))
|
||||
try {
|
||||
New-Item -ItemType Directory -Path $sandbox | Out-Null
|
||||
$inputs = @{
|
||||
OnnxPath = Join-Path $sandbox 'best.onnx'
|
||||
OrtDllPath = Join-Path $sandbox 'onnxruntime.dll'
|
||||
FfmpegPath = Join-Path $sandbox 'ffmpeg.exe'
|
||||
FfprobePath = Join-Path $sandbox 'ffprobe.exe'
|
||||
}
|
||||
$inputs.Values | ForEach-Object { New-Item -ItemType File -Path $_ | Out-Null }
|
||||
$output = Join-Path $sandbox 'non-empty-output'
|
||||
New-Item -ItemType Directory -Path $output | Out-Null
|
||||
New-Item -ItemType File -Path (Join-Path $output 'sentinel.txt') | Out-Null
|
||||
|
||||
$directArgs = @(
|
||||
'-NoLogo',
|
||||
'-NoProfile',
|
||||
'-ExecutionPolicy', 'Bypass',
|
||||
'-File', $powerShellEntrypoint,
|
||||
'-OnnxPath', $inputs.OnnxPath,
|
||||
'-OrtDllPath', $inputs.OrtDllPath,
|
||||
'-FfmpegPath', $inputs.FfmpegPath,
|
||||
'-FfprobePath', $inputs.FfprobePath,
|
||||
'-OutputDirectory', $output
|
||||
)
|
||||
$directOutput = & powershell.exe @directArgs 2>&1 | Out-String
|
||||
$directExitCode = $LASTEXITCODE
|
||||
|
||||
$batchCommand = '"{0}" -OnnxPath "{1}" -OrtDllPath "{2}" -FfmpegPath "{3}" -FfprobePath "{4}" -OutputDirectory "{5}"' -f $batchEntrypoint, $inputs.OnnxPath, $inputs.OrtDllPath, $inputs.FfmpegPath, $inputs.FfprobePath, $output
|
||||
$batchOutput = & cmd.exe /d /c $batchCommand 2>&1 | Out-String
|
||||
$batchExitCode = $LASTEXITCODE
|
||||
|
||||
if ($directExitCode -eq 0 -or $directOutput -notmatch 'OutputDirectory must be empty') {
|
||||
throw "The PowerShell release script did not reject the non-empty output directory. Output: $directOutput"
|
||||
}
|
||||
if ($batchExitCode -eq 0 -or $batchOutput -notmatch 'OutputDirectory must be empty') {
|
||||
throw "The batch entrypoint did not forward release arguments and exit status. Output: $batchOutput"
|
||||
}
|
||||
|
||||
Write-Output 'PASS: batch release entrypoint forwards arguments to the PowerShell release script.'
|
||||
exit 0
|
||||
} finally {
|
||||
if (Test-Path -LiteralPath $sandbox) {
|
||||
Remove-Item -LiteralPath $sandbox -Recurse -Force
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
rem Avoid passing a PowerShell 7 module path to Windows PowerShell 5.1.
|
||||
rem The release script needs the built-in Microsoft.PowerShell.Utility module.
|
||||
set "PSModulePath="
|
||||
powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%build-v2-release.ps1" %*
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
|
||||
endlocal & exit /b %EXIT_CODE%
|
||||
Reference in New Issue
Block a user