c80e3f5567
Die fuer Debian 13 geschriebene Fassung (Python + Tkinter + matplotlib)
laeuft jetzt als Windows-Anwendung mit Qt 6. Oberflaeche, Bedienlogik und
alle DSP-Verfahren sind unveraendert uebernommen.
- core/ DSP, Audio-IO und Export ohne GUI-Abhaengigkeit
- ui/ Hauptfenster, eigene Wellenform-Anzeige, Uebersichtsleiste,
ffplay-Wiedergabe, Hintergrund-Worker
- tools/ Selbsttest gegen die Python-Vorlage, Ende-zu-Ende-Test der
ffmpeg-Kette, Messwerkzeuge fuer den Geschwindigkeitsvergleich
- chopper/ unveraenderte Vorlage als Referenz fuer die Pruefungen
Verifikation: verify.ps1 vergleicht den Auslieferungsbau gegen die Vorlage
(alle diskreten Ergebnisse identisch) und zusaetzlich einen double-Bau
gegen eine float64-Referenz (260 Werte innerhalb von 1e-9).
Die 14 Commits der Python-Vorlage liegen als chopper-history.bundle bei
(chopper/ war unter Debian ein eigenes Repository).
165 lines
7.1 KiB
PowerShell
165 lines
7.1 KiB
PowerShell
# ---------------------------------------------------------------------------
|
|
# Baut den Sample Chopper.
|
|
#
|
|
# .\build.ps1 Release bauen (inkl. Qt-Laufzeitdateien)
|
|
# .\build.ps1 -Config Debug Debug bauen
|
|
# .\build.ps1 -Core nur DSP-Kern + Selbsttest (schnell)
|
|
# .\build.ps1 -Run nach dem Bauen starten
|
|
# .\build.ps1 -NoDeploy Qt-DLLs NICHT kopieren
|
|
# .\build.ps1 -Toolchain msvc MSVC statt MinGW erzwingen
|
|
#
|
|
# Die Qt-Laufzeitdateien werden nach jedem Bauen automatisch neben die EXE
|
|
# kopiert. Ohne sie startet SampleChopper.exe nur, solange Qt im PATH liegt --
|
|
# ein Doppelklick im Explorer scheitert dann mit
|
|
# "Qt6Widgets.dll wurde nicht gefunden". Genau das ist einmal passiert,
|
|
# nachdem ein -Clean-Build das Ausgabeverzeichnis geleert hatte.
|
|
#
|
|
# Warum hier und nicht als CMake-POST_BUILD: CMake leitet solche Befehle ueber
|
|
# cmd.exe weiter, und '&' ist dort ein Befehlstrenner. Dieses Projekt liegt
|
|
# unter "C:\Users\Key & Co\..." -- der Aufruf wuerde zerlegt. PowerShell
|
|
# uebergibt Argumente ohne Shell-Zwischenstufe und hat das Problem nicht.
|
|
#
|
|
# Die Toolchain wird automatisch gewaehlt: MinGW 13.1 aus der Qt-Installation,
|
|
# wenn vorhanden, sonst MSVC 2022 mit installierter C++-Workload. Der Quelltext
|
|
# ist fuer beide gleich.
|
|
# ---------------------------------------------------------------------------
|
|
[CmdletBinding()]
|
|
param(
|
|
[ValidateSet('Release', 'Debug')]
|
|
[string]$Config = 'Release',
|
|
[ValidateSet('auto', 'mingw', 'msvc')]
|
|
[string]$Toolchain = 'auto',
|
|
[switch]$Core,
|
|
[switch]$Run,
|
|
[switch]$NoDeploy,
|
|
[switch]$Clean,
|
|
[string]$QtDir,
|
|
[string]$MingwDir
|
|
)
|
|
|
|
# Hinweis: 'Continue' ist Absicht. Native Tools (cmake, ninja, windeployqt)
|
|
# schreiben Fortschritt und Warnungen auf stderr; mit 'Stop' wuerde PowerShell
|
|
# schon bei einer harmlosen CMake-Warnung abbrechen. Geprueft wird deshalb
|
|
# ausschliesslich ueber $LASTEXITCODE.
|
|
$ErrorActionPreference = 'Continue'
|
|
$root = $PSScriptRoot
|
|
$config = $Config
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Toolchain bestimmen
|
|
# ---------------------------------------------------------------------------
|
|
function Test-MsvcCppTools {
|
|
$vswhere = @(
|
|
"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe",
|
|
"$env:ProgramFiles\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
) | Where-Object { Test-Path $_ } | Select-Object -First 1
|
|
if (-not $vswhere) { return $null }
|
|
$install = & $vswhere -latest -products * `
|
|
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
|
|
-property installationPath 2>$null
|
|
if (-not $install) { return $null }
|
|
$vcvars = Join-Path $install 'VC\Auxiliary\Build\vcvars64.bat'
|
|
if (-not (Test-Path $vcvars)) { return $null }
|
|
return $install
|
|
}
|
|
|
|
$mingwRoot = if ($MingwDir) { $MingwDir } else { 'C:\Qt\Tools\mingw1310_64' }
|
|
$mingwQt = 'C:\Qt\6.8.3\mingw_64'
|
|
$msvcQt = 'C:\Qt\6.8.3\msvc2022_64'
|
|
|
|
if ($Toolchain -eq 'auto') {
|
|
if (Test-Path (Join-Path $mingwRoot 'bin\g++.exe')) { $Toolchain = 'mingw' }
|
|
elseif (Test-MsvcCppTools) { $Toolchain = 'msvc' }
|
|
else { throw "Weder MinGW unter $mingwRoot noch eine MSVC-C++-Workload gefunden." }
|
|
}
|
|
|
|
if ($Toolchain -eq 'mingw') {
|
|
if (-not $QtDir) { $QtDir = $mingwQt }
|
|
$compiler = Join-Path $mingwRoot 'bin\g++.exe'
|
|
if (-not (Test-Path $compiler)) { throw "MinGW nicht gefunden: $compiler" }
|
|
$env:PATH = (Join-Path $mingwRoot 'bin') + ';' + $env:PATH
|
|
$generator = if (Get-Command ninja -ErrorAction SilentlyContinue) { 'Ninja' } else { 'MinGW Makefiles' }
|
|
Write-Host "Toolchain: MinGW ($compiler)" -ForegroundColor Cyan
|
|
Write-Host "Qt: $QtDir" -ForegroundColor Cyan
|
|
} else {
|
|
if (-not $QtDir) { $QtDir = $msvcQt }
|
|
$install = Test-MsvcCppTools
|
|
if (-not $install) {
|
|
throw "MSVC-C++-Workload fehlt. Entweder im Visual Studio Installer " +
|
|
"'Desktopentwicklung mit C++' nachinstallieren oder -Toolchain mingw verwenden."
|
|
}
|
|
$vcvars = Join-Path $install 'VC\Auxiliary\Build\vcvars64.bat'
|
|
$lines = & cmd.exe /c "`"$vcvars`" >nul 2>&1 && set"
|
|
foreach ($line in $lines) {
|
|
if ($line -match '^([^=]+)=(.*)$') {
|
|
Set-Item -Path "env:$($matches[1])" -Value $matches[2] -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
$generator = 'Ninja'
|
|
Write-Host "Toolchain: MSVC ($install)" -ForegroundColor Cyan
|
|
Write-Host "Qt: $QtDir" -ForegroundColor Cyan
|
|
}
|
|
|
|
if (-not (Test-Path $QtDir)) { throw "Qt nicht gefunden unter $QtDir" }
|
|
|
|
$buildDir = Join-Path $root "build/$($config.ToLower())-$Toolchain"
|
|
if ($Clean -and (Test-Path $buildDir)) { Remove-Item -Recurse -Force $buildDir }
|
|
|
|
$cmake = (Get-Command cmake -ErrorAction SilentlyContinue)
|
|
if (-not $cmake) { throw "cmake nicht gefunden (pip install cmake)" }
|
|
$ninja = Get-Command ninja -ErrorAction SilentlyContinue
|
|
|
|
$configureArgs = @(
|
|
'-S', $root,
|
|
'-B', $buildDir,
|
|
'-G', $generator,
|
|
"-DCMAKE_BUILD_TYPE=$config",
|
|
"-DCMAKE_PREFIX_PATH=$QtDir"
|
|
)
|
|
if ($generator -eq 'Ninja') {
|
|
if (-not $ninja -and $Toolchain -eq 'msvc') { throw "ninja nicht gefunden (pip install ninja)" }
|
|
if ($ninja) { $configureArgs += "-DCMAKE_MAKE_PROGRAM=$($ninja.Source)" }
|
|
}
|
|
if ($Toolchain -eq 'mingw') {
|
|
$configureArgs += "-DCMAKE_CXX_COMPILER=$compiler"
|
|
$configureArgs += "-DCMAKE_C_COMPILER=$(Join-Path $mingwRoot 'bin\gcc.exe')"
|
|
}
|
|
if ($Core) { $configureArgs += '-DSC_CORE_ONLY=ON' }
|
|
|
|
Write-Host "`n=== Konfigurieren ===" -ForegroundColor Cyan
|
|
& $cmake.Source @configureArgs
|
|
if ($LASTEXITCODE -ne 0) { throw "CMake-Konfiguration fehlgeschlagen" }
|
|
|
|
Write-Host "`n=== Bauen ($config, $Toolchain) ===" -ForegroundColor Cyan
|
|
& $cmake.Source --build $buildDir --parallel
|
|
if ($LASTEXITCODE -ne 0) { throw "Build fehlgeschlagen" }
|
|
|
|
$exe = Join-Path $buildDir 'SampleChopper.exe'
|
|
Write-Host "`nFertig: $exe" -ForegroundColor Green
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Qt-Laufzeitdateien daneben legen
|
|
# ---------------------------------------------------------------------------
|
|
# Standardmaessig, damit ein -Clean-Build nie eine unstartbare EXE hinterlaesst.
|
|
if (-not $NoDeploy -and -not $Core -and (Test-Path $exe)) {
|
|
$windeployqt = Join-Path $QtDir 'bin\windeployqt.exe'
|
|
if (Test-Path $windeployqt) {
|
|
Write-Host "`n=== Qt-Laufzeitdateien kopieren ===" -ForegroundColor Cyan
|
|
& $windeployqt --no-translations --no-system-d3d-compiler --no-opengl-sw $exe 2>&1 |
|
|
Select-String -Pattern 'Updating|Adding|Creating|Cannot|Warning' |
|
|
Select-Object -First 12
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "windeployqt ist fehlgeschlagen (Exitcode $LASTEXITCODE)." -ForegroundColor Yellow
|
|
Write-Host "Die EXE braucht dann Qt im PATH." -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Write-Host "windeployqt nicht gefunden unter $windeployqt" -ForegroundColor Yellow
|
|
Write-Host "Die EXE braucht dann Qt im PATH. Mit -NoDeploy laesst sich das ueberspringen." -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
if ($Run -and -not $Core -and (Test-Path $exe)) {
|
|
Write-Host "`n=== Starten ===" -ForegroundColor Cyan
|
|
& $exe
|
|
}
|