# 在 module_test 内部创建两个 ASCII junction,供 Keil 工程引用 底盘/云台 的 # 同一份源码与参数: # module_test/refs/chassis -> ../../底盘 # module_test/refs/gimbal -> ../../云台 # # 背景:µVision 对含中文的 include/源文件路径支持不稳定(本机实测报 file not found), # 因此工程里统一使用 ASCII 路径 ..\refs\chassis\... / ..\refs\gimbal\...。 # junction 指向真实目录,保证"同一个文件",不会出现副本漂移; # 同时 Simba-OmniInfantry 根目录只保留 底盘/云台/module_test 三个源码目录。 # # 使用:在 PowerShell 中执行(无需管理员权限,同卷 junction 可创建) # powershell -ExecutionPolicy Bypass -File tools\link_algo.ps1 $ErrorActionPreference = 'Stop' $moduleTest = Split-Path -Parent $PSScriptRoot # ...\module_test $simba = Split-Path -Parent $moduleTest # ...\Simba-OmniInfantry $refs = Join-Path $moduleTest 'refs' if (-not (Test-Path $refs)) { New-Item -ItemType Directory -Path $refs | Out-Null } $pairs = @( @{ Link = 'chassis'; Target = '底盘' }, @{ Link = 'gimbal'; Target = '云台' } ) foreach ($p in $pairs) { $link = Join-Path $refs $p.Link $target = Join-Path $simba $p.Target if (-not (Test-Path $target)) { throw "找不到目录: $target" } if (Test-Path $link) { $item = Get-Item $link -Force if ($item.LinkType -eq 'Junction') { Write-Host "junction 已存在: $link -> $($item.Target)" continue } throw "$link 已存在且不是 junction,请先手动处理" } New-Item -ItemType Junction -Path $link -Target $target | Out-Null Write-Host "已创建 junction: $link -> $target" }