`armor/` 是它的 Rust 改写版,这一份留着当参考:ADC 阈值的 2000 就是从它标定出来的 (`.env.example` 里那句 "same as the reference firmware" 指的就是它),而且它的 README 记着实测设备与 MAC,换硬件时是有用的现场记录。 只收了 20 个源文件。它自带的 `.gitignore` 已经排掉 `build/`(211 MB 的 ESP-IDF 构建产物) 与生成的 `sdkconfig`,所以仓库里不会多出这些东西。 两处顺带处理: - `reference/armor/.git` 是一个**空的**仓库壳(`git init` 过,零提交、零 remote、零 ref), 而外层 git 正因为它的存在而拒绝索引 `reference/` 下的任何文件 (`error: 'reference/armor/' does not have a commit checked out`)。它被挪到 `desktop/.dev/backup/reference-armor-git`(可逆,且该目录已被忽略),不是删除。 - 它的 README 指着 `../armor-platformio-backup/`,那份备份并不存在。改成明说"没有进仓库", 免得以后有人照着找一个不存在的目录。 另外把 `/docs/` 加进 .gitignore:那是工作区里另起的一个 Astro 文档站,与本仓库无关。
84 lines
3.3 KiB
PowerShell
84 lines
3.3 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Run idf.py for this project with a local ESP-IDF environment activated.
|
|
|
|
.DESCRIPTION
|
|
Activates ESP-IDF (located through the Espressif Installation Manager's
|
|
eim_idf.json, unless IDF_PATH is already set) and forwards every remaining
|
|
argument to idf.py.
|
|
|
|
Non-ASCII project path workaround
|
|
---------------------------------
|
|
ESP-IDF v6.1 rewrites the compiler's "-specs=..." flag from
|
|
components/esp_libc/project_include.cmake through CMake's file(STRINGS),
|
|
which silently drops every non-ASCII byte. When this project lives under a
|
|
path containing non-ASCII characters (e.g. "D:\宣筹\..."), the rewritten
|
|
flag points at a nonexistent file and every compile fails with:
|
|
|
|
riscv32-esp-elf-gcc.exe: fatal error: cannot read spec file ...
|
|
|
|
This script detects that case and builds out-of-tree into an ASCII build
|
|
directory instead, which keeps the flag (and every generated path) ASCII.
|
|
Override the location with the IDF_BUILD_DIR environment variable.
|
|
|
|
.EXAMPLE
|
|
.\idf.ps1 build
|
|
.\idf.ps1 menuconfig
|
|
.\idf.ps1 -p COM9 flash monitor
|
|
.\idf.ps1 erase-flash
|
|
#>
|
|
# NOTE: deliberately no param() block. An advanced/declared parameter list makes
|
|
# PowerShell try to bind idf.py's own short options to its common parameters
|
|
# ("-p" is ambiguous with -ProgressAction / -PipelineVariable). A simple script
|
|
# passes every unbound token through $args verbatim.
|
|
$IdfArgs = @($args)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
function Find-IdfActivation {
|
|
$candidates = @(
|
|
(Join-Path $env:USERPROFILE '.espressif\eim_idf.json'),
|
|
'C:\Espressif\tools\eim_idf.json',
|
|
(Join-Path $env:LOCALAPPDATA 'Espressif\eim_idf.json')
|
|
)
|
|
foreach ($path in $candidates) {
|
|
if (-not (Test-Path $path)) { continue }
|
|
$cfg = Get-Content $path -Raw | ConvertFrom-Json
|
|
$installed = $cfg.idfInstalled | Where-Object { $_.id -eq $cfg.idfSelectedId } | Select-Object -First 1
|
|
if (-not $installed) { $installed = $cfg.idfInstalled | Select-Object -First 1 }
|
|
if ($installed -and (Test-Path $installed.activationScript)) {
|
|
return $installed.activationScript
|
|
}
|
|
}
|
|
return $null
|
|
}
|
|
|
|
if (-not $env:IDF_PATH) {
|
|
$activation = Find-IdfActivation
|
|
if (-not $activation) {
|
|
throw 'ESP-IDF not found. Activate your ESP-IDF environment first (export.ps1 / eim).'
|
|
}
|
|
. $activation *> $null
|
|
}
|
|
|
|
if (-not $IdfArgs -or $IdfArgs.Count -eq 0) { $IdfArgs = @('build') }
|
|
|
|
# --- non-ASCII project path workaround -------------------------------------
|
|
$projectDir = if ($PSScriptRoot) { $PSScriptRoot } else { (Get-Location).Path }
|
|
$userPickedBuildDir = $IdfArgs -contains '-B' -or $IdfArgs -contains '--build-dir'
|
|
|
|
if ($projectDir -notmatch '^[\x20-\x7E]+$' -and -not $userPickedBuildDir) {
|
|
if ($env:IDF_BUILD_DIR) {
|
|
$buildDir = $env:IDF_BUILD_DIR
|
|
} else {
|
|
$qualifier = Split-Path -Qualifier $projectDir # e.g. "D:"
|
|
$buildDir = Join-Path $qualifier 'esp-idf-build\armor'
|
|
}
|
|
Write-Host "Non-ASCII project path detected; building out-of-tree in '$buildDir'." -ForegroundColor Yellow
|
|
Write-Host 'Set IDF_BUILD_DIR to use a different build directory.' -ForegroundColor Yellow
|
|
$IdfArgs = @('-B', $buildDir) + $IdfArgs
|
|
}
|
|
|
|
& idf.py @IdfArgs
|
|
exit $LASTEXITCODE
|