homebrew-core/Formula/qscintilla2.rb

113 lines
4.3 KiB
Ruby

class Qscintilla2 < Formula
desc "Port to Qt of the Scintilla editing component"
homepage "https://www.riverbankcomputing.com/software/qscintilla/intro"
url "https://www.riverbankcomputing.com/static/Downloads/QScintilla/2.13.1/QScintilla_src-2.13.1.tar.gz"
sha256 "800e3d2071a96bcccd7581346af0d2fe28fc30cd68530cb8302685d013afd54a"
license "GPL-3.0-only"
# The downloads page also lists pre-release versions, which use the same file
# name format as stable versions. The only difference is that files for
# stable versions are kept in corresponding version subdirectories and
# pre-release files are in the parent QScintilla directory. The regex below
# omits pre-release versions by only matching tarballs in a version directory.
livecheck do
url "https://www.riverbankcomputing.com/software/qscintilla/download"
regex(%r{href=.*?QScintilla/v?\d+(?:\.\d+)+/QScintilla(?:[._-](?:gpl|src))?[._-]v?(\d+(?:\.\d+)+)\.t}i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "c8fe944fd61b3501cfa69b21945e6ba0bee5de83d054aee61189c2160cb88e45"
sha256 cellar: :any, arm64_big_sur: "b50669602ec28b423ff37fd752d763154870c88f10a6384ced07e77aeb5d594a"
sha256 cellar: :any, big_sur: "39dc87200786163924fbabdabaf1fef976c61fb12d63888047567fabbcfa255b"
sha256 cellar: :any, catalina: "4fc7f6b0dea043e74676c249633979f265f2809d4310cef1cdf45b0b5011cb6f"
sha256 cellar: :any, mojave: "8401229918ea4b92eca28715baa00174957b6143238b4b2f5dac29a17aaaa5ba"
sha256 cellar: :any_skip_relocation, x86_64_linux: "1b686ed9682a25bce057e4b0d9eb69805ead8b5f929bc72b63e84ae6e6353a6e"
end
depends_on "pyqt-builder" => :build
depends_on "sip" => :build
# TODO: use qt when octave can migrate to qt6
depends_on "pyqt@5"
depends_on "python@3.9"
depends_on "qt@5"
on_linux do
depends_on "gcc"
end
fails_with gcc: "5"
def install
args = []
spec = ""
if OS.mac?
# TODO: when using qt 6, modify the spec
spec = (ENV.compiler == :clang) ? "macx-clang" : "macx-g++"
spec << "-arm64" if Hardware::CPU.arm?
args = %W[-config release -spec #{spec}]
end
pyqt = Formula["pyqt@5"]
qt = Formula["qt@5"]
site_packages = Language::Python.site_packages("python3")
cd "src" do
inreplace "qscintilla.pro" do |s|
s.gsub! "QMAKE_POST_LINK += install_name_tool -id @rpath/$(TARGET1) $(TARGET)",
"QMAKE_POST_LINK += install_name_tool -id #{lib}/$(TARGET1) $(TARGET)"
s.gsub! "$$[QT_INSTALL_LIBS]", lib
s.gsub! "$$[QT_INSTALL_HEADERS]", include
# TODO: use qt6 directory layout when octave can migrate to qt6
s.gsub! "$$[QT_INSTALL_TRANSLATIONS]", prefix/"trans"
s.gsub! "$$[QT_INSTALL_DATA]", prefix/"data"
s.gsub! "$$[QT_HOST_DATA]", prefix/"data"
# s.gsub! "$$[QT_INSTALL_TRANSLATIONS]", share/"qt/translations"
# s.gsub! "$$[QT_INSTALL_DATA]", share/"qt"
# s.gsub! "$$[QT_HOST_DATA]", share/"qt"
end
inreplace "features/qscintilla2.prf" do |s|
s.gsub! "$$[QT_INSTALL_LIBS]", lib
s.gsub! "$$[QT_INSTALL_HEADERS]", include
end
system qt.opt_bin/"qmake", "qscintilla.pro", *args
system "make"
system "make", "install"
end
cd "Python" do
mv "pyproject-qt#{qt.version.major}.toml", "pyproject.toml"
(buildpath/"Python/pyproject.toml").append_lines <<~EOS
[tool.sip.project]
sip-include-dirs = ["#{pyqt.opt_prefix/site_packages}/PyQt#{pyqt.version.major}/bindings"]
EOS
# TODO: qt6 options
# --qsci-features-dir #{share}/qt/mkspecs/features
# --api-dir #{share}/qt/qsci/api/python
args = %W[
--target-dir #{prefix/site_packages}
--qsci-features-dir #{prefix}/data/mkspecs/features
--qsci-include-dir #{include}
--qsci-library-dir #{lib}
--api-dir #{prefix}/data/qsci/api/python
]
system "sip-install", *args
end
end
test do
pyqt = Formula["pyqt@5"]
(testpath/"test.py").write <<~EOS
import PyQt#{pyqt.version.major}.Qsci
assert("QsciLexer" in dir(PyQt#{pyqt.version.major}.Qsci))
EOS
system Formula["python@3.9"].opt_bin/"python3", "test.py"
end
end