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.3/QScintilla_src-2.13.3.tar.gz"
sha256 "711d28e37c8fccaa8229e8e39a5b3b2d97f3fffc63da10b71c71b84fa3649398"
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: "5f7514bf089c4385d8bb6fc9ae394a94f10a839f571f0a8760cd7675fa1450d6"
sha256 cellar: :any, arm64_big_sur: "942c121fe8d2ceba45c271ffd535b8420e669d39c33cf2ae8c924514c8eb7c83"
sha256 cellar: :any, monterey: "4c2834dfde86fe935083340fd0742bf3ebf6bcfff8591d08bde06c5a84893a4f"
sha256 cellar: :any, big_sur: "be13e0b8b5e441404cf4239bec231109cb3dfa7fc4fbfa58fbd05f9eb1e844af"
sha256 cellar: :any, catalina: "a82243f91a8e6b85af879686f7e3eb45fd1eb1a5b22fb6e2c190b4bb2fa8abb5"
sha256 cellar: :any_skip_relocation, x86_64_linux: "cd59e09e37a09b02219ea6a21dc39b1a1153f3bc81dfb15b54add91de0edf55b"
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