From cad16aa181054297d3fcd154d732ed4b5fe63052 Mon Sep 17 00:00:00 2001 From: SeongTae Jeong Date: Mon, 3 Mar 2025 22:12:05 +0900 Subject: [PATCH] Add Qt formula --- Formula/sqlb-qt@5.rb | 195 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 Formula/sqlb-qt@5.rb diff --git a/Formula/sqlb-qt@5.rb b/Formula/sqlb-qt@5.rb new file mode 100644 index 0000000..a071234 --- /dev/null +++ b/Formula/sqlb-qt@5.rb @@ -0,0 +1,195 @@ +# Patches for Qt must be at the very least submitted to Qt's Gerrit codereview +# rather than their bug-report Jira. The latter is rarely reviewed by Qt. +class SqlbQtAT5 < Formula + desc "Cross-platform application and UI framework" + homepage "https://www.qt.io/" + url "https://download.qt.io/official_releases/qt/5.15/5.15.16/single/qt-everywhere-opensource-src-5.15.16.tar.xz" + # version "5.15.16" + # NOTE: Use *.diff for GitLab/KDE patches to avoid their checksums changing. + sha256 "efa99827027782974356aceff8a52bd3d2a8a93a54dd0db4cca41b5e35f1041c" + license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "LGPL-3.0-only"] + revision 1 + + livecheck do + url "https://download.qt.io/official_releases/qt/5.15/" + regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i) + end + + bottle do + root_url "https://github.com/lucydodo/homebrew-tap/releases/download/sqlb-qt@5-5.15.16_1" + sha256 cellar: :any, arm64_sonoma: "be4927a0d13ae0decd8b1ad449adf3d0290e57b14505d0fcc3e7d4f2895ea2fc" + end + + keg_only :versioned_formula + + depends_on arch: :arm64 + + # Fix build with Xcode 14.3. + # https://bugreports.qt.io/browse/QTBUG-112906 + patch do + url "https://invent.kde.org/qt/qt/qtlocation-mapboxgl/-/commit/5a07e1967dcc925d9def47accadae991436b9686.diff" + sha256 "4f433bb009087d3fe51e3eec3eee6e33a51fde5c37712935b9ab96a7d7571e7d" + directory "qtlocation/src/3rdparty/mapbox-gl-native" + end + + # CVE-2023-51714 + # Remove with Qt 5.15.17 + patch do + url "https://download.qt.io/official_releases/qt/5.15/0001-CVE-2023-51714-qtbase-5.15.diff" + sha256 "2129058a5e24d98ee80a776c49a58c2671e06c338dffa7fc0154e82eef96c9d4" + directory "qtbase" + end + patch do + url "https://download.qt.io/official_releases/qt/5.15/0002-CVE-2023-51714-qtbase-5.15.diff" + sha256 "99d5d32527e767d6ab081ee090d92e0b11f27702619a4af8966b711db4f23e42" + directory "qtbase" + end + + # CVE-2024-25580 + # Remove with Qt 5.15.17 + patch do + url "https://download.qt.io/official_releases/qt/5.15/CVE-2024-25580-qtbase-5.15.diff" + sha256 "7cc9bf74f696de8ec5386bb80ce7a2fed5aa3870ac0e2c7db4628621c5c1a731" + directory "qtbase" + end + + # CVE-2024-36048 + # Remove with Qt 5.15.17 + patch do + url "https://download.qt.io/official_releases/qt/5.15/CVE-2024-36048-qtnetworkauth-5.15.diff" + sha256 "e5d385d636b5241b59ac16c4a75359e21e510506b26839a4e2033891245f33f9" + directory "qtnetworkauth" + end + + # CVE-2024-39936 + # Remove with Qt 5.15.18 + patch do + url "https://download.qt.io/official_releases/qt/5.15/CVE-2024-39936-qtbase-5.15.patch" + sha256 "2cc23afba9d7e48f8faf8664b4c0324a9ac31a4191da3f18bd0accac5c7704de" + directory "qtbase" + end + + def install + # Determine the minimum macOS version. + # Match the required version of the DB Browser for SQLite app. + ENV["MACOSX_DEPLOYMENT_TARGET"] = "10.13" + ENV.append "CPPFLAGS", "-mmacosx-version-min=10.13" + ENV.append "LDFLAGS", "-mmacosx-version-min=10.13" + + args = [ + "-device-option", + "QMAKE_APPLE_DEVICE_ARCHS=x86_64 arm64", + "-verbose", + "-prefix", + prefix.to_s, + "-release", + "-opensource", + "-confirm-license", + "-nomake", + "examples", + "-nomake", + "tests", + ] + + args << "-no-rpath" + args << "-no-assimp" if Hardware::CPU.arm? + + # Work around Clang failure in bundled Boost and V8: + # error: integer value -1 is outside the valid range of values [0, 3] for this enumeration type + if DevelopmentTools.clang_build_version >= 1500 + args << "QMAKE_CXXFLAGS+=-Wno-enum-constexpr-conversion" + inreplace "qtwebengine/src/3rdparty/chromium/build/config/compiler/BUILD.gn", + /^\s*"-Wno-thread-safety-attributes",$/, + "\\0 \"-Wno-enum-constexpr-conversion\"," + end + + system "./configure", *args + system "make" + system "make", "install" + + # Install a qtversion.xml to ease integration with QtCreator + # As far as we can tell, there is no ability to make the Qt buildsystem + # generate this and it's in the Qt source tarball at all. + # Multiple people on StackOverflow have asked for this and it's a pain + # to add Qt to QtCreator (the official IDE) without it. + # Given Qt upstream seems extremely unlikely to accept this: let's ship our + # own version. + # If you read this and you can eliminate it or upstream it: please do! + # More context in https://github.com/Homebrew/homebrew-core/pull/124923 + qtversion_xml = share/"qtcreator/QtProject/qtcreator/qtversion.xml" + qtversion_xml.dirname.mkpath + qtversion_xml.write <<~XML + + + + + QtVersion.0 + + 1 + Qt %{Qt:Version} (#{opt_prefix}) + #{opt_bin}/qmake + Qt4ProjectManager.QtVersion.Desktop + + false + + + + Version + 1 + + + XML + + # Move `*.app` bundles into `libexec` to expose them to `brew linkapps` and + # because we don't like having them in `bin`. + bin.glob("*.app") do |app| + libexec.install app + bin.write_exec_script libexec/app.basename/"Contents/MacOS"/app.stem + end + end + + def caveats + <<~EOS + We agreed to the Qt open source license for you. + If this is unacceptable you should uninstall. + + You can add Homebrew's Qt to QtCreator's "Qt Versions" in: + Preferences > Qt Versions > Link with Qt... + pressing "Choose..." and selecting as the Qt installation path: + #{opt_prefix} + EOS + end + + test do + (testpath/"hello.pro").write <<~EOS + QT += core + QT -= gui + TARGET = hello + CONFIG += console + CONFIG -= app_bundle + TEMPLATE = app + SOURCES += main.cpp + EOS + + (testpath/"main.cpp").write <<~EOS + #include + #include + + int main(int argc, char *argv[]) + { + QCoreApplication a(argc, argv); + qDebug() << "Hello World!"; + return 0; + } + EOS + + # Work around "error: no member named 'signbit' in the global namespace" + ENV.delete "CPATH" + + system bin/"qmake", testpath/"hello.pro" + system "make" + assert_path_exists testpath/"hello" + assert_path_exists testpath/"main.o" + system "./hello" + end +end