summaryrefslogtreecommitdiffstats
path: root/Utilities/Release/win/qt-6.3.0-win-msvc.ps1
blob: 265b26e9a62ff56bb16d8889f05a38faf8a9b523 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

# Run this script on a Windows host to generate Qt binaries.
# Set the PATH environment variable to contain the locations of cmake and git.

param (
  [string]$cmake = 'cmake',
  [string]$git = 'git',
  [string]$ninja = 'ninja',
  [switch]$trace
)

if ($trace -eq $true) {
  Set-PSDebug -Trace 1
}

$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

if ($env:VSCMD_ARG_TGT_ARCH -eq "x64") {
  $arch = "x86_64";
} elseif ($env:VSCMD_ARG_TGT_ARCH -eq "x86") {
  $arch = "i386";
} elseif ($env:VSCMD_ARG_TGT_ARCH -eq "arm64") {
  $arch = "arm64";
} else {
  Write-Host "VSCMD_ARG_TGT_ARCH env var not recognized.  Run this from a Visual Studio Command Prompt."
  exit 1
}

if ($env:VCToolsVersion -match '^(?<version>[0-9][0-9]\.[0-9])') {
  $toolset = "msvc_v" + $Matches.version -replace '\.', ''
} else {
  Write-Host "VCToolsVersion env var not set.  Run this from a Visual Studio Command Prompt."
}

$srcname = "qt-everywhere-src-6.3.0"
$pkgname = "qt-6.3.0-win-$arch-$toolset-1"
$pkgname_host = "qt-6.3.0-win-x86_64-$toolset-1"
$topdir = $pwd.Path
$srcdir = Join-Path $topdir $srcname
$blddir = Join-Path $topdir "$pkgname-build"
$prefix = Join-Path $topdir $pkgname
$prefix_host = Join-Path $topdir "$pkgname_host"

# Qt Source
if ( -not (Test-Path -Path $srcdir)) {
  Invoke-WebRequest -Uri "https://download.qt.io/official_releases/qt/6.3/6.3.0/single/qt-everywhere-src-6.3.0.tar.xz" -OutFile qt.tar.xz
  if ($(Get-FileHash "qt.tar.xz").Hash -ne 'cd2789cade3e865690f3c18df58ffbff8af74cc5f01faae50634c12eb52dd85b') {
      exit 1
  }
  & $cmake -E tar xvf qt.tar.xz
  Remove-Item qt.tar.xz
}

# Build Qt
if ( -not (Test-Path -Path $blddir)) {
  New-Item -ItemType Directory -Path $blddir
  Set-Location -Path "$blddir"
  if ($arch -eq "arm64") {
    $qt_platform = "win32-arm64-msvc"
    $qt_host_path = "-qt-host-path", "$prefix_host"
  } else {
    $qt_platform = "win32-msvc"
    $qt_host_path = $null
  }
  & ..\$srcname\configure.bat `
    -prefix $prefix `
    -static `
    -static-runtime `
    -release `
    -opensource -confirm-license `
    -platform $qt_platform `
    $qt_host_path `
    -gui `
    -widgets `
    -qt-doubleconversion `
    -qt-freetype `
    -qt-harfbuzz `
    -qt-pcre `
    -qt-zlib `
    -qt-libpng `
    -qt-libjpeg `
    -no-gif `
    -no-tiff `
    -no-webp `
    -no-icu `
    -no-pch `
    -no-opengl `
    -no-dbus `
    -no-accessibility `
    -no-feature-androiddeployqt `
    -no-feature-assistant `
    -no-feature-designer `
    -no-feature-linguist `
    -no-feature-pixeltool `
    -no-feature-printsupport `
    -no-feature-qtattributionsscanner `
    -no-feature-qtdiag `
    -no-feature-qtplugininfo `
    -no-feature-sql `
    -no-feature-windeployqt `
    -skip qtconnectivity `
    -skip qtdeclarative `
    -skip qtdoc `
    -skip qtlottie `
    -skip qtmqtt `
    -skip qtmultimedia `
    -skip qtopcua `
    -skip qtquick3d `
    -skip qtquicktimeline `
    -skip qtscxml `
    -skip qtsensors `
    -skip qtserialport `
    -skip qtsvg `
    -skip qtvirtualkeyboard `
    -skip qtwayland `
    -skip qtwebchannel `
    -skip qtwebengine `
    -skip qtwebsockets `
    -skip qtwebview `
    -nomake examples `
    -nomake tests
  & $ninja
}

# Install Qt
if ( -not (Test-Path -Path $prefix)) {
  & $ninja install
}

# Package Qt
Set-Location -Path $topdir
& $cmake -E tar cf "$pkgname.zip" "--format=zip" "$pkgname"