优化大文件稳定并发传输与打包流程
This commit is contained in:
+72
@@ -0,0 +1,72 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
cd /d "%~dp0"
|
||||
|
||||
echo == QFT one-click package ==
|
||||
|
||||
where cargo >nul 2>nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: Rust cargo was not found in PATH.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
where java >nul 2>nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: JDK 17 was not found in PATH.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "android\local.properties" if not defined ANDROID_HOME if not defined ANDROID_SDK_ROOT (
|
||||
echo ERROR: Android SDK was not found. Set ANDROID_HOME or create android\local.properties with sdk.dir.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "android\gradle\wrapper\gradle-wrapper.jar" (
|
||||
echo [1/5] Bootstrapping the Gradle wrapper...
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "android\bootstrap-wrapper.ps1"
|
||||
if errorlevel 1 exit /b 1
|
||||
) else (
|
||||
echo [1/5] Gradle wrapper is ready.
|
||||
)
|
||||
|
||||
echo [2/5] Testing and building the Windows release...
|
||||
pushd windows
|
||||
cargo test
|
||||
if errorlevel 1 (popd & exit /b 1)
|
||||
cargo build --release
|
||||
if errorlevel 1 (popd & exit /b 1)
|
||||
popd
|
||||
|
||||
echo [3/5] Testing and building the installable Android APK...
|
||||
pushd android
|
||||
call gradlew.bat :app:testDebugUnitTest :app:assembleDebug --stacktrace
|
||||
if errorlevel 1 (popd & exit /b 1)
|
||||
popd
|
||||
|
||||
for /f "tokens=3" %%V in ('findstr /R /C:"versionName *=" "android\app\build.gradle.kts"') 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-%QFT_VERSION%-%QFT_STAMP%-windows"
|
||||
set "QFT_PACKAGE_DIR=%CD%\dist\%QFT_PACKAGE%"
|
||||
|
||||
echo [4/5] Collecting 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 "android\app\build\outputs\apk\debug\app-debug.apk" "%QFT_PACKAGE_DIR%\QFT-Android-%QFT_VERSION%.apk" >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 [5/5] 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
|
||||
Reference in New Issue
Block a user