qt-5.12.1-win-x86-msvc.ps1 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.12.1"
  29. $pkgname = "qt-5.12.1-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/unstable-jom.zip" -OutFile jom.zip
  37. if ($(Get-FileHash "jom.zip").Hash -ne '128fdd846fe24f8594eed37d1d8929a0ea78df563537c0c1b1861a635013fff8') {
  38. exit 1
  39. }
  40. Expand-Archive -Path jom.zip -DestinationPath jom
  41. Remove-Item jom.zip
  42. }
  43. $jom = "$topdir\jom\jom.exe"
  44. # Qt Source
  45. if ( -not (Test-Path -Path $srcdir)) {
  46. Invoke-WebRequest -Uri "https://download.qt.io/official_releases/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.tar.xz" -OutFile qt.tar.xz
  47. if ($(Get-FileHash "qt.tar.xz").Hash -ne 'caffbd625c7bc10ff8c5c7a27dbc7d84fa4de146975c0e1ffe904b514ccd6da4') {
  48. exit 1
  49. }
  50. & $cmake -E tar xvf qt.tar.xz
  51. Remove-Item qt.tar.xz
  52. }
  53. # Build Qt
  54. if ( -not (Test-Path -Path $blddir)) {
  55. New-Item -ItemType Directory -Path $blddir
  56. Set-Location -Path "$blddir"
  57. & ..\$srcname\configure.bat `
  58. -prefix $prefix `
  59. -static `
  60. -static-runtime `
  61. -release `
  62. -opensource -confirm-license `
  63. -platform win32-msvc `
  64. -mp `
  65. -gui `
  66. -widgets `
  67. -qt-pcre `
  68. -qt-zlib `
  69. -qt-libpng `
  70. -qt-libjpeg `
  71. -no-gif `
  72. -no-icu `
  73. -no-pch `
  74. -no-angle `
  75. -no-opengl `
  76. -no-dbus `
  77. -no-harfbuzz `
  78. -no-accessibility `
  79. -skip declarative `
  80. -skip multimedia `
  81. -skip qtcanvas3d `
  82. -skip qtconnectivity `
  83. -skip qtdeclarative `
  84. -skip qtlocation `
  85. -skip qtmultimedia `
  86. -skip qtsensors `
  87. -skip qtserialport `
  88. -skip qtsvg `
  89. -skip qtwayland `
  90. -skip qtwebchannel `
  91. -skip qtwebengine `
  92. -skip qtwebsockets `
  93. -skip qtxmlpatterns `
  94. -nomake examples -nomake tests
  95. & $jom -J $env:NUMBER_OF_PROCESSORS
  96. }
  97. # Install Qt
  98. if ( -not (Test-Path -Path $prefix)) {
  99. & $jom install
  100. # Patch the installation.
  101. Set-Location -Path $prefix
  102. & $git apply -v (Join-Path $PSScriptRoot qt-5.12.1-win-x86-msvc-install.patch)
  103. }
  104. # Package Qt
  105. Set-Location -Path $topdir
  106. & $cmake -E tar cf "$pkgname.zip" "--format=zip" "$pkgname"