| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- param(
- [Parameter(Mandatory=$true)][string]$QtRoot,
- [Parameter(Mandatory=$true)][string]$MingwRoot,
- [string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.12'
- )
- $ErrorActionPreference = 'Stop'
- $ProgressPreference = 'SilentlyContinue'
- [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding
- $sourceRoot = Join-Path $ReleaseRoot '_build-src\qt-client'
- $appRoot = Join-Path $ReleaseRoot 'app'
- $evidenceRoot = Join-Path $ReleaseRoot 'evidence'
- $env:PATH = (Join-Path $MingwRoot 'bin') + ';' + (Join-Path $QtRoot 'bin') + ';' + $env:PATH
- New-Item -ItemType Directory -Force -Path $appRoot,$evidenceRoot | Out-Null
- # ZIP timestamps can be ahead of this machine's clock. Normalize only the
- # copied source metadata so qmake does not recursively regenerate Makefile.
- # Source bytes and the machine clock remain unchanged.
- $buildNow = (Get-Date).ToUniversalTime()
- Get-ChildItem -LiteralPath $sourceRoot -Recurse -File | Where-Object { $_.LastWriteTimeUtc -gt $buildNow } | ForEach-Object {
- $_.LastWriteTimeUtc = $buildNow.AddMinutes(-1)
- }
- function Invoke-Logged([string]$Tool,[string[]]$ToolArguments,[string]$WorkingDirectory,[string]$Label) {
- $outPath = Join-Path $evidenceRoot ($Label + '.stdout.log')
- $errPath = Join-Path $evidenceRoot ($Label + '.stderr.log')
- $process = Start-Process -FilePath $Tool -ArgumentList $ToolArguments -WorkingDirectory $WorkingDirectory `
- -NoNewWindow -Wait -PassThru -RedirectStandardOutput $outPath -RedirectStandardError $errPath
- if ($process.ExitCode -ne 0) {
- Get-Content -LiteralPath $errPath -Tail 30
- throw "$Label failed with exit code $($process.ExitCode)"
- }
- Write-Output "$Label passed"
- }
- $qmake = Join-Path $QtRoot 'bin\qmake.exe'
- $make = Join-Path $MingwRoot 'bin\mingw32-make.exe'
- foreach ($tool in @($qmake,$make)) {
- if (!(Test-Path -LiteralPath $tool)) { throw "Missing build tool: $tool" }
- }
- & $qmake -query | Out-File -Encoding utf8 (Join-Path $evidenceRoot 'windows-qmake-query.txt')
- & (Join-Path $MingwRoot 'bin\g++.exe') --version | Out-File -Encoding utf8 (Join-Path $evidenceRoot 'windows-compiler-version.txt')
- foreach ($kind in @('app','probe')) {
- $build = Join-Path $ReleaseRoot ('_build-src\build-' + $kind + '-win-release')
- New-Item -ItemType Directory -Force -Path $build | Out-Null
- if ($kind -eq 'app') {
- $project = Join-Path $sourceRoot 'DDR5_SLT_Monitor.pro'
- $executable = 'DDR5_SLT_Monitor.exe'
- } else {
- $project = Join-Path $sourceRoot 'tests\qt_clean_probe.pro'
- $executable = 'QtCleanProbe.exe'
- }
- Invoke-Logged $qmake @($project,'-spec','win32-g++','CONFIG+=release','CONFIG-=debug','CONFIG-=debug_and_release','CONFIG-=console') $build ('windows-' + $kind + '-qmake')
- Invoke-Logged $make @('-j4') $build ('windows-' + $kind + '-build')
- $built = Join-Path $build $executable
- if (!(Test-Path -LiteralPath $built)) { $built = Join-Path $build ('release\' + $executable) }
- if (!(Test-Path -LiteralPath $built)) { throw "Build did not produce $executable" }
- Copy-Item -LiteralPath $built -Destination (Join-Path $appRoot $executable) -Force
- }
- # The Qt 5.15.2 deployment tool rejected its matching MinGW plugins as debug.
- # Use an explicit, reviewable runtime from this exact build kit; validation runs
- # both Qt executables with the SDK and compiler directories removed from PATH.
- foreach ($library in @('Qt5Core.dll','Qt5Gui.dll','Qt5Widgets.dll','Qt5Network.dll',
- 'Qt5SerialPort.dll','Qt5WebSockets.dll','Qt5PrintSupport.dll',
- 'libEGL.dll','libGLESv2.dll','D3Dcompiler_47.dll','opengl32sw.dll')) {
- Copy-Item -LiteralPath (Join-Path $QtRoot ('bin\' + $library)) -Destination $appRoot -Force
- }
- foreach ($library in @('libgcc_s_seh-1.dll','libstdc++-6.dll','libwinpthread-1.dll')) {
- Copy-Item -LiteralPath (Join-Path $MingwRoot ('bin\' + $library)) -Destination $appRoot -Force
- }
- foreach ($category in @('platforms','imageformats','printsupport','styles','bearer')) {
- $sourcePlugins = Join-Path $QtRoot ('plugins\' + $category)
- if (Test-Path -LiteralPath $sourcePlugins) {
- $destination = Join-Path $appRoot $category
- New-Item -ItemType Directory -Force -Path $destination | Out-Null
- Copy-Item -Path (Join-Path $sourcePlugins '*.dll') -Destination $destination -Force
- }
- }
- Copy-Item -LiteralPath (Join-Path $sourceRoot 'config.json') -Destination (Join-Path $appRoot 'config.json') -Force
- $utf8 = New-Object System.Text.UTF8Encoding($false)
- [IO.File]::WriteAllText((Join-Path $appRoot 'qt.conf'), "[Paths]`r`nPrefix=.`r`nPlugins=.`r`n", $utf8)
- $ports = @{ serialPorts = @(
- @{port='';serialNumber='';baud=115200},
- @{port='';serialNumber='';baud=115200},
- @{port='';serialNumber='';baud=115200},
- @{port='';serialNumber='';baud=115200}
- )} | ConvertTo-Json -Depth 5
- [IO.File]::WriteAllText((Join-Path $appRoot 'port.json'), $ports + "`r`n", $utf8)
- $planPath = Join-Path $appRoot 'qt-plans.json'
- [IO.File]::WriteAllText($planPath, "{`"version`":1,`"stations`":{}}`r`n", $utf8)
- $files = Get-ChildItem -LiteralPath $appRoot -Recurse -File | ForEach-Object {
- @{ path = $_.FullName.Substring($appRoot.Length + 1).Replace('\','/'); bytes = $_.Length;
- sha256 = (Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant() }
- }
- $result = @{
- passed = $true; build_host = $env:COMPUTERNAME; architecture = 'x86_64'; qt_root = $QtRoot;
- compiler_root = $MingwRoot; app_directory = $appRoot;
- backend_url = 'ws://192.168.2.79:8080/ws?view=qt-clean'; files = @($files)
- } | ConvertTo-Json -Depth 8
- [IO.File]::WriteAllText((Join-Path $evidenceRoot 'windows-build-deployment.json'), $result + "`r`n", $utf8)
- Write-Output $result
|