SEMS-data-collection/run.ps1

71 lines
1.7 KiB
PowerShell
Raw Normal View History

Param($cmd)
#在 PowerShell 中将字符集修改为 UTF-8
$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
$Env:PATH = "C:\Program Files\Common Files\Pleora\eBUS SDK;" #开发光谱相机所必需的路径
$Env:PATH += "C:\Program Files\Git\cmd;C:\Windows\System32\OpenSSH;" #开发所需的git/ssh命令的路径
$Env:PATH += (Resolve-Path ../CompliteEnv/mingw64/bin).path + ";" #g++所在路径
$Env:PATH += (Resolve-Path ../CompliteEnv/CMake/bin).path + ";" #cmake所在路径
$Env:PATH += (Resolve-Path ./lib).path + ";" #本项目所需的动态链接库所在路径
Write-Host "PATH is set to $Env:PATH"
function Remove-Build-Dir {
If (Test-Path "build") {
#如果当前目录下build文件夹存在
Remove-Item -Path "build" -Recurse #递归阐述build文件夹
}
}
function ReBuild-Target {
# 编译生成Makefile
cmake -B build -G "MinGW Makefiles"
# 编译生成可执行程序
cmake --build build
}
function Run-All-Exe {
$exeFiles = Get-ChildItem -Path "build" -Filter *.exe
Write-Host "Exe Files: $exeFiles"
ForEach ($exeFile in $exeFiles) {
Write-Host "Processing file: $($exeFile.FullName)"
Start-Process -Wait -FilePath $exeFile.FullName -NoNewWindow -PassThru
}
}
If ($cmd -eq "b") {
Write-Host "Rebuilding all targets..."
Remove-Build-Dir
ReBuild-Target
Run-All-Exe
}
If ($cmd -eq "p") {
Write-Host "Packing all targets..."
cmake --build build --target package
}
If ([String]::IsNullOrEmpty($cmd)) {
#如果没有任何参数就运行所有exe
Run-All-Exe
}