Commit e75c24a8 authored by qq_38816927's avatar qq_38816927

更新win脚本

parent cfad96f8
@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
...@@ -33,57 +34,24 @@ set PLATFORM= ...@@ -33,57 +34,24 @@ 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 /i "%~1"=="-m" goto parse_m if "%~1"=="-m" (set "BUILD_MODE=%~2" & shift & shift & goto parse)
if /i "%~1"=="-b" goto parse_b if "%~1"=="-b" (set "BUNDLE_NAME=%~2" & shift & shift & goto parse)
if /i "%~1"=="-a" goto parse_a if "%~1"=="-a" (set "ABILITY_NAME=%~2" & shift & shift & goto parse)
if /i "%~1"=="-d" goto parse_d if "%~1"=="-d" (set "DEBUG_MODE=%~2" & shift & shift & goto parse)
if /i "%~1"=="-p" goto parse_p if "%~1"=="-p" (set "LOCAL_OHOS_PATH=%~2" & shift & shift & goto parse)
if /i "%~1"=="-h" goto show_help if "%~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 Record script start time (epoch seconds for elapsed calculation) REM Record script start time (epoch seconds for elapsed calculation)
for /f "usebackq tokens=*" %%t in (`powershell -NoProfile -Command "[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()"`) do set START_TIME=%%t for /f %%t in ('powershell -NoProfile -Command "[int][double]::Parse((Get-Date -UFormat '%%s'))"') do set START_TIME=%%t
echo Run environment configuration: echo Run environment configuration:
echo - Platform: %PLATFORM% echo - Platform: %PLATFORM%
...@@ -112,15 +80,12 @@ echo Checking environment configuration... ...@@ -112,15 +80,12 @@ echo Checking environment configuration...
set "MIN_VERSION=6.0.0" set "MIN_VERSION=6.0.0"
set "PRODUCT_INFO=%DEVECO_PATH%\product-info.json" set "PRODUCT_INFO=%DEVECO_PATH%\product-info.json"
REM Read version without "(expr).prop" in PowerShell: a closing ")" inside in ('...') breaks cmd parsing.
set "CURRENT_VERSION="
if exist "%PRODUCT_INFO%" ( if exist "%PRODUCT_INFO%" (
for /f "usebackq tokens=*" %%v in (`powershell -NoProfile -Command "Get-Content -LiteralPath '%PRODUCT_INFO%' ^| ConvertFrom-Json ^| Select-Object -ExpandProperty version"`) do set "CURRENT_VERSION=%%v" for /f "tokens=*" %%v in ('powershell -NoProfile -Command "(Get-Content '%PRODUCT_INFO%' | ConvertFrom-Json).version"') do set "CURRENT_VERSION=%%v"
) else ( ) else (
echo Warning: product-info.json not found, skipping version check. echo Warning: product-info.json not found, skipping version check.
set "CURRENT_VERSION=unknown" set "CURRENT_VERSION=unknown"
) )
if "!CURRENT_VERSION!"=="" set "CURRENT_VERSION=unknown"
if not "%CURRENT_VERSION%"=="unknown" ( if not "%CURRENT_VERSION%"=="unknown" (
echo Current DevEco version: %CURRENT_VERSION% echo Current DevEco version: %CURRENT_VERSION%
...@@ -207,9 +172,9 @@ if "%PLATFORM%"=="ohosArm64" ( ...@@ -207,9 +172,9 @@ 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) 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 "usebackq tokens=*" %%t in (`powershell -NoProfile -Command "[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()"`) 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
REM ====================== HAP build ====================== REM ====================== HAP build ======================
if not "%LOCAL_OHOS_PATH%"=="" ( if not "%LOCAL_OHOS_PATH%"=="" (
...@@ -302,7 +267,6 @@ echo. ...@@ -302,7 +267,6 @@ 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 "usebackq tokens=*" %%t in (`powershell -NoProfile -Command "[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()"`) 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
...@@ -317,8 +281,6 @@ set /a SECONDS=ELAPSED%%60 ...@@ -317,8 +281,6 @@ 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