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" ...@@ -138,8 +138,10 @@ HDC_BIN="$DEVECO_HOME/sdk/default/openharmony/toolchains/hdc"
export DEVECO_SDK_HOME="$DEVECO_HOME/sdk" 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" 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 "$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] ====================== # ====================== [3. Gradle Build] ======================
echo "[Harmony-Debug-Pipeline] Build: Gradle KMP publishBinariesToHarmonyApp (mode=$BUILD_MODE; first run slower, later incremental)"
echo "Working path: $(pwd)" echo "Working path: $(pwd)"
echo "Building OpenHarmony ARM64..." echo "Building OpenHarmony ARM64..."
if [ "$PLATFORM" = "ohosArm64" ]; then if [ "$PLATFORM" = "ohosArm64" ]; then
...@@ -168,6 +170,7 @@ else ...@@ -168,6 +170,7 @@ else
echo -e "\033[31mError: Unsupported platform '$PLATFORM'\033[0m" echo -e "\033[31mError: Unsupported platform '$PLATFORM'\033[0m"
exit 4 exit 4
fi fi
echo "[Harmony-Debug-Pipeline] Build: KMP publish finished — next ohpm/hvigor HAP (incremental builds may be faster)"
# SO packaging end time # SO packaging end time
HAP_START_TIME=$(date +%s) HAP_START_TIME=$(date +%s)
# --- Subsequent install logic (hdc install etc.) --- # --- Subsequent install logic (hdc install etc.) ---
...@@ -194,6 +197,7 @@ if [ "$BUILD_MODE" = "release" ]; then ...@@ -194,6 +197,7 @@ if [ "$BUILD_MODE" = "release" ]; then
else 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 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 fi
echo "[Harmony-Debug-Pipeline] Build: HAP assemble finished"
# ====================== [5. Install and Push Debug Components] ====================== # ====================== [5. Install and Push Debug Components] ======================
AVAILABLE_TARGETS=$("$HDC_BIN" list targets) AVAILABLE_TARGETS=$("$HDC_BIN" list targets)
...@@ -227,6 +231,7 @@ if ! echo "$AVAILABLE_TARGETS" | grep -q "$TARGET_ID"; then ...@@ -227,6 +231,7 @@ if ! echo "$AVAILABLE_TARGETS" | grep -q "$TARGET_ID"; then
exit 5 exit 5
fi 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 "Pushing debug components and installing HAP..."
echo " - Device: $TARGET_ID" echo " - Device: $TARGET_ID"
# Install HAP (using temp directory) # Install HAP (using temp directory)
...@@ -246,6 +251,7 @@ if echo "$INSTALL_OUTPUT" | grep -qE "failed"; then ...@@ -246,6 +251,7 @@ if echo "$INSTALL_OUTPUT" | grep -qE "failed"; then
sleep 5 sleep 5
fi fi
# ====================== [6. App Launch and Debug Mount] ====================== # ====================== [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" echo -e "\033[33mLaunching app and starting debug listener...\033[0m"
"$HDC_BIN" -t "$TARGET_ID" shell rm -rf "$REMOTE_HAP_DIR" "$HDC_BIN" -t "$TARGET_ID" shell rm -rf "$REMOTE_HAP_DIR"
sleep 1 sleep 1
......
@echo off @echo off
@echo off
rem Eazytec is pleased to support the open source community by making CPF-KMP-CMP available. 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 Copyright (C) 2026 Eazytec. All rights reserved.
rem rem
...@@ -34,26 +33,55 @@ set PLATFORM= ...@@ -34,26 +33,55 @@ set PLATFORM=
set TARGET_ID= set TARGET_ID=
REM Parse options (supports options in any position, e.g. ohosArm64 62Q0226107024702 -m release) 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 :parse
if "%~1"=="" goto done_parse if "%~1"=="" goto done_parse
if "%~1"=="-m" (set "BUILD_MODE=%~2" & shift & shift & goto parse) if /i "%~1"=="-m" goto parse_m
if "%~1"=="-b" (set "BUNDLE_NAME=%~2" & shift & shift & goto parse) if /i "%~1"=="-b" goto parse_b
if "%~1"=="-a" (set "ABILITY_NAME=%~2" & shift & shift & goto parse) if /i "%~1"=="-a" goto parse_a
if "%~1"=="-d" (set "DEBUG_MODE=%~2" & shift & shift & goto parse) if /i "%~1"=="-d" goto parse_d
if "%~1"=="-p" (set "LOCAL_OHOS_PATH=%~2" & shift & shift & goto parse) if /i "%~1"=="-p" goto parse_p
if "%~1"=="-h" goto show_help if /i "%~1"=="-h" goto show_help
REM Positional: first=PLATFORM, second=TARGET_ID REM Positional: first=PLATFORM, second=TARGET_ID
if "!PLATFORM!"=="" (set "PLATFORM=%~1") else if "!TARGET_ID!"=="" (set "TARGET_ID=%~1") if "!PLATFORM!"=="" (set "PLATFORM=%~1") else if "!TARGET_ID!"=="" (set "TARGET_ID=%~1")
shift shift
goto parse 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 :done_parse
if "!PLATFORM!"=="" set "PLATFORM=%DEFAULT_PLATFORM%" if "!PLATFORM!"=="" set "PLATFORM=%DEFAULT_PLATFORM%"
if "!TARGET_ID!"=="" set "TARGET_ID=%DEFAULT_TARGET_ID%" 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) 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 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%" ( ...@@ -133,7 +161,9 @@ if not exist "%HDC_BIN%" (
) )
"%HDC_BIN%" -t %TARGET_ID% shell aa force-stop %BUNDLE_NAME% 2>nul "%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 ====================== REM ====================== Gradle Build ======================
echo [Harmony-Debug-Pipeline] Build: Gradle KMP publishBinariesToHarmonyApp (mode=%BUILD_MODE%; first run slower, later incremental)
echo Working path: %CD% echo Working path: %CD%
echo Building OpenHarmony (%PLATFORM%)... echo Building OpenHarmony (%PLATFORM%)...
...@@ -174,6 +204,7 @@ if "%PLATFORM%"=="ohosArm64" ( ...@@ -174,6 +204,7 @@ if "%PLATFORM%"=="ohosArm64" (
if errorlevel 1 exit /b %errorlevel% 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 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 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" ( ...@@ -204,6 +235,8 @@ if "%BUILD_MODE%"=="release" (
) )
if errorlevel 1 (echo Hvigor build failed & exit /b 1) if errorlevel 1 (echo Hvigor build failed & exit /b 1)
echo [Harmony-Debug-Pipeline] Build: HAP assemble finished
REM ====================== Install HAP ====================== REM ====================== Install HAP ======================
set "HAP_DIR=entry\build\default\outputs\default" set "HAP_DIR=entry\build\default\outputs\default"
set "SIGNED_HAP=entry-default-signed.hap" set "SIGNED_HAP=entry-default-signed.hap"
...@@ -226,6 +259,7 @@ if not defined DEVICE_FOUND ( ...@@ -226,6 +259,7 @@ if not defined DEVICE_FOUND (
exit /b 5 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 Pushing and installing HAP...
echo - Device: %TARGET_ID% echo - Device: %TARGET_ID%
set "REMOTE_HAP_DIR=/data/local/tmp/debug_install" set "REMOTE_HAP_DIR=/data/local/tmp/debug_install"
...@@ -243,6 +277,7 @@ if errorlevel 1 ( ...@@ -243,6 +277,7 @@ if errorlevel 1 (
) )
REM ====================== Launch App ====================== 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% "%HDC_BIN%" -t %TARGET_ID% shell rm -rf %REMOTE_HAP_DIR%
timeout /t 1 /nobreak >nul timeout /t 1 /nobreak >nul
echo Launching app... echo Launching app...
...@@ -264,6 +299,7 @@ echo. ...@@ -264,6 +299,7 @@ echo.
echo App info: echo App info:
echo - Bundle: %BUNDLE_NAME% echo - Bundle: %BUNDLE_NAME%
echo - Device: %TARGET_ID% 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 ELAPSED=HAP_START_TIME-START_TIME
set /a MINUTES=ELAPSED/60 set /a MINUTES=ELAPSED/60
set /a SECONDS=ELAPSED%%60 set /a SECONDS=ELAPSED%%60
...@@ -278,6 +314,8 @@ set /a SECONDS=ELAPSED%%60 ...@@ -278,6 +314,8 @@ set /a SECONDS=ELAPSED%%60
echo - Total time: !MINUTES!m!SECONDS!s (!ELAPSED!s) echo - Total time: !MINUTES!m!SECONDS!s (!ELAPSED!s)
echo ------------------------------------------------------------ echo ------------------------------------------------------------
exit /b 0
:show_help :show_help
echo Usage: %~nx0 [options] [PLATFORM] [TARGET_ID] echo Usage: %~nx0 [options] [PLATFORM] [TARGET_ID]
echo. 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