修正为仅打包Rust桌面端
This commit is contained in:
@@ -143,7 +143,7 @@ APK:
|
||||
|
||||
## 一键打包
|
||||
|
||||
脚本会执行 Windows/桌面端 release 构建、Android 单元测试与可安装 debug APK 构建,随后把二进制、APK、协议说明和 SHA-256 校验文件收集到带时间戳的 `dist/QFT-*` 目录并生成压缩包:
|
||||
脚本只打包 `windows/` 下的 Rust 桌面端:执行 `cargo test` 和 `cargo build --release`,随后把 Rust 二进制、协议说明和 SHA-256 校验文件收集到带时间戳的 `dist/QFT-Rust-*` 目录并生成压缩包。脚本不检查、下载或调用 Android SDK、Java、Gradle:
|
||||
|
||||
```bat
|
||||
package.bat
|
||||
|
||||
+6
-32
@@ -2,7 +2,7 @@
|
||||
setlocal EnableExtensions
|
||||
cd /d "%~dp0"
|
||||
|
||||
echo == QFT one-click package ==
|
||||
echo == QFT Rust one-click package ==
|
||||
|
||||
where cargo >nul 2>nul
|
||||
if errorlevel 1 (
|
||||
@@ -10,26 +10,7 @@ if errorlevel 1 (
|
||||
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...
|
||||
echo [1/3] Testing and building the Rust Windows release...
|
||||
pushd windows
|
||||
cargo test
|
||||
if errorlevel 1 (popd & exit /b 1)
|
||||
@@ -37,27 +18,20 @@ 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 "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-%QFT_VERSION%-%QFT_STAMP%-windows"
|
||||
set "QFT_PACKAGE=QFT-Rust-%QFT_VERSION%-%QFT_STAMP%-windows"
|
||||
set "QFT_PACKAGE_DIR=%CD%\dist\%QFT_PACKAGE%"
|
||||
|
||||
echo [4/5] Collecting artifacts...
|
||||
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 "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...
|
||||
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 };" ^
|
||||
|
||||
+6
-25
@@ -4,42 +4,24 @@ set -eu
|
||||
QFT_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
cd "$QFT_ROOT"
|
||||
|
||||
echo "== QFT one-click package =="
|
||||
echo "== QFT Rust one-click package =="
|
||||
command -v cargo >/dev/null 2>&1 || { echo "ERROR: Rust cargo was not found in PATH." >&2; exit 1; }
|
||||
command -v java >/dev/null 2>&1 || { echo "ERROR: JDK 17 was not found in PATH." >&2; exit 1; }
|
||||
if [ ! -f "android/local.properties" ] && [ -z "${ANDROID_HOME:-}" ] && [ -z "${ANDROID_SDK_ROOT:-}" ]; then
|
||||
echo "ERROR: Android SDK was not found. Set ANDROID_HOME or create android/local.properties with sdk.dir." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "android/gradle/wrapper/gradle-wrapper.jar" ]; then
|
||||
echo "[1/5] Bootstrapping the Gradle wrapper..."
|
||||
sh android/bootstrap-wrapper.sh
|
||||
else
|
||||
echo "[1/5] Gradle wrapper is ready."
|
||||
fi
|
||||
|
||||
echo "[2/5] Testing and building the desktop release..."
|
||||
echo "[1/3] Testing and building the Rust desktop release..."
|
||||
(
|
||||
cd windows
|
||||
cargo test
|
||||
cargo build --release
|
||||
)
|
||||
|
||||
echo "[3/5] Testing and building the installable Android APK..."
|
||||
(
|
||||
cd android
|
||||
sh ./gradlew :app:testDebugUnitTest :app:assembleDebug --stacktrace
|
||||
)
|
||||
|
||||
QFT_VERSION=$(sed -n 's/.*versionName[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' android/app/build.gradle.kts | sed -n '1p')
|
||||
QFT_VERSION=$(awk -F'"' '/^\[package\]/{package=1; next} package && /^version[[:space:]]*=/{print $2; exit} /^\[/{package=0}' windows/Cargo.toml)
|
||||
[ -n "$QFT_VERSION" ] || QFT_VERSION=unknown
|
||||
QFT_STAMP=$(date '+%Y%m%d-%H%M%S')
|
||||
QFT_PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
QFT_PACKAGE="QFT-${QFT_VERSION}-${QFT_STAMP}-${QFT_PLATFORM}"
|
||||
QFT_PACKAGE="QFT-Rust-${QFT_VERSION}-${QFT_STAMP}-${QFT_PLATFORM}"
|
||||
QFT_PACKAGE_DIR="$QFT_ROOT/dist/$QFT_PACKAGE"
|
||||
|
||||
echo "[4/5] Collecting artifacts..."
|
||||
echo "[2/3] Collecting Rust artifacts..."
|
||||
mkdir -p "$QFT_PACKAGE_DIR"
|
||||
if [ -f "windows/target/release/qft-windows.exe" ]; then
|
||||
cp "windows/target/release/qft-windows.exe" "$QFT_PACKAGE_DIR/QFT-Windows.exe"
|
||||
@@ -49,11 +31,10 @@ else
|
||||
echo "ERROR: desktop release binary was not produced." >&2
|
||||
exit 1
|
||||
fi
|
||||
cp "android/app/build/outputs/apk/debug/app-debug.apk" "$QFT_PACKAGE_DIR/QFT-Android-${QFT_VERSION}.apk"
|
||||
cp README.md TEST_REPORT.md "$QFT_PACKAGE_DIR/"
|
||||
cp docs/PROTOCOL.md "$QFT_PACKAGE_DIR/PROTOCOL.md"
|
||||
|
||||
echo "[5/5] Writing SHA-256 checksums and archive..."
|
||||
echo "[3/3] Writing SHA-256 checksums and archive..."
|
||||
(
|
||||
cd "$QFT_PACKAGE_DIR"
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
|
||||
Reference in New Issue
Block a user