homebrew-core/Formula/qscintilla2.rb

115 lines
4.2 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"
revision 1
# 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
rebuild 1
sha256 cellar: :any, arm64_monterey: "5529f833ceb54ab3967ac29483c5ec73de4bd56534f1b6cdc5baf0a14190ec42"
sha256 cellar: :any, arm64_big_sur: "2f0778c4cd60bc0a5219d627ec09ca12d556bc9a397dd69f250b7eba73bc4099"
sha256 cellar: :any, monterey: "f0936833a4ce37dc43a82d34c8e572dd3526b3f432ea35363935bbaddf43ceac"
sha256 cellar: :any, big_sur: "cf739239f57e90a78004ceb66c138136a8cb98d1b3ce593f239c0fd6d958ccaa"
sha256 cellar: :any, catalina: "a80e7f2c421e20ccc7134c33cd838c2da22bfb550cb7dd23d9ae08a28a74cc88"
sha256 cellar: :any_skip_relocation, x86_64_linux: "9c4e568914df85c19e9a361eef5bc535a80b52e6b61b3cea5402b8e3851398a5"
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.10"
depends_on "qt@5"
fails_with gcc: "5"
def python3
"python3.10"
end
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 python3, "test.py"
end
end