-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
qt.rb
210 lines (175 loc) 路 6.45 KB
/
qt.rb
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
class Qt < Formula
desc "Cross-platform application and UI framework"
homepage "https://www.qt.io/"
url "https://download.qt.io/official_releases/qt/6.0/6.0.3/single/qt-everywhere-src-6.0.3.tar.xz"
sha256 "ca4a97439443dd0b476a47b284ba772c3b1b041a9eef733e26a789490993a0e3"
license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "LGPL-3.0-only"]
revision 2
head "https://code.qt.io/qt/qt5.git", branch: "dev", shallow: false
# The first-party website doesn't make version information readily available,
# so we check the `head` repository tags instead.
livecheck do
url :head
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "635a8970ba2a0a33eac8f36a75477fcb0454f955df1f5bd01fa8bb8f1f406338"
sha256 cellar: :any, big_sur: "69f8718c2d528308eb4784e249a9f0b4ccc75ec9408ad0b1151452ec532cf784"
sha256 cellar: :any, catalina: "677e7dab6d7a0c9a9ec6328e68cfaf3adfb0b04acd53df99acc5ed45d6dd0bc5"
sha256 cellar: :any, mojave: "31f6ffd1847621491ea92af60d1e6348b84160b0cf757ca69d5fada250858de5"
end
depends_on "cmake" => [:build, :test]
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on xcode: [:build, :test]
depends_on "assimp"
depends_on "dbus"
depends_on "double-conversion"
depends_on "freetype"
depends_on "glib"
depends_on "icu4c"
depends_on "jasper"
depends_on "jpeg"
depends_on "libb2"
depends_on "libpng"
depends_on "libproxy"
depends_on "libtiff"
depends_on "pcre2"
depends_on "python@3.9"
depends_on "sqlite"
depends_on "webp"
depends_on "zstd"
uses_from_macos "cups"
uses_from_macos "krb5"
uses_from_macos "perl"
uses_from_macos "zlib"
resource "qtimageformats" do
url "https://download.qt.io/official_releases/additional_libraries/6.0/6.0.3/qtimageformats-everywhere-src-6.0.3.tar.xz"
sha256 "327580b5a5b9a8d75e869c0eaa7ff34881bbde4e4ccc51d07a59e96054136837"
end
resource "qt3d" do
url "https://download.qt.io/official_releases/additional_libraries/6.0/6.0.3/qt3d-everywhere-src-6.0.3.tar.xz"
sha256 "470f95c559b68cc8faa982c1ca7ff83054d6802f7b2a0c1d960a155b92080cf9"
end
resource "qtnetworkauth" do
url "https://download.qt.io/official_releases/additional_libraries/6.0/6.0.3/qtnetworkauth-everywhere-src-6.0.3.tar.xz"
sha256 "124bf433e2c5418e900a5947d4ceb128ee179f514eddcea33924f0b695be64ed"
end
def install
resources.each { |addition| addition.stage buildpath/addition.name }
config_args = %W[
-release
-prefix #{HOMEBREW_PREFIX}
-extprefix #{prefix}
-libexecdir share/qt/libexec
-plugindir share/qt/plugins
-qmldir share/qt/qml
-docdir share/doc/qt
-translationdir share/qt/translations
-examplesdir share/qt/examples
-testsdir share/qt/tests
-libproxy
-no-feature-relocatable
-no-feature-brotli
-system-sqlite
-no-sql-mysql
-no-sql-odbc
-no-sql-psql
]
# TODO: remove `-DFEATURE_qt3d_system_assimp=ON`
# and `-DTEST_assimp=ON` when Qt 6.2 is released.
# See https://bugreports.qt.io/browse/QTBUG-91537
cmake_args = std_cmake_args.reject { |s| s["CMAKE_INSTALL_PREFIX"]||s["CMAKE_FIND_FRAMEWORK"] } + %W[
-DCMAKE_OSX_DEPLOYMENT_TARGET=#{MacOS.version}
-DCMAKE_FIND_FRAMEWORK=FIRST
-DINSTALL_MKSPECSDIR=share/qt/mkspecs
-DINSTALL_DESCRIPTIONSDIR=share/qt/modules
-DFEATURE_pkg_config=ON
-DFEATURE_qt3d_system_assimp=ON
-DTEST_assimp=ON
]
system "./configure", *config_args, "--", *cmake_args
system "ninja"
system "ninja", "install"
rm bin/"qt-cmake-private-install.cmake"
# Some config scripts will only find Qt in a "Frameworks" folder
frameworks.install_symlink Dir["#{lib}/*.framework"]
inreplace lib/"cmake/Qt6/qt.toolchain.cmake", /.*set.__qt_initial_.*/, ""
# The pkg-config files installed suggest that headers can be found in the
# `include` directory. Make this so by creating symlinks from `include` to
# the Frameworks' Headers folders.
Pathname.glob("#{lib}/*.framework/Headers") do |path|
include.install_symlink path => path.parent.basename(".framework")
end
mkdir libexec
Pathname.glob("#{bin}/*.app") do |app|
mv app, libexec
bin.write_exec_script "#{libexec/app.stem}.app/Contents/MacOS/#{app.stem}"
end
end
test do
(testpath/"CMakeLists.txt").write <<~EOS
cmake_minimum_required(VERSION #{Formula["cmake"].version})
project(test VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 COMPONENTS Core Widgets Sql Concurrent
3DCore Svg Quick3D Network NetworkAuth REQUIRED)
add_executable(test
main.cpp
)
target_link_libraries(test PRIVATE Qt6::Core Qt6::Widgets
Qt6::Sql Qt6::Concurrent Qt6::3DCore Qt6::Svg Qt6::Quick3D
Qt6::Network Qt6::NetworkAuth
)
EOS
(testpath/"test.pro").write <<~EOS
QT += core svg 3dcore network networkauth quick3d \
sql
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
EOS
(testpath/"main.cpp").write <<~EOS
#undef QT_NO_DEBUG
#include <QCoreApplication>
#include <Qt3DCore>
#include <QtQuick3D>
#include <QImageReader>
#include <QtNetworkAuth>
#include <QtSql>
#include <QtSvg>
#include <QDebug>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(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();
for(const char* fmt:{"bmp", "cur", "gif", "heic", "heif",
"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;
}
EOS
system "cmake", testpath
system "make"
system "./test"
system bin/"qmake", testpath/"test.pro"
system "make"
system "./test"
end
end