homebrew-core/Formula/qt@5.rb

217 lines
6.9 KiB
Ruby

# 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 QtAT5 < 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.2/single/qt-everywhere-src-5.15.2.tar.xz"
mirror "https://mirrors.dotsrc.org/qtproject/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz"
mirror "https://mirrors.ocf.berkeley.edu/qt/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz"
sha256 "3a530d1b243b5dec00bc54937455471aaa3e56849d2593edb8ded07228202240"
license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "LGPL-3.0-only"]
bottle do
rebuild 1
sha256 cellar: :any, arm64_big_sur: "6128558bbf98848bb762d8e1e532303b694bf120d4f9be16e1a969ba62fa3d22"
sha256 cellar: :any, big_sur: "a11186f808f81ccae91a1b79d14a1014428f744a0943688e2fd2b95ba989ddc2"
sha256 cellar: :any, catalina: "02280e07b5fe37344d834df7901b1040aa9f257d668a8d6b76382bd97bc91a68"
sha256 cellar: :any, mojave: "0089f9216563b73d1920ce1c6e359e2a83e97a07ec8e83162e7c7503bcd36318"
sha256 cellar: :any_skip_relocation, x86_64_linux: "082ee515cd0e4b9f23cf98a6734adf53e73bbb8fd1c1fac1bc8a8d0281902df4"
end
keg_only :versioned_formula
depends_on "pkg-config" => :build
depends_on xcode: :build
depends_on macos: :sierra
uses_from_macos "gperf" => :build
uses_from_macos "bison"
uses_from_macos "flex"
uses_from_macos "sqlite"
on_linux do
depends_on "at-spi2-core"
depends_on "fontconfig"
depends_on "gcc"
depends_on "glib"
depends_on "icu4c"
depends_on "libproxy"
depends_on "libxkbcommon"
depends_on "libice"
depends_on "libsm"
depends_on "libxcomposite"
depends_on "libdrm"
depends_on "mesa"
depends_on "pulseaudio"
depends_on "python@3.9"
depends_on "sdl2"
depends_on "systemd"
depends_on "xcb-util"
depends_on "xcb-util-image"
depends_on "xcb-util-keysyms"
depends_on "xcb-util-renderutil"
depends_on "xcb-util-wm"
depends_on "zstd"
depends_on "wayland"
end
fails_with gcc: "5"
# Find SDK for 11.x macOS
# Upstreamed, remove when Qt updates Chromium
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/92d4cf/qt/5.15.2.diff"
sha256 "fa99c7ffb8a510d140c02694a11e6c321930f43797dbf2fe8f2476680db4c2b2"
end
# Fix build for GCC 11
patch do
url "https://invent.kde.org/qt/qt/qtbase/commit/8252ef5fc6d043004ddf7085e1c1fe1bf2ca39f7.patch"
sha256 "8ab742b991ed5c43e8da4b1ce1982fd38fe611aaac3d57ee37728b59932b518a"
directory "qtbase"
end
# Fix build for GCC 11
patch do
url "https://invent.kde.org/qt/qt/qtbase/commit/cb2da673f53815a5cfe15f50df49b98032429f9e.patch"
sha256 "33304570431c0dd3becc22f3f0911ccfc781a1ce6c7926c3acb08278cd2e60c3"
directory "qtbase"
end
# Fix build for GCC 11
patch do
url "https://invent.kde.org/qt/qt/qtdeclarative/commit/4f08a2da5b0da675cf6a75683a43a106f5a1e7b8.patch"
sha256 "193c2e159eccc0592b7092b1e9ff31ad9556b38462d70633e507822f75d4d24a"
directory "qtdeclarative"
end
# Patch for qmake on ARM
# https://codereview.qt-project.org/c/qt/qtbase/+/327649
if Hardware::CPU.arm?
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/9dc732/qt/qt-split-arch.patch"
sha256 "36915fde68093af9a147d76f88a4e205b789eec38c0c6f422c21ae1e576d45c0"
directory "qtbase"
end
end
def install
args = %W[
-verbose
-prefix #{prefix}
-release
-opensource -confirm-license
-qt-libpng
-qt-libjpeg
-qt-freetype
-qt-pcre
-nomake examples
-nomake tests
-pkg-config
-dbus-runtime
]
if OS.mac?
args << "-no-rpath"
args << "-system-zlib"
if Hardware::CPU.arm?
# Temporarily fixes for Apple Silicon
args << "-skip" << "qtwebengine" << "-no-assimp"
else
# Should be reenabled unconditionally once it is fixed on Apple Silicon
args << "-proprietary-codecs"
end
else
args << "-R#{lib}"
# https://bugreports.qt.io/browse/QTBUG-71564
args << "-no-avx2"
args << "-no-avx512"
args << "-qt-zlib"
# https://bugreports.qt.io/browse/QTBUG-60163
# https://codereview.qt-project.org/c/qt/qtwebengine/+/191880
args += %w[-skip qtwebengine]
args << "-no-sql-mysql"
# Change default mkspec for qmake on Linux to use brewed GCC
inreplace "qtbase/mkspecs/common/g++-base.conf", "$${CROSS_COMPILE}gcc", ENV.cc
inreplace "qtbase/mkspecs/common/g++-base.conf", "$${CROSS_COMPILE}g++", ENV.cxx
end
system "./configure", *args
# Remove reference to shims directory
inreplace "qtbase/mkspecs/qmodule.pri",
/^PKG_CONFIG_EXECUTABLE = .*$/,
"PKG_CONFIG_EXECUTABLE = #{Formula["pkg-config"].opt_bin/"pkg-config"}"
system "make"
ENV.deparallelize
system "make", "install"
# Some config scripts will only find Qt in a "Frameworks" folder
frameworks.install_symlink Dir["#{lib}/*.framework"]
# 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
# Move `*.app` bundles into `libexec` to expose them to `brew linkapps` and
# because we don't like having them in `bin`.
# (Note: This move breaks invocation of Assistant via the Help menu
# of both Designer and Linguist as that relies on Assistant being in `bin`.)
libexec.mkpath
Pathname.glob("#{bin}/*.app") { |app| mv app, libexec }
end
def caveats
s = <<~EOS
We agreed to the Qt open source license for you.
If this is unacceptable you should uninstall.
EOS
if Hardware::CPU.arm?
s += <<~EOS
This version of Qt on Apple Silicon does not include QtWebEngine
EOS
end
s
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 <QCoreApplication>
#include <QDebug>
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_predicate testpath/"hello", :exist?
assert_predicate testpath/"main.o", :exist?
system "./hello"
end
end