first
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
# ============================================================
|
||||
# Windows 自包含打包(MinGW + Qt6 + ffmpeg)
|
||||
# 用法(PowerShell):
|
||||
# ./packaging/build-win.ps1 -QtPrefix "E:\QT6.6.3\6.6.3\mingw_64" `
|
||||
# -MinGwBin "E:\QT6.6.3\Tools\mingw1120_64\bin" `
|
||||
# -Ffmpeg "C:\path\ffmpeg.exe" `
|
||||
# -DepsPrefix "C:\path\deps-prefix" `
|
||||
# -DevourerSrc "C:\path\devourer" # 可选,离线构建用
|
||||
# 产物: dist/fpv-relay-win-x64/ (含 exe + Qt + ffmpeg + 依赖,双击 run-gui.bat 即用)
|
||||
#
|
||||
# 前置:本机已装 libusb-1.0 / libsodium(MinGW) 到 -DepsPrefix(含 include/lib/bin),
|
||||
# 且 pkg-config 可用(devourer 的 CMake 需要)。
|
||||
# ============================================================
|
||||
param(
|
||||
[string]$QtPrefix = $env:QT_PREFIX,
|
||||
[string]$MinGwBin = $env:MINGW_BIN,
|
||||
[string]$Ffmpeg = $env:FFMPEG_EXE,
|
||||
[string]$DepsPrefix = $env:FPV_DEPS_PREFIX,
|
||||
[string]$DevourerSrc = $env:DEVOURER_SRC,
|
||||
[string]$BuildDir = "build-win-gui"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Repo = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $Repo
|
||||
|
||||
if (-not $QtPrefix) { throw "需要 -QtPrefix(Qt 安装目录,如 E:\QT6.6.3\6.6.3\mingw_64)" }
|
||||
if (-not $MinGwBin) { throw "需要 -MinGwBin(MinGW bin 目录)" }
|
||||
if (-not $Ffmpeg) { throw "需要 -Ffmpeg(静态 ffmpeg.exe 路径)" }
|
||||
if (-not $DepsPrefix) { throw "需要 -DepsPrefix(含 libusb/libsodium 的 include/lib/bin)" }
|
||||
|
||||
$env:PATH = "$MinGwBin;$QtPrefix\bin;$DepsPrefix\bin;$env:PATH"
|
||||
if (-not $env:PKG_CONFIG_PATH) { $env:PKG_CONFIG_PATH = "$DepsPrefix\lib\pkgconfig" }
|
||||
|
||||
# ---- 构建 ----
|
||||
$cmakeArgs = @(
|
||||
"-S", $Repo, "-B", (Join-Path $Repo $BuildDir), "-G", "Ninja",
|
||||
"-DCMAKE_BUILD_TYPE=Release",
|
||||
"-DFPC_BUILD_GUI=ON", "-DFPC_BUILD_WFB_USB=ON", "-DFPC_BUILD_WFB_CAPTURE=OFF",
|
||||
"-DFPC_QT_PREFIX=$QtPrefix"
|
||||
)
|
||||
if ($DevourerSrc) { $cmakeArgs += "-DFETCHCONTENT_SOURCE_DIR_DEVOURER=$DevourerSrc" }
|
||||
cmake @cmakeArgs
|
||||
cmake --build (Join-Path $Repo $BuildDir)
|
||||
|
||||
# ---- 组装 ----
|
||||
$Name = "fpv-relay-win-x64"
|
||||
$Stage = Join-Path $Repo "dist\$Name"
|
||||
Remove-Item -Recurse -Force $Stage -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Force -Path $Stage | Out-Null
|
||||
|
||||
Copy-Item (Join-Path $Repo "$BuildDir\fpv-relay.exe") $Stage
|
||||
Copy-Item (Join-Path $Repo "$BuildDir\fpv-relay-gui.exe") $Stage
|
||||
Copy-Item $Ffmpeg $Stage
|
||||
Copy-Item (Join-Path $DepsPrefix "bin\libusb-1.0.dll") $Stage
|
||||
Copy-Item (Join-Path $DepsPrefix "bin\libsodium-26.dll") $Stage
|
||||
Copy-Item (Join-Path $Repo "ass\gs.key") $Stage -ErrorAction SilentlyContinue
|
||||
Copy-Item (Join-Path $Repo "config.windows.example.yaml") $Stage
|
||||
Copy-Item (Join-Path $Repo "config.windows.example.yaml") (Join-Path $Stage "config.yaml")
|
||||
|
||||
# Qt 运行库
|
||||
& (Join-Path $QtPrefix "bin\windeployqt.exe") --release --qmldir (Join-Path $Repo "src\gui") (Join-Path $Stage "fpv-relay-gui.exe")
|
||||
Copy-Item (Join-Path $QtPrefix "bin\Qt6ShaderTools.dll") $Stage -ErrorAction SilentlyContinue
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $Stage "qml") | Out-Null
|
||||
Copy-Item -Recurse -Force (Join-Path $QtPrefix "qml\Qt5Compat") (Join-Path $Stage "qml\Qt5Compat")
|
||||
# FpvRelay QML 模块目录
|
||||
Copy-Item -Recurse -Force (Join-Path $Repo "$BuildDir\FpvRelay") (Join-Path $Stage "FpvRelay")
|
||||
|
||||
# qt.conf:让 Qt 从程序目录找 QML
|
||||
Set-Content -Path (Join-Path $Stage "qt.conf") -Value "[Paths]`nPrefix=.`nQmlImportsPath=qml`n" -Encoding ASCII
|
||||
|
||||
# 启动脚本
|
||||
Set-Content -Path (Join-Path $Stage "run-cli.bat") -Encoding ASCII -Value @"
|
||||
@echo off
|
||||
setlocal
|
||||
set DIR=%~dp0
|
||||
cd /d "%DIR%"
|
||||
set PATH=%DIR%;%PATH%
|
||||
"%DIR%fpv-relay.exe" %*
|
||||
"@
|
||||
Set-Content -Path (Join-Path $Stage "run-gui.bat") -Encoding ASCII -Value @"
|
||||
@echo off
|
||||
setlocal
|
||||
set DIR=%~dp0
|
||||
cd /d "%DIR%"
|
||||
set PATH=%DIR%;%PATH%
|
||||
start "" "%DIR%fpv-relay-gui.exe" %*
|
||||
"@
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "完成: $Stage"
|
||||
Write-Host "用户侧只需先用 Zadig 把网卡驱动换成 WinUSB,然后双击 run-gui.bat。"
|
||||
Reference in New Issue
Block a user