初始化项目

This commit is contained in:
2026-10-19 00:11:38 +08:00
commit 9545e48e4d
150 changed files with 9559 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
<#
build-hap.ps1 - 命令行构建 HAP(CI 与本地通用)
用法:
powershell -ExecutionPolicy Bypass -File ci\build-hap.ps1 [-BuildMode debug|release] [-Product default] [-SdkHome <SDK 路径>] [-DryRun]
说明:
- 只封装 hvigorw 调用与产物定位,签名由 CI 的独立步骤完成(见 ci/README.md);
- -DryRun 只打印将要执行的命令,不触发构建(用于自检与流水线 dry-run)。
#>
param(
[ValidateSet('debug', 'release')][string]$BuildMode = 'debug',
[string]$Product = 'default',
[string]$SdkHome = 'D:\env\huawei\command-line-tools\sdk',
[switch]$DryRun
)
$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path -Parent $PSScriptRoot
if (-not (Test-Path (Join-Path $projectRoot 'hvigorfile.ts'))) {
throw "未找到工程根目录(缺少 hvigorfile.ts): $projectRoot"
}
if (-not (Test-Path $SdkHome)) {
throw "SDK 路径不存在: $SdkHome"
}
$env:DEVECO_SDK_HOME = $SdkHome
$hvArgs = @(
'assembleHap',
'--mode', 'module',
'-p', "product=$Product",
'-p', "buildMode=$BuildMode",
'--no-daemon'
)
if ($DryRun) {
Write-Output ("PROJECT: " + $projectRoot)
Write-Output ("SDK: " + $SdkHome)
Write-Output ("DRYRUN: hvigorw " + ($hvArgs -join ' '))
return
}
Push-Location $projectRoot
try {
& hvigorw @hvArgs
if ($LASTEXITCODE -ne 0) {
throw "hvigorw 构建失败,退出码 $LASTEXITCODE"
}
}
finally {
Pop-Location
}
$outDir = Join-Path $projectRoot ("entry\build\" + $Product + "\outputs\" + $Product)
$hap = Get-ChildItem $outDir -Filter '*.hap' -ErrorAction SilentlyContinue |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if ($null -eq $hap) {
throw "未找到 HAP 产物: $outDir"
}
Write-Output ("ARTIFACT: " + $hap.FullName)
Write-Output ("SIZE: " + $hap.Length)