综合平台编程器项目的远程存储
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

57 lignes
1.7 KiB

  1. [CmdletBinding()]
  2. param(
  3. [ValidateSet('Debug', 'Release')]
  4. [string]$Configuration = 'Debug'
  5. )
  6. Set-StrictMode -Version Latest
  7. $ErrorActionPreference = 'Stop'
  8. $projectRoot = Split-Path -Parent $PSScriptRoot
  9. $qtRoot = 'D:\Qt5.15.2\5.15.2\mingw81_64'
  10. $minGwBin = 'D:\Qt5.15.2\Tools\mingw810_64\bin'
  11. $qmakePath = Join-Path $qtRoot 'bin\qmake.exe'
  12. $makePath = Join-Path $minGwBin 'mingw32-make.exe'
  13. $projectFile = Join-Path $projectRoot 'app\integrated_platform.pro'
  14. $configurationName = $Configuration.ToLowerInvariant()
  15. $buildDirectory = Join-Path $projectRoot "build\$configurationName"
  16. $executablePath = Join-Path $buildDirectory "$configurationName\integrated_platform.exe"
  17. foreach ($requiredPath in @($qmakePath, $makePath, $projectFile)) {
  18. if (-not (Test-Path -LiteralPath $requiredPath)) {
  19. throw "未找到必要文件:$requiredPath"
  20. }
  21. }
  22. New-Item -ItemType Directory -Path $buildDirectory -Force | Out-Null
  23. $originalPath = $env:Path
  24. $env:Path = "$qtRoot\bin;$minGwBin;$env:Path"
  25. Push-Location $buildDirectory
  26. try {
  27. & $qmakePath $projectFile "CONFIG+=$configurationName" "CONFIG-=$(if ($configurationName -eq 'debug') { 'release' } else { 'debug' })"
  28. if ($LASTEXITCODE -ne 0) {
  29. throw "qmake 执行失败,退出码:$LASTEXITCODE"
  30. }
  31. & $makePath -j2
  32. if ($LASTEXITCODE -ne 0) {
  33. throw "mingw32-make 执行失败,退出码:$LASTEXITCODE"
  34. }
  35. if (-not (Test-Path -LiteralPath $executablePath)) {
  36. throw "未生成可执行文件:$executablePath"
  37. }
  38. Write-Host "构建完成,正在启动:$executablePath"
  39. & $executablePath
  40. if ($LASTEXITCODE -ne 0) {
  41. throw "程序退出异常,退出码:$LASTEXITCODE"
  42. }
  43. }
  44. finally {
  45. Pop-Location
  46. $env:Path = $originalPath
  47. }