* 将 Rust ICSP 原生库名称更改为 `flyshot_planning`,更新相关引用。 * 修改构建脚本以支持新的库名称,并确保库文件复制到正确的目录。 * 添加对 Rust ICSP 原生库的依赖检查,确保发布时包含必要的库文件。 * 更新测试项目以加载新的原生库,确保兼容性和功能完整性。
77 lines
2.7 KiB
PowerShell
77 lines
2.7 KiB
PowerShell
<#
|
||
.SYNOPSIS
|
||
构建 Rust ICSP 原生规划库并复制到 src/Libs 与可选目标目录。
|
||
|
||
.DESCRIPTION
|
||
在 Windows x64 上通过 cargo release 构建 flyshot_planning,默认写入
|
||
src/Libs/flyshot_planning.dll;Linux x64 写入 src/Libs/libflyshot_planning.so。
|
||
可通过 -DestinationDirectories 额外复制到测试或发布输出目录。
|
||
|
||
.PARAMETER Configuration
|
||
传递给 dotnet 相关路径的构建配置名,默认 Release。
|
||
|
||
.PARAMETER DestinationDirectories
|
||
除 src/Libs 外需要覆盖复制的额外目标目录列表。
|
||
#>
|
||
|
||
[CmdletBinding()]
|
||
param(
|
||
[ValidateSet('Debug', 'Release')]
|
||
[string]$Configuration = 'Release',
|
||
|
||
[string[]]$DestinationDirectories = @()
|
||
)
|
||
|
||
$ErrorActionPreference = 'Stop'
|
||
Set-StrictMode -Version Latest
|
||
|
||
$repositoryRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||
$cargoManifest = Join-Path $repositoryRoot 'native\flyshot-native-planning\Cargo.toml'
|
||
$libsDirectory = Join-Path $repositoryRoot 'src\Libs'
|
||
$cargoProfile = if ($Configuration -eq 'Debug') { 'debug' } else { 'release' }
|
||
$targetDirectory = Join-Path $repositoryRoot "native\flyshot-native-planning\target\$cargoProfile"
|
||
|
||
if ($IsLinux -or (-not $IsWindows -and -not $IsMacOS))
|
||
{
|
||
$artifactFileName = 'libflyshot_planning.so'
|
||
}
|
||
else
|
||
{
|
||
$artifactFileName = 'flyshot_planning.dll'
|
||
}
|
||
|
||
$builtArtifactPath = Join-Path $targetDirectory $artifactFileName
|
||
$libsArtifactPath = Join-Path $libsDirectory $artifactFileName
|
||
|
||
Write-Host "正在构建 Rust 原生规划库 ($Configuration) ..."
|
||
& cargo build --manifest-path $cargoManifest --$Configuration
|
||
if ($LASTEXITCODE -ne 0)
|
||
{
|
||
throw "cargo build 失败,退出码:$LASTEXITCODE"
|
||
}
|
||
|
||
if (-not (Test-Path -LiteralPath $builtArtifactPath -PathType Leaf))
|
||
{
|
||
throw "未找到构建产物:$builtArtifactPath"
|
||
}
|
||
|
||
New-Item -ItemType Directory -Path $libsDirectory -Force | Out-Null
|
||
Copy-Item -LiteralPath $builtArtifactPath -Destination $libsArtifactPath -Force
|
||
Write-Host "已复制到:$libsArtifactPath"
|
||
|
||
$defaultTestOutput = Join-Path $repositoryRoot "tests\Flyshot.Core.Tests\bin\$Configuration\net8.0"
|
||
$allDestinations = @($DestinationDirectories) + @($defaultTestOutput)
|
||
|
||
foreach ($destination in $allDestinations | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | Select-Object -Unique)
|
||
{
|
||
$absoluteDestination = [System.IO.Path]::GetFullPath($destination)
|
||
if (-not (Test-Path -LiteralPath $absoluteDestination -PathType Container))
|
||
{
|
||
Write-Host "跳过不存在的目标目录:$absoluteDestination"
|
||
continue
|
||
}
|
||
|
||
Copy-Item -LiteralPath $builtArtifactPath -Destination (Join-Path $absoluteDestination $artifactFileName) -Force
|
||
Write-Host "已复制到:$absoluteDestination\$artifactFileName"
|
||
}
|