forked from obsproject/obs-deps
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqt5.ps1
147 lines (117 loc) · 4.91 KB
/
qt5.ps1
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
136
137
138
139
140
141
142
143
144
145
146
147
param(
[string] $Name = 'qt5',
[string] $Version = '5.15.8',
[string] $Uri = 'https://github.com/qt/qt5.git',
[string] $Hash = '3c61a77b7f2a2df6077290843ab13069bd70dca9',
[array] $Patches = @(
@{
PatchFile = "${PSScriptRoot}/patches/Qt5/win/0001-QTBUG-74606.patch"
HashSum = "BAE8765FC74FB398BC3967AD82760856EE308E643A8460C324D36A4D07063001"
}
)
)
# References:
# 1: https://wiki.qt.io/Building_Qt_5_from_Git
# 2: https://doc.qt.io/qt-5/windows-building.html
# 3: https://doc.qt.io/qt-5/configure-options.html#source-build-and-install-directories
# 4: https://doc.qt.io/qt-6.2/windows-building.html
# Per [2]:
# Note: The install path must not contain any spaces or Windows specific file system characters.
# Per [4]:
# Note: The path to the source directory must not contain any spaces or Windows specific file system characters. The
# path should also be kept short. This avoids issues with too long file paths in the compilation phase.
function Setup {
Setup-Dependency -Uri $Uri -Hash $Hash -DestinationPath $Path
# Download jom if not present and check its hash.
Invoke-SafeWebRequest -Uri "https://download.qt.io/official_releases/jom/jom_1_1_3.zip" -HashFile "${PSScriptRoot}/checksums/jom-1.1.3.zip.sha256" -CheckExisting
Expand-ArchiveExt -Path "jom_1_1_3.zip" -DestinationPath "jom" -Force
New-Item -ItemType "directory" -Path "qt5_build\${Version}\${Target}" -Force
New-Item -ItemType "directory" -Path "$($ConfigData.OutputPath)" -Force
# Run init-repository perl script.
# This will fail if any of the repos are dirty (uncommitted patches).
Set-Location qt5
# Perform git clean here to ensure that init-repository does not fail.
Invoke-External git submodule foreach --recursive "git clean -dfx"
Invoke-External git clean -dfx
Check-GitUser
$Options = @(
'--module-subset', 'qtbase,qtimageformats,qtmultimedia,qtsvg,qtwinextras'
'--force'
)
Invoke-External perl init-repository @Options
}
function Clean {
Set-Location $Path
# Perform git clean here to ensure that the source tree is clean.
# This should only be needed if building in-tree, but safe enough to do either way.
Invoke-External git submodule foreach --recursive "git clean -dfx"
Invoke-External git clean -dfx
Set-Location ".."
Remove-Item "qt5_build\${Version}\${Target}\*" -Recurse -Force
Remove-Item "$($ConfigData.OutputPath)\*" -Recurse -Force
}
function Patch {
Log-Information "Patch (${Target})"
Set-Location $Path
$Patches | ForEach-Object {
$Params = $_
Safe-Patch @Params
}
Set-Location qtbase
Check-GitUser
git add .
git commit -m "Simple fix for QTBUG-74606"
}
function Configure {
Log-Information "Configure (${Target})"
Set-Location $Path
$BuildPath = "$($ConfigData.OutputPath)"
Set-Location "..\qt5_build\${Version}\${Target}"
$QtBuildConfiguration = '-release'
if ( $Configuration -eq 'Release' ) {
$QtBuildConfiguration = '-release'
} elseif ( $Configuration -eq 'RelWithDebInfo' ) {
$QtBuildConfiguration = '-release -force-debug-info'
} elseif ( $Configuration -eq 'Debug' ) {
$QtBuildConfiguration = '-debug'
} elseif ( $Configuration -eq 'MinSizeRel' ) {
$QtBuildConfiguration = '-release'
}
$BuildCommand = "..\..\..\qt5\configure -opensource -confirm-license ${QtBuildConfiguration} -no-strip -nomake examples -nomake tests -no-compile-examples -schannel -no-dbus -no-freetype -no-harfbuzz -no-icu -no-feature-itemmodeltester -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-sql -no-feature-sqlmodel -no-feature-testlib -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite2 -no-sql-sqlite -no-sql-tds -DQT_NO_PDF -DQT_NO_PRINTER -mp -prefix ${BuildPath}"
$Params = @{
BasePath = (Get-Location | Convert-Path)
BuildPath = "."
BuildCommand = "${BuildCommand}"
Target = $Target
HostArchitecture = $Target
}
Invoke-DevShell @Params
}
function Build {
Log-Information "Build (${Target})"
Set-Location $Path
Set-Location ".."
Copy-Item "jom\jom.exe" "qt5_build\${Version}\${Target}\jom.exe"
Set-Location "qt5_build\${Version}\${Target}"
$Params = @{
BasePath = (Get-Location | Convert-Path)
BuildPath = "."
BuildCommand = ".\jom.exe"
Target = $Target
HostArchitecture = $Target
}
Invoke-DevShell @Params
}
function Install {
Log-Information "Install (${Target})"
Set-Location $Path
Set-Location "..\qt5_build\${Version}\${Target}"
$Params = @{
BasePath = (Get-Location | Convert-Path)
BuildPath = "."
BuildCommand = ".\jom.exe install"
Target = $Target
HostArchitecture = $Target
}
Invoke-DevShell @Params
}