-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Expand file tree
/
Copy pathqt.rb
More file actions
226 lines (202 loc) 路 7.93 KB
/
Copy pathqt.rb
File metadata and controls
226 lines (202 loc) 路 7.93 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
class Qt < Formula
desc "Cross-platform application and UI framework"
homepage "https://www.qt.io/"
url "https://download.qt.io/official_releases/qt/6.11/6.11.1/submodules/md5sums.txt"
mirror "https://qt.mirror.constant.com/archive/qt/6.11/6.11.1/submodules/md5sums.txt"
mirror "https://mirrors.ukfast.co.uk/sites/qt.io/archive/qt/6.11/6.11.1/submodules/md5sums.txt"
version "6.11.1"
sha256 "9e6bcc7f14c6776eb9dd480ec3df75a5bb458ab76cfb3b91b14e999968a62e73"
license all_of: [
"BSD-3-Clause",
"GFDL-1.3-no-invariants-only",
"GPL-2.0-only",
{ "GPL-3.0-only" => { with: "Qt-GPL-exception-1.0" } },
"LGPL-3.0-only",
]
livecheck do
formula "qtbase"
end
bottle do
rebuild 1
sha256 cellar: :any_skip_relocation, arm64_tahoe: "000845228bc27a71853e1953defa82d014fe7dc8360552a451b088667de3b07b"
sha256 cellar: :any_skip_relocation, arm64_sequoia: "000845228bc27a71853e1953defa82d014fe7dc8360552a451b088667de3b07b"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "000845228bc27a71853e1953defa82d014fe7dc8360552a451b088667de3b07b"
sha256 cellar: :any_skip_relocation, sonoma: "000845228bc27a71853e1953defa82d014fe7dc8360552a451b088667de3b07b"
sha256 cellar: :any_skip_relocation, arm64_linux: "9dcc0180007892d77a289c1ed4dcd971198f89f1e301cf253010754717fc3b72"
sha256 cellar: :any_skip_relocation, x86_64_linux: "9dcc0180007892d77a289c1ed4dcd971198f89f1e301cf253010754717fc3b72"
end
depends_on "cmake" => :test
depends_on "pkgconf" => :test
depends_on "vulkan-headers" => :test
depends_on "qt3d"
depends_on "qt5compat"
depends_on "qtbase"
depends_on "qtcanvaspainter"
depends_on "qtcharts"
depends_on "qtconnectivity"
depends_on "qtdatavis3d"
depends_on "qtdeclarative"
depends_on "qtgraphs"
depends_on "qtgrpc"
depends_on "qthttpserver"
depends_on "qtimageformats"
depends_on "qtlanguageserver"
depends_on "qtlocation"
depends_on "qtlottie"
depends_on "qtmultimedia"
depends_on "qtnetworkauth"
depends_on "qtpositioning"
depends_on "qtquick3d"
depends_on "qtquick3dphysics"
depends_on "qtquickeffectmaker"
depends_on "qtquicktimeline"
depends_on "qtremoteobjects"
depends_on "qtscxml"
depends_on "qtsensors"
depends_on "qtserialbus"
depends_on "qtserialport"
depends_on "qtshadertools"
depends_on "qtspeech"
depends_on "qtsvg"
depends_on "qttasktree"
depends_on "qttools"
depends_on "qttranslations"
depends_on "qtvirtualkeyboard"
depends_on "qtwebchannel"
depends_on "qtwebsockets"
on_system :linux, macos: :sonoma_or_newer do
depends_on "qtwebengine"
depends_on "qtwebview"
end
on_linux do
depends_on "qtwayland"
end
def webengine_supported?
on_sonoma :or_newer do
return true
end
on_linux do
return true
end
false
end
def install
# Check for any new formulae that need to be created before bottling
if build.bottle?
submodules = File.read("md5sums.txt").scan(/^\h+[ \t]+(\S+)-everywhere-src-/i).flatten.to_set
submodules -= ["qtwebengine", "qtwebview"] unless webengine_supported?
submodules.delete("qtwayland") unless OS.linux?
submodules.delete("qtactiveqt") # Windows-only
submodules.delete("qtdoc") # skip HTML documentation
submodules.delete("qtopenapi") # TODO: add in follow up PR
dep_names = deps.reject(&:test?).to_set(&:name)
missing = submodules - dep_names
odie "Possible new #{Utils.pluralize("formula", missing.count)}: #{missing.join(", ")}" unless missing.empty?
extras = dep_names - submodules
odie "Unexpected #{Utils.pluralize("dependency", extras.count)}: #{extras.join(", ")}" unless extras.empty?
end
# Create compatibility symlinks so existing usage of `Formula["qt"]` still works.
# These are done pointing to HOMEBREW_PREFIX paths to avoid making `qt` keg-only
# which causes an unwanted caveat message. Anyways, Qt won't work correctly if
# any dependencies are not linked as it is built to find modules in linked path
deps.each do |dep|
next if dep.test?
formula = dep.to_formula
Find.find(*formula.opt_prefix.glob("{#{Keg.keg_link_directories.join(",")}}")) do |src|
src = Pathname(src)
dst = prefix/src.relative_path_from(formula.opt_prefix)
linked_src = HOMEBREW_PREFIX/src.relative_path_from(formula.opt_prefix)
# Skip directories that have been symlinked already. We just link all directories
# starting with "Qt", which helps reduce the total number of symlinks by over 90%.
Find.prune if dst.symlink?
if src.symlink? || src.file?
dst.dirname.install_symlink linked_src
elsif src.directory? && (linked_src.symlink? || src.basename.to_s.start_with?(/qt/i))
dst.dirname.install_symlink linked_src
Find.prune
end
end
# Also symlink apps from libexec directories. Need to use ln_s to retain opt path
formula.opt_libexec.glob("*.app") do |app|
libexec.mkpath
ln_s app.relative_path_from(libexec), libexec
end
end
end
test do
modules = %w[Core Gui Widgets Sql Concurrent 3DCore Svg Quick3D Network NetworkAuth]
modules << "WebEngineCore" if webengine_supported?
(testpath/"CMakeLists.txt").write <<~CMAKE
cmake_minimum_required(VERSION 4.0)
project(test VERSION 1.0.0 LANGUAGES CXX)
find_package(Qt6 REQUIRED COMPONENTS #{modules.join(" ")})
qt_standard_project_setup()
qt_add_executable(test main.cpp)
target_link_libraries(test PRIVATE Qt6::#{modules.join(" Qt6::")})
CMAKE
(testpath/"test.pro").write <<~QMAKE
QT += #{modules.join(" ").downcase}
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += #{formula_opt_include("vulkan-headers")}
QMAKE
(testpath/"main.cpp").write <<~CPP
#undef QT_NO_DEBUG
#include <QCoreApplication>
#include <Qt3DCore>
#include <QtQuick3D>
#include <QImageReader>
#include <QtNetworkAuth>
#include <QtSql>
#include <QtSvg>
#include <QDebug>
#include <QVulkanInstance>
#{"#include <QtWebEngineCore>" if webengine_supported?}
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QSvgGenerator generator;
auto *handler = new QOAuthHttpServerReplyHandler();
delete handler; handler = nullptr;
auto *root = new Qt3DCore::QEntity();
delete root; root = nullptr;
Q_ASSERT(QSqlDatabase::isDriverAvailable("QSQLITE"));
const auto &list = QImageReader::supportedImageFormats();
QVulkanInstance inst;
// See https://github.com/actions/runner-images/issues/1779
// if (!inst.create())
// qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
for(const char* fmt:{"bmp", "cur", "gif",
#ifdef __APPLE__
"heic", "heif",
#endif
"icns", "ico", "jp2", "jpeg", "jpg", "pbm", "pgm", "png",
"ppm", "svg", "svgz", "tga", "tif", "tiff", "wbmp", "webp",
"xbm", "xpm"}) {
Q_ASSERT(list.contains(fmt));
}
return 0;
}
CPP
ENV["LC_ALL"] = "en_US.UTF-8"
ENV["QT_QPA_PLATFORM"] = "minimal" if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"]
system "cmake", "-S", ".", "-B", "cmake"
system "cmake", "--build", "cmake"
system "./cmake/test"
ENV.delete "CPATH" if OS.mac?
mkdir "qmake" do
system bin/"qmake", testpath/"test.pro"
system "make"
system "./test"
end
flags = shell_output("pkgconf --cflags --libs Qt6#{modules.join(" Qt6")}").chomp.split
system ENV.cxx, "-std=c++17", "main.cpp", "-o", "test", *flags
system "./test"
# Check QT_INSTALL_PREFIX is HOMEBREW_PREFIX to support split `qt-*` formulae
assert_equal HOMEBREW_PREFIX.to_s, shell_output("#{bin}/qmake -query QT_INSTALL_PREFIX").chomp
end
end