| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- $ErrorActionPreference = "Stop"
- $RootDir = Split-Path -Parent $PSScriptRoot
- Set-Location $RootDir
- $PythonBin = if ($env:PYTHON_BIN) { $env:PYTHON_BIN } else { ".\.venv\Scripts\python.exe" }
- $PyInstallerBin = if ($env:PYINSTALLER_BIN) { $env:PYINSTALLER_BIN } else { ".\.venv\Scripts\pyinstaller.exe" }
- if (-not (Test-Path $PythonBin)) {
- Write-Error "Python executable not found: $PythonBin"
- }
- if (-not (Test-Path $PyInstallerBin)) {
- Write-Error "PyInstaller executable not found: $PyInstallerBin`nInstall it with: uv pip install --python .\.venv\Scripts\python.exe pyinstaller"
- }
- $Version = (& $PythonBin -c "from pathlib import Path; import tomllib; print(tomllib.loads(Path('pyproject.toml').read_text(encoding='utf-8'))['project']['version'])").Trim()
- $ArchName = if ([Environment]::Is64BitOperatingSystem) { "x86_64" } else { "x86" }
- $MainOutput = "dist/mlog-tool-qt.exe"
- $VersionedOutput = "dist/mlog-tool-qt-v$Version-windows-$ArchName.exe"
- Write-Host "Building Qt executable with $PyInstallerBin"
- $ResetQtPlatform = $false
- if (-not $env:QT_QPA_PLATFORM) {
- $env:QT_QPA_PLATFORM = "offscreen"
- $ResetQtPlatform = $true
- }
- try {
- & $PyInstallerBin --noconfirm --clean mlog_tool_qt.spec
- if ($LASTEXITCODE -ne 0) {
- exit $LASTEXITCODE
- }
- Copy-Item $MainOutput $VersionedOutput -Force
- }
- finally {
- if ($ResetQtPlatform) {
- Remove-Item Env:QT_QPA_PLATFORM -ErrorAction SilentlyContinue
- }
- }
- Write-Host ""
- Write-Host "Build finished:"
- Write-Host " $MainOutput"
- Write-Host " $VersionedOutput"
|