Files
FlyShotHost/build/Copy-NativePlanningArtifacts.ps1
yunxiao.zhu 9c56ee825e ✨ feat(native-planning): 添加 Rust ICSP 原生规划核心及 C# 互操作集成
* 新增 Rust 原生 ICSP 规划库 (Cargo 项目, CubicSpline 算法, FFI 接口)
* 新增 Flyshot.Native.Planning C# 互操作项目 (P/Invoke 封装)
* 更新 ControllerClientCompat 适配新的规划接口
* 添加构建脚本 (Copy-NativePlanningArtifacts.ps1)
* 新增互操作测试及一致性对比测试
* 更新解决方案文件和设计文档
2026-06-26 15:41:01 +08:00

95 lines
3.5 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.

param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release",
[string[]]$DestinationDirectories = @()
)
$ErrorActionPreference = "Stop"
# 从脚本位置定位仓库根目录,确保从任意工作目录调用都得到一致结果。
$repositoryRoot = Split-Path -Parent $PSScriptRoot
$manifestPath = Join-Path $repositoryRoot "native/flyshot-native-planning/Cargo.toml"
$cargoExecutable = if ($IsWindows) { "cargo.exe" } else { "cargo" }
$cargoPath = Join-Path $HOME ".cargo/bin/$cargoExecutable"
if (-not (Test-Path -LiteralPath $cargoPath)) {
throw "未找到 Rust Cargo:$cargoPath。请先通过 rustup 安装 stable-x86_64-pc-windows-msvc。"
}
$cargoArguments = @("build", "--manifest-path", $manifestPath)
if ($Configuration -eq "Release") {
$cargoArguments += "--release"
}
if ($IsWindows) {
# Windows MSVC 目标必须在 VS C++ 开发者环境中运行,避免 PATH 中其他 link.exe 抢占。
$vswherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (-not (Test-Path -LiteralPath $vswherePath)) {
throw "未找到 vswhere.exe,无法定位 Visual Studio C++ Build Tools。"
}
$installationPath = & $vswherePath -latest -products * `
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
-property installationPath
if ([string]::IsNullOrWhiteSpace($installationPath)) {
throw "未找到已安装的 Visual Studio C++ x64 编译工具。"
}
$vcvarsPath = Join-Path $installationPath "VC/Auxiliary/Build/vcvars64.bat"
if (-not (Test-Path -LiteralPath $vcvarsPath)) {
throw "未找到 VS x64 开发者环境脚本:$vcvarsPath"
}
$quotedArguments = $cargoArguments | ForEach-Object { '"' + $_.Replace('"', '\"') + '"' }
$command = 'call "{0}" >nul && "{1}" {2}' -f `
$vcvarsPath, $cargoPath, ($quotedArguments -join " ")
& cmd.exe /d /c $command
if ($LASTEXITCODE -ne 0) {
throw "Rust 原生规划库构建失败,退出码:$LASTEXITCODE"
}
}
else {
& $cargoPath @cargoArguments
if ($LASTEXITCODE -ne 0) {
throw "Rust 原生规划库构建失败,退出码:$LASTEXITCODE"
}
}
$profileDirectory = if ($Configuration -eq "Release") { "release" } else { "debug" }
$libraryName = if ($IsWindows) {
"flyshot_native_planning.dll"
}
elseif ($IsLinux) {
"libflyshot_native_planning.so"
}
else {
throw "当前脚本仅支持 Windows x64 和 Linux x64。"
}
$sourcePath = Join-Path $repositoryRoot "native/flyshot-native-planning/target/$profileDirectory/$libraryName"
if (-not (Test-Path -LiteralPath $sourcePath)) {
throw "Rust 构建已结束,但未找到原生库:$sourcePath"
}
# 未显式指定目标时,默认复制到对应配置的 Core 测试输出目录。
if ($DestinationDirectories.Count -eq 0) {
$DestinationDirectories = @(
(Join-Path $repositoryRoot "tests/Flyshot.Core.Tests/bin/$Configuration/net8.0")
)
}
foreach ($destinationDirectory in $DestinationDirectories) {
$destinationPath = if ([System.IO.Path]::IsPathRooted($destinationDirectory)) {
$destinationDirectory
}
else {
Join-Path $repositoryRoot $destinationDirectory
}
$resolvedDestination = [System.IO.Path]::GetFullPath(
$destinationPath)
New-Item -ItemType Directory -Force -Path $resolvedDestination | Out-Null
Copy-Item -LiteralPath $sourcePath `
-Destination (Join-Path $resolvedDestination $libraryName) `
-Force
Write-Host "已复制原生规划库到:$resolvedDestination"
}