47 lines
1.8 KiB
Batchfile
47 lines
1.8 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions
|
|
cd /d "%~dp0"
|
|
|
|
echo == QFT Rust one-click package ==
|
|
|
|
where cargo >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo ERROR: Rust cargo was not found in PATH.
|
|
exit /b 1
|
|
)
|
|
|
|
echo [1/3] Testing and building the Rust Windows release...
|
|
pushd windows
|
|
cargo test
|
|
if errorlevel 1 (popd & exit /b 1)
|
|
cargo build --release
|
|
if errorlevel 1 (popd & exit /b 1)
|
|
popd
|
|
|
|
for /f "tokens=3" %%V in ('findstr /R /C:"^version =" "windows\Cargo.toml"') do set "QFT_VERSION=%%~V"
|
|
for /f "usebackq delims=" %%T in (`powershell -NoProfile -Command "Get-Date -Format yyyyMMdd-HHmmss"`) do set "QFT_STAMP=%%T"
|
|
if not defined QFT_VERSION set "QFT_VERSION=unknown"
|
|
set "QFT_PACKAGE=QFT-Rust-%QFT_VERSION%-%QFT_STAMP%-windows"
|
|
set "QFT_PACKAGE_DIR=%CD%\dist\%QFT_PACKAGE%"
|
|
|
|
echo [2/3] Collecting Rust artifacts...
|
|
mkdir "%QFT_PACKAGE_DIR%" || exit /b 1
|
|
copy /y "windows\target\release\qft-windows.exe" "%QFT_PACKAGE_DIR%\QFT-Windows.exe" >nul || exit /b 1
|
|
copy /y "README.md" "%QFT_PACKAGE_DIR%\README.md" >nul || exit /b 1
|
|
copy /y "TEST_REPORT.md" "%QFT_PACKAGE_DIR%\TEST_REPORT.md" >nul || exit /b 1
|
|
copy /y "docs\PROTOCOL.md" "%QFT_PACKAGE_DIR%\PROTOCOL.md" >nul || exit /b 1
|
|
|
|
echo [3/3] Writing SHA-256 checksums and ZIP archive...
|
|
powershell -NoProfile -Command ^
|
|
"$dir = [IO.Path]::GetFullPath('%QFT_PACKAGE_DIR%');" ^
|
|
"$lines = Get-ChildItem -LiteralPath $dir -File ^| Sort-Object Name ^| ForEach-Object { '{0} {1}' -f (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLower(), $_.Name };" ^
|
|
"[IO.File]::WriteAllLines((Join-Path $dir 'SHA256SUMS.txt'), $lines, [Text.UTF8Encoding]::new($false));" ^
|
|
"Compress-Archive -LiteralPath $dir -DestinationPath ($dir + '.zip') -Force"
|
|
if errorlevel 1 exit /b 1
|
|
|
|
echo.
|
|
echo PACKAGE COMPLETE
|
|
echo Folder: %QFT_PACKAGE_DIR%
|
|
echo ZIP: %QFT_PACKAGE_DIR%.zip
|
|
exit /b 0
|