Commit 403a10a0 authored by qq_38816927's avatar qq_38816927

打包脚本

parent 4b151778
......@@ -138,8 +138,10 @@ HDC_BIN="$DEVECO_HOME/sdk/default/openharmony/toolchains/hdc"
export DEVECO_SDK_HOME="$DEVECO_HOME/sdk"
export PATH="$DEVECO_SDK_HOME:$DEVECO_HOME/jbr/Contents/Home/bin:$DEVECO_HOME/tools/node/bin:$DEVECO_HOME/tools/ohpm/bin:$DEVECO_HOME/tools/hvigor/bin:$PATH"
"$HDC_BIN" -t "$TARGET_ID" shell aa force-stop "$BUNDLE_NAME" >/dev/null 2>&1 || true
echo "[Harmony-Debug-Pipeline] Prep: hdc force-stop $BUNDLE_NAME (ignore errors if not running)"
# ====================== [3. Gradle Build] ======================
echo "[Harmony-Debug-Pipeline] Build: Gradle KMP publishBinariesToHarmonyApp (mode=$BUILD_MODE; first run slower, later incremental)"
echo "Working path: $(pwd)"
echo "Building OpenHarmony ARM64..."
if [ "$PLATFORM" = "ohosArm64" ]; then
......@@ -168,6 +170,7 @@ else
echo -e "\033[31mError: Unsupported platform '$PLATFORM'\033[0m"
exit 4
fi
echo "[Harmony-Debug-Pipeline] Build: KMP publish finished — next ohpm/hvigor HAP (incremental builds may be faster)"
# SO packaging end time
HAP_START_TIME=$(date +%s)
# --- Subsequent install logic (hdc install etc.) ---
......@@ -194,6 +197,7 @@ if [ "$BUILD_MODE" = "release" ]; then
else
node "$DEVECO_HOME/tools/hvigor/bin/hvigorw.js" --mode module -p module=entry@default -p product=default -p buildMode=debug -p requiredDeviceType=phone assembleHap --analyze=normal --parallel --incremental --daemon
fi
echo "[Harmony-Debug-Pipeline] Build: HAP assemble finished"
# ====================== [5. Install and Push Debug Components] ======================
AVAILABLE_TARGETS=$("$HDC_BIN" list targets)
......@@ -227,6 +231,7 @@ if ! echo "$AVAILABLE_TARGETS" | grep -q "$TARGET_ID"; then
exit 5
fi
echo "[Harmony-Debug-Pipeline] Install: bm install signed HAP (may uninstall/reinstall if a prior install failed)"
echo "Pushing debug components and installing HAP..."
echo " - Device: $TARGET_ID"
# Install HAP (using temp directory)
......@@ -246,6 +251,7 @@ if echo "$INSTALL_OUTPUT" | grep -qE "failed"; then
sleep 5
fi
# ====================== [6. App Launch and Debug Mount] ======================
echo "[Harmony-Debug-Pipeline] Run: aa start -a $ABILITY_NAME -b $BUNDLE_NAME (DEBUG_MODE=$DEBUG_MODE; debug uses -D)"
echo -e "\033[33mLaunching app and starting debug listener...\033[0m"
"$HDC_BIN" -t "$TARGET_ID" shell rm -rf "$REMOTE_HAP_DIR"
sleep 1
......
@echo off
@echo off
rem Eazytec is pleased to support the open source community by making CPF-KMP-CMP available.
rem Copyright (C) 2026 Eazytec. All rights reserved.
rem
......@@ -34,26 +33,55 @@ set PLATFORM=
set TARGET_ID=
REM Parse options (supports options in any position, e.g. ohosArm64 62Q0226107024702 -m release)
REM NOTE: Do not use "goto" inside parenthesized IF blocks — cmd.exe may fail with
REM "The system cannot find the batch label specified - parse" and mis-handle -b/-a.
:parse
if "%~1"=="" goto done_parse
if "%~1"=="-m" (set "BUILD_MODE=%~2" & shift & shift & goto parse)
if "%~1"=="-b" (set "BUNDLE_NAME=%~2" & shift & shift & goto parse)
if "%~1"=="-a" (set "ABILITY_NAME=%~2" & shift & shift & goto parse)
if "%~1"=="-d" (set "DEBUG_MODE=%~2" & shift & shift & goto parse)
if "%~1"=="-p" (set "LOCAL_OHOS_PATH=%~2" & shift & shift & goto parse)
if "%~1"=="-h" goto show_help
if /i "%~1"=="-m" goto parse_m
if /i "%~1"=="-b" goto parse_b
if /i "%~1"=="-a" goto parse_a
if /i "%~1"=="-d" goto parse_d
if /i "%~1"=="-p" goto parse_p
if /i "%~1"=="-h" goto show_help
REM Positional: first=PLATFORM, second=TARGET_ID
if "!PLATFORM!"=="" (set "PLATFORM=%~1") else if "!TARGET_ID!"=="" (set "TARGET_ID=%~1")
shift
goto parse
:parse_m
set "BUILD_MODE=%~2"
shift
shift
goto parse
:parse_b
set "BUNDLE_NAME=%~2"
shift
shift
goto parse
:parse_a
set "ABILITY_NAME=%~2"
shift
shift
goto parse
:parse_d
set "DEBUG_MODE=%~2"
shift
shift
goto parse
:parse_p
set "LOCAL_OHOS_PATH=%~2"
shift
shift
goto parse
:done_parse
if "!PLATFORM!"=="" set "PLATFORM=%DEFAULT_PLATFORM%"
if "!TARGET_ID!"=="" set "TARGET_ID=%DEFAULT_TARGET_ID%"
REM 与 :composeApp:cleanHarmonyAppEntryBuildsAndNativeLibs 一致,清理 harmonyApp/entry 中间目录(脚本在仓库根目录)
call "%~dp0..\cleanHarmonyAppEntryBuildsAndNativeLibs.bat"
if errorlevel 1 exit /b %errorlevel%
REM Record script start time (epoch seconds for elapsed calculation)
for /f %%t in ('powershell -NoProfile -Command "[int][double]::Parse((Get-Date -UFormat '%%s'))"') do set START_TIME=%%t
......@@ -133,7 +161,9 @@ if not exist "%HDC_BIN%" (
)
"%HDC_BIN%" -t %TARGET_ID% shell aa force-stop %BUNDLE_NAME% 2>nul
echo [Harmony-Debug-Pipeline] Prep: hdc force-stop %BUNDLE_NAME% (ignore errors if not running)
REM ====================== Gradle Build ======================
echo [Harmony-Debug-Pipeline] Build: Gradle KMP publishBinariesToHarmonyApp (mode=%BUILD_MODE%; first run slower, later incremental)
echo Working path: %CD%
echo Building OpenHarmony (%PLATFORM%)...
......@@ -174,6 +204,7 @@ if "%PLATFORM%"=="ohosArm64" (
if errorlevel 1 exit /b %errorlevel%
echo [Harmony-Debug-Pipeline] Build: KMP publish finished — next ohpm/hvigor HAP (incremental builds may be faster)
REM SO packaging end time / HAP build start time
for /f %%t in ('powershell -NoProfile -Command "[int][double]::Parse((Get-Date -UFormat '%%s'))"') do set HAP_START_TIME=%%t
......@@ -204,6 +235,8 @@ if "%BUILD_MODE%"=="release" (
)
if errorlevel 1 (echo Hvigor build failed & exit /b 1)
echo [Harmony-Debug-Pipeline] Build: HAP assemble finished
REM ====================== Install HAP ======================
set "HAP_DIR=entry\build\default\outputs\default"
set "SIGNED_HAP=entry-default-signed.hap"
......@@ -226,6 +259,7 @@ if not defined DEVICE_FOUND (
exit /b 5
)
echo [Harmony-Debug-Pipeline] Install: bm install signed HAP (may uninstall/reinstall if a prior install failed)
echo Pushing and installing HAP...
echo - Device: %TARGET_ID%
set "REMOTE_HAP_DIR=/data/local/tmp/debug_install"
......@@ -243,6 +277,7 @@ if errorlevel 1 (
)
REM ====================== Launch App ======================
echo [Harmony-Debug-Pipeline] Run: aa start -a %ABILITY_NAME% -b %BUNDLE_NAME% (DEBUG_MODE=%DEBUG_MODE%; debug uses -D)
"%HDC_BIN%" -t %TARGET_ID% shell rm -rf %REMOTE_HAP_DIR%
timeout /t 1 /nobreak >nul
echo Launching app...
......@@ -264,6 +299,7 @@ echo.
echo App info:
echo - Bundle: %BUNDLE_NAME%
echo - Device: %TARGET_ID%
for /f %%t in ('powershell -NoProfile -Command "[int][double]::Parse((Get-Date -UFormat '%%s'))"') do set END_TIME=%%t
set /a ELAPSED=HAP_START_TIME-START_TIME
set /a MINUTES=ELAPSED/60
set /a SECONDS=ELAPSED%%60
......@@ -278,6 +314,8 @@ set /a SECONDS=ELAPSED%%60
echo - Total time: !MINUTES!m!SECONDS!s (!ELAPSED!s)
echo ------------------------------------------------------------
exit /b 0
:show_help
echo Usage: %~nx0 [options] [PLATFORM] [TARGET_ID]
echo.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment