qt-5.15.10-win-x86-msvc.ps1 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # Run this script on a Windows host to generate Qt binaries.
  4. # Set the PATH environment variable to contain the locations of cmake and git.
  5. param (
  6. [string]$cmake = 'cmake',
  7. [string]$git = 'git',
  8. [switch]$trace
  9. )
  10. if ($trace -eq $true) {
  11. Set-PSDebug -Trace 1
  12. }
  13. $ErrorActionPreference = 'Stop'
  14. $ProgressPreference = 'SilentlyContinue'
  15. if ($env:VSCMD_ARG_TGT_ARCH -eq "x64") {
  16. $arch = "x86_64";
  17. } elseif ($env:VSCMD_ARG_TGT_ARCH -eq "x86") {
  18. $arch = "i386";
  19. } else {
  20. Write-Host "VSCMD_ARG_TGT_ARCH env var not recognized. Run this from a Visual Studio Command Prompt."
  21. exit 1
  22. }
  23. if ($env:VCToolsVersion -match '^(?<version>[0-9][0-9]\.[0-9])') {
  24. $toolset = "msvc_v" + $Matches.version -replace '\.', ''
  25. } else {
  26. Write-Host "VCToolsVersion env var not set. Run this from a Visual Studio Command Prompt."
  27. }
  28. $srcname = "qt-everywhere-src-5.15.10"
  29. $pkgname = "qt-5.15.10-win-$arch-$toolset-1"
  30. $topdir = $pwd.Path
  31. $srcdir = Join-Path $topdir $srcname
  32. $blddir = Join-Path $topdir "$pkgname-build"
  33. $prefix = Join-Path $topdir $pkgname
  34. # JOM
  35. if ( -not (Test-Path -Path "jom")) {
  36. Invoke-WebRequest -Uri "http://download.qt-project.org/official_releases/jom/jom_1_1_4.zip" -OutFile jom.zip
  37. if ($(Get-FileHash "jom.zip").Hash -ne 'd533c1ef49214229681e90196ed2094691e8c4a0a0bef0b2c901debcb562682b') {
  38. Write-Host "jom hash does not match"
  39. exit 1
  40. }
  41. Expand-Archive -Path jom.zip -DestinationPath jom
  42. Remove-Item jom.zip
  43. }
  44. $jom = "$topdir\jom\jom.exe"
  45. # Qt Source
  46. if ( -not (Test-Path -Path $srcdir)) {
  47. Invoke-WebRequest -Uri "https://download.qt.io/archive/qt/5.15/5.15.10/single/qt-everywhere-opensource-src-5.15.10.tar.xz" -OutFile qt.tar.xz
  48. if ($(Get-FileHash "qt.tar.xz").Hash -ne 'b545cb83c60934adc9a6bbd27e2af79e5013de77d46f5b9f5bb2a3c762bf55ca') {
  49. Write-Host "qt hash does not match"
  50. exit 1
  51. }
  52. & $cmake -E tar xvf qt.tar.xz
  53. Remove-Item qt.tar.xz
  54. }
  55. # Build Qt
  56. if ( -not (Test-Path -Path $blddir)) {
  57. New-Item -ItemType Directory -Path $blddir
  58. Set-Location -Path "$blddir"
  59. & ..\$srcname\configure.bat `
  60. -prefix $prefix `
  61. -static `
  62. -static-runtime `
  63. -release `
  64. -opensource -confirm-license `
  65. -platform win32-msvc `
  66. -mp `
  67. -gui `
  68. -widgets `
  69. -qt-pcre `
  70. -qt-zlib `
  71. -qt-libpng `
  72. -qt-libjpeg `
  73. -no-gif `
  74. -no-icu `
  75. -no-pch `
  76. -no-angle `
  77. -no-opengl `
  78. -no-dbus `
  79. -no-harfbuzz `
  80. -no-accessibility `
  81. -skip declarative `
  82. -skip multimedia `
  83. -skip qtcanvas3d `
  84. -skip qtconnectivity `
  85. -skip qtdeclarative `
  86. -skip qtlocation `
  87. -skip qtmultimedia `
  88. -skip qtsensors `
  89. -skip qtserialbus `
  90. -skip qtserialport `
  91. -skip qtsvg `
  92. -skip qtwayland `
  93. -skip qtwebchannel `
  94. -skip qtwebengine `
  95. -skip qtwebsockets `
  96. -skip qtxmlpatterns `
  97. -nomake examples -nomake tests
  98. & $jom -J $env:NUMBER_OF_PROCESSORS
  99. }
  100. # Install Qt
  101. if ( -not (Test-Path -Path $prefix)) {
  102. & $jom install
  103. # Patch the installation.
  104. Set-Location -Path $prefix
  105. & $git apply -v (Join-Path $PSScriptRoot qt-5.15.10-win-x86-msvc-install.patch)
  106. }
  107. # Package Qt
  108. Set-Location -Path $topdir
  109. & $cmake -E tar cf "$pkgname.zip" "--format=zip" "$pkgname"