Files
simba-rmic-2026/vt/scripts/build.ps1
T
sloray f7ca246b68
构建客户端 / 检查(类型 + 单元测试) (push) Canceled after 0s
构建客户端 / Linux x64(deb + AppImage) (push) Canceled after 0s
构建客户端 / Windows x64(NSIS 安装包) (push) Canceled after 0s
构建客户端 / macOS 通用(.app + .dmg) (push) Canceled after 0s
feat(match): 同步比赛计时与装甲板扣血许可
- feat(client): 增加裁判比赛计时、技术暂停与选手端局域网同步
- feat(armor): 红蓝共用通用固件,按客户端选队并显示网络连接状态
- feat(armor): 仅在对局进行中允许扣血,其他阶段保留受击闪烁
- feat(client): 将计时置于血条中间并增加开赛前五秒全屏动画
- fix(client): 修复连续血条、对手镜像和图传断连灰度遮罩
- fix(client): 统一界面中文字体并整理各页面文案
- fix(maintenance): 备份迁移装甲板分区,恢复 SDK 构建与固件打包
- refactor(repo): 按 armor、vt 和 client 整理工程与脚本,移除旧参考实现
- test: 补充线路、受击许可、回环 UDP、维护和 HUD 验证
- docs: 同步构建、协议、比赛控制和硬件验证边界

验证:前端构建与 19 项相关测试通过;核心 91 项单元测试与 2 项回环 UDP 集成测试通过;装甲板规则 25 项、线路 26 项、Tauri 51 项测试通过;独立探测器 5 项与目录回归 4 项通过。完成 C3 两组阈值实际编译、导出与 ZIP 校验,检查 900×600 / 1280×720 页面、倒计时和随包中文字体。
未执行烧录、板上运行、跨电脑广播或硬件稳定性验证。
2026-10-22 17:08:49 +08:00

102 lines
4.9 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Build the ESP32-S3 firmware from PowerShell without executing .env as code.
[CmdletBinding()]
param(
[string]$EnvFile = '.env',
[switch]$Package,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$CargoArgs = @()
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
Push-Location (Split-Path -Parent $PSScriptRoot)
$buildEnvironment = @{}
foreach ($name in @('CARGO_WORKSPACE_DIR', 'ESP_IDF_GLOB_BASE', 'ESP_IDF_GLOB_PARTITIONS')) {
$buildEnvironment[$name] = [Environment]::GetEnvironmentVariable($name, 'Process')
}
try {
if (Test-Path -LiteralPath $EnvFile) {
$lineNumber = 0
foreach ($line in Get-Content -LiteralPath $EnvFile -Encoding UTF8) {
$lineNumber++
if ($line -match '^\s*(#|$)') { continue }
if ($line -notmatch '^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$') {
throw "Invalid assignment in ${EnvFile}:${lineNumber}"
}
$key = $Matches[1]
$value = $Matches[2].Trim()
if ($value.StartsWith("'") -or $value.StartsWith('"')) {
$quote = $value.Substring(0, 1)
if ($value.Length -lt 2 -or -not $value.EndsWith($quote)) {
throw "Unclosed quote in ${EnvFile}:${lineNumber}"
}
$value = $value.Substring(1, $value.Length - 2)
} else {
$value = ($value -replace '\s+#.*$', '').TrimEnd()
}
[Environment]::SetEnvironmentVariable($key, $value, 'Process')
}
}
if ([string]::IsNullOrWhiteSpace($env:WIFI_SSID) -or $env:WIFI_SSID -eq 'your-ssid') {
throw 'Set WIFI_SSID in .env (copy .env.example) or the environment before building.'
}
if ($null -eq $env:WIFI_PASS) { $env:WIFI_PASS = '' }
# bindgen 要加载 esp-clang 自带的 libclang.dll,而它依赖**同目录**的 libLLVM-21.dll、
# libclang-cpp.dll 等。LoadLibraryEx 默认不会去 DLL 自己的目录找依赖,所以必须把这个
# 目录放进 PATH,否则报的是一句毫不相干的话:
# Unable to find libclang: "...\libclang.dll could not be opened: LoadLibraryExW failed"
# (`espup` 的 shell 会替你导出这些变量,直接跑脚本的人不会。)
$espClang = Join-Path $env:USERPROFILE '.rustup\toolchains\esp-1.97.0.0\xtensa-esp32-elf-clang\esp-clang\bin'
if (Test-Path -LiteralPath (Join-Path $espClang 'libclang.dll')) {
$env:LIBCLANG_PATH = $espClang
# An existing entry can be behind another LLVM installation. Move it
# to the front so libclang-cpp.dll and the runtime match libclang.dll.
$otherPaths = @($env:PATH -split ';' | Where-Object { $_ -ne $espClang })
$env:PATH = (@($espClang) + $otherPaths) -join ';'
}
$env:CARGO_WORKSPACE_DIR = (Get-Location).Path
$env:ESP_IDF_GLOB_BASE = (Get-Location).Path
$env:ESP_IDF_GLOB_PARTITIONS = 'partitions.csv'
$firmwareElf = $null
if ($Package) {
# Use Cargo's actual artifact path, including --target-dir / --config
# overrides, rather than guessing where this build wrote its ELF.
& cargo build --release --locked --message-format=json-render-diagnostics @CargoArgs | ForEach-Object {
$message = $_ | ConvertFrom-Json
if ($message.reason -eq 'compiler-artifact' -and $message.target.name -eq 'esp32' -and $message.executable) {
$firmwareElf = $message.executable
}
}
} else {
& cargo build --release --locked @CargoArgs
}
if ($LASTEXITCODE -ne 0) { throw "cargo build failed (exit $LASTEXITCODE)." }
if ($Package) {
if (-not $firmwareElf) { throw 'Cargo did not report the esp32 firmware ELF; refusing to package old images.' }
$python = Get-Command python -ErrorAction SilentlyContinue
if ($null -eq $python) {
throw '-Package requires Python 3 on PATH (used by scripts/package_firmware.py).'
}
# 固件包的版本号与客户端同源:都读仓库根的 version.json(由 scripts/version.mjs
# 从 git 历史算出)。不传的话 make_bundle.py 会退回 BUILD-INFO.json 里的
# 变体名+提交号,那是另一套编号,装到客户端里会与界面上的版本对不上。
$versionArgs = @()
if (Test-Path -LiteralPath '../version.json') {
$info = Get-Content -LiteralPath '../version.json' -Raw | ConvertFrom-Json
$versionArgs = @('--version', "v$($info.version)+$($info.build)")
}
& python scripts/package_firmware.py --firmware target/firmware --elf $firmwareElf --name 'RMIC 图传固件' @versionArgs
if ($LASTEXITCODE -ne 0) { throw "package_firmware.py failed (exit $LASTEXITCODE)." }
}
} finally {
foreach ($name in $buildEnvironment.Keys) {
[Environment]::SetEnvironmentVariable($name, $buildEnvironment[$name], 'Process')
}
Pop-Location
}