build_gui_exe.ps1 1001 B

12345678910111213141516171819202122232425262728293031
  1. param(
  2. [string]$AppName = 'MotorCADParameterScan'
  3. )
  4. $ErrorActionPreference = 'Stop'
  5. Set-Location -LiteralPath $PSScriptRoot
  6. $safeDir = $PSScriptRoot.Replace('\', '/')
  7. $commit = git -c "safe.directory=$safeDir" rev-parse --short HEAD
  8. if ($LASTEXITCODE -ne 0) {
  9. throw 'No Git commit exists.'
  10. }
  11. $dirty = git -c "safe.directory=$safeDir" status --porcelain --untracked-files=no
  12. if ($dirty) {
  13. throw 'Tracked files have uncommitted changes. Commit before building.'
  14. }
  15. $buildInfo = "BUILD_COMMIT = '$commit'`n"
  16. [System.IO.File]::WriteAllText((Join-Path $PSScriptRoot 'build_info.py'), $buildInfo, [System.Text.Encoding]::ASCII)
  17. python -m PyInstaller `
  18. --noconfirm `
  19. --clean `
  20. --windowed `
  21. --name $AppName `
  22. --collect-all ansys.motorcad.core `
  23. --add-data "scan_parameters.json;." `
  24. motorcad_scan_gui.py
  25. Copy-Item -LiteralPath '.\scan_parameters.json' -Destination ".\dist\$AppName\scan_parameters.json" -Force
  26. Write-Host "Build complete: $PSScriptRoot\dist\$AppName\$AppName.exe"