|
| 1 | +# Patches for Qt must be at the very least submitted to Qt's Gerrit codereview |
| 2 | +# rather than their bug-report Jira. The latter is rarely reviewed by Qt. |
| 3 | +class SqlbQtAT5 < Formula |
| 4 | + desc "Cross-platform application and UI framework" |
| 5 | + homepage "https://www.qt.io/" |
| 6 | + url "https://download.qt.io/official_releases/qt/5.15/5.15.16/single/qt-everywhere-opensource-src-5.15.16.tar.xz" |
| 7 | + # version "5.15.16" |
| 8 | + # NOTE: Use *.diff for GitLab/KDE patches to avoid their checksums changing. |
| 9 | + sha256 "efa99827027782974356aceff8a52bd3d2a8a93a54dd0db4cca41b5e35f1041c" |
| 10 | + license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "LGPL-3.0-only"] |
| 11 | + revision 1 |
| 12 | + |
| 13 | + livecheck do |
| 14 | + url "https://download.qt.io/official_releases/qt/5.15/" |
| 15 | + regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i) |
| 16 | + end |
| 17 | + |
| 18 | + bottle do |
| 19 | + root_url "https://github.com/lucydodo/homebrew-tap/releases/download/sqlb-qt@5-5.15.16_1" |
| 20 | + sha256 cellar: :any, arm64_sonoma: "be4927a0d13ae0decd8b1ad449adf3d0290e57b14505d0fcc3e7d4f2895ea2fc" |
| 21 | + end |
| 22 | + |
| 23 | + keg_only :versioned_formula |
| 24 | + |
| 25 | + depends_on arch: :arm64 |
| 26 | + |
| 27 | + # Fix build with Xcode 14.3. |
| 28 | + # https://bugreports.qt.io/browse/QTBUG-112906 |
| 29 | + patch do |
| 30 | + url "https://invent.kde.org/qt/qt/qtlocation-mapboxgl/-/commit/5a07e1967dcc925d9def47accadae991436b9686.diff" |
| 31 | + sha256 "4f433bb009087d3fe51e3eec3eee6e33a51fde5c37712935b9ab96a7d7571e7d" |
| 32 | + directory "qtlocation/src/3rdparty/mapbox-gl-native" |
| 33 | + end |
| 34 | + |
| 35 | + # CVE-2023-51714 |
| 36 | + # Remove with Qt 5.15.17 |
| 37 | + patch do |
| 38 | + url "https://download.qt.io/official_releases/qt/5.15/0001-CVE-2023-51714-qtbase-5.15.diff" |
| 39 | + sha256 "2129058a5e24d98ee80a776c49a58c2671e06c338dffa7fc0154e82eef96c9d4" |
| 40 | + directory "qtbase" |
| 41 | + end |
| 42 | + patch do |
| 43 | + url "https://download.qt.io/official_releases/qt/5.15/0002-CVE-2023-51714-qtbase-5.15.diff" |
| 44 | + sha256 "99d5d32527e767d6ab081ee090d92e0b11f27702619a4af8966b711db4f23e42" |
| 45 | + directory "qtbase" |
| 46 | + end |
| 47 | + |
| 48 | + # CVE-2024-25580 |
| 49 | + # Remove with Qt 5.15.17 |
| 50 | + patch do |
| 51 | + url "https://download.qt.io/official_releases/qt/5.15/CVE-2024-25580-qtbase-5.15.diff" |
| 52 | + sha256 "7cc9bf74f696de8ec5386bb80ce7a2fed5aa3870ac0e2c7db4628621c5c1a731" |
| 53 | + directory "qtbase" |
| 54 | + end |
| 55 | + |
| 56 | + # CVE-2024-36048 |
| 57 | + # Remove with Qt 5.15.17 |
| 58 | + patch do |
| 59 | + url "https://download.qt.io/official_releases/qt/5.15/CVE-2024-36048-qtnetworkauth-5.15.diff" |
| 60 | + sha256 "e5d385d636b5241b59ac16c4a75359e21e510506b26839a4e2033891245f33f9" |
| 61 | + directory "qtnetworkauth" |
| 62 | + end |
| 63 | + |
| 64 | + # CVE-2024-39936 |
| 65 | + # Remove with Qt 5.15.18 |
| 66 | + patch do |
| 67 | + url "https://download.qt.io/official_releases/qt/5.15/CVE-2024-39936-qtbase-5.15.patch" |
| 68 | + sha256 "2cc23afba9d7e48f8faf8664b4c0324a9ac31a4191da3f18bd0accac5c7704de" |
| 69 | + directory "qtbase" |
| 70 | + end |
| 71 | + |
| 72 | + def install |
| 73 | + # Determine the minimum macOS version. |
| 74 | + # Match the required version of the DB Browser for SQLite app. |
| 75 | + ENV["MACOSX_DEPLOYMENT_TARGET"] = "10.13" |
| 76 | + ENV.append "CPPFLAGS", "-mmacosx-version-min=10.13" |
| 77 | + ENV.append "LDFLAGS", "-mmacosx-version-min=10.13" |
| 78 | + |
| 79 | + args = [ |
| 80 | + "-device-option", |
| 81 | + "QMAKE_APPLE_DEVICE_ARCHS=x86_64 arm64", |
| 82 | + "-verbose", |
| 83 | + "-prefix", |
| 84 | + prefix.to_s, |
| 85 | + "-release", |
| 86 | + "-opensource", |
| 87 | + "-confirm-license", |
| 88 | + "-nomake", |
| 89 | + "examples", |
| 90 | + "-nomake", |
| 91 | + "tests", |
| 92 | + ] |
| 93 | + |
| 94 | + args << "-no-rpath" |
| 95 | + args << "-no-assimp" if Hardware::CPU.arm? |
| 96 | + |
| 97 | + # Work around Clang failure in bundled Boost and V8: |
| 98 | + # error: integer value -1 is outside the valid range of values [0, 3] for this enumeration type |
| 99 | + if DevelopmentTools.clang_build_version >= 1500 |
| 100 | + args << "QMAKE_CXXFLAGS+=-Wno-enum-constexpr-conversion" |
| 101 | + inreplace "qtwebengine/src/3rdparty/chromium/build/config/compiler/BUILD.gn", |
| 102 | + /^\s*"-Wno-thread-safety-attributes",$/, |
| 103 | + "\\0 \"-Wno-enum-constexpr-conversion\"," |
| 104 | + end |
| 105 | + |
| 106 | + system "./configure", *args |
| 107 | + system "make" |
| 108 | + system "make", "install" |
| 109 | + |
| 110 | + # Install a qtversion.xml to ease integration with QtCreator |
| 111 | + # As far as we can tell, there is no ability to make the Qt buildsystem |
| 112 | + # generate this and it's in the Qt source tarball at all. |
| 113 | + # Multiple people on StackOverflow have asked for this and it's a pain |
| 114 | + # to add Qt to QtCreator (the official IDE) without it. |
| 115 | + # Given Qt upstream seems extremely unlikely to accept this: let's ship our |
| 116 | + # own version. |
| 117 | + # If you read this and you can eliminate it or upstream it: please do! |
| 118 | + # More context in https://github.com/Homebrew/homebrew-core/pull/124923 |
| 119 | + qtversion_xml = share/"qtcreator/QtProject/qtcreator/qtversion.xml" |
| 120 | + qtversion_xml.dirname.mkpath |
| 121 | + qtversion_xml.write <<~XML |
| 122 | + <?xml version="1.0" encoding="UTF-8"?> |
| 123 | + <!DOCTYPE QtCreatorQtVersions> |
| 124 | + <qtcreator> |
| 125 | + <data> |
| 126 | + <variable>QtVersion.0</variable> |
| 127 | + <valuemap type="QVariantMap"> |
| 128 | + <value type="int" key="Id">1</value> |
| 129 | + <value type="QString" key="Name">Qt %{Qt:Version} (#{opt_prefix})</value> |
| 130 | + <value type="QString" key="QMakePath">#{opt_bin}/qmake</value> |
| 131 | + <value type="QString" key="QtVersion.Type">Qt4ProjectManager.QtVersion.Desktop</value> |
| 132 | + <value type="QString" key="autodetectionSource"></value> |
| 133 | + <value type="bool" key="isAutodetected">false</value> |
| 134 | + </valuemap> |
| 135 | + </data> |
| 136 | + <data> |
| 137 | + <variable>Version</variable> |
| 138 | + <value type="int">1</value> |
| 139 | + </data> |
| 140 | + </qtcreator> |
| 141 | + XML |
| 142 | + |
| 143 | + # Move `*.app` bundles into `libexec` to expose them to `brew linkapps` and |
| 144 | + # because we don't like having them in `bin`. |
| 145 | + bin.glob("*.app") do |app| |
| 146 | + libexec.install app |
| 147 | + bin.write_exec_script libexec/app.basename/"Contents/MacOS"/app.stem |
| 148 | + end |
| 149 | + end |
| 150 | + |
| 151 | + def caveats |
| 152 | + <<~EOS |
| 153 | + We agreed to the Qt open source license for you. |
| 154 | + If this is unacceptable you should uninstall. |
| 155 | +
|
| 156 | + You can add Homebrew's Qt to QtCreator's "Qt Versions" in: |
| 157 | + Preferences > Qt Versions > Link with Qt... |
| 158 | + pressing "Choose..." and selecting as the Qt installation path: |
| 159 | + #{opt_prefix} |
| 160 | + EOS |
| 161 | + end |
| 162 | + |
| 163 | + test do |
| 164 | + (testpath/"hello.pro").write <<~EOS |
| 165 | + QT += core |
| 166 | + QT -= gui |
| 167 | + TARGET = hello |
| 168 | + CONFIG += console |
| 169 | + CONFIG -= app_bundle |
| 170 | + TEMPLATE = app |
| 171 | + SOURCES += main.cpp |
| 172 | + EOS |
| 173 | + |
| 174 | + (testpath/"main.cpp").write <<~EOS |
| 175 | + #include <QCoreApplication> |
| 176 | + #include <QDebug> |
| 177 | +
|
| 178 | + int main(int argc, char *argv[]) |
| 179 | + { |
| 180 | + QCoreApplication a(argc, argv); |
| 181 | + qDebug() << "Hello World!"; |
| 182 | + return 0; |
| 183 | + } |
| 184 | + EOS |
| 185 | + |
| 186 | + # Work around "error: no member named 'signbit' in the global namespace" |
| 187 | + ENV.delete "CPATH" |
| 188 | + |
| 189 | + system bin/"qmake", testpath/"hello.pro" |
| 190 | + system "make" |
| 191 | + assert_path_exists testpath/"hello" |
| 192 | + assert_path_exists testpath/"main.o" |
| 193 | + system "./hello" |
| 194 | + end |
| 195 | +end |
0 commit comments