homebrew-core/Formula/global.rb

130 lines
5.3 KiB
Ruby

class Global < Formula
include Language::Python::Shebang
desc "Source code tag system"
homepage "https://www.gnu.org/software/global/"
url "https://ftp.gnu.org/gnu/global/global-6.6.9.tar.gz"
mirror "https://ftpmirror.gnu.org/global/global-6.6.9.tar.gz"
sha256 "aacba0fa8d60ca645e62f312dcd23b47ed48a081aa0fb1563cff4702d9d1fad5"
license "GPL-3.0-or-later"
bottle do
sha256 arm64_ventura: "8d1198b19e8434e3efd55a350ceb8025f9d8e3829379c1158b196453f5fc8726"
sha256 arm64_monterey: "16be70332826b4f6fff1fe329261c3e6d0c191ffa6c072aaee67f251f4884ec4"
sha256 arm64_big_sur: "4db854ebdb0400e322b10cc71730568313c6723a9678360b316fc547684f06a4"
sha256 ventura: "759433f9ee88cf432a33fafb16d2691e191a1cab98866f14c2cf17340ecccefb"
sha256 monterey: "4b4df3d890c28bfdb765942a82781a1f2c28731e2b546592a37f361082360101"
sha256 big_sur: "fde855f3b4b68c2bf34e33fe170bce3f53abe8ab76522aabe3d5c20c750d5d03"
sha256 x86_64_linux: "f027aac458584bd59fa1d33033c62440af0521141759bf5e0199ab96ff9a02f6"
end
head do
url ":pserver:anonymous:@cvs.savannah.gnu.org:/sources/global", using: :cvs
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "bison" => :build
depends_on "flex" => :build
## gperf is provided by OSX Command Line Tools.
depends_on "libtool" => :build
end
depends_on "libtool"
depends_on "ncurses"
depends_on "python@3.11"
depends_on "sqlite"
depends_on "universal-ctags"
skip_clean "lib/gtags"
resource "Pygments" do
url "https://files.pythonhosted.org/packages/e0/ef/5905cd3642f2337d44143529c941cc3a02e5af16f0f65f81cbef7af452bb/Pygments-2.13.0.tar.gz"
sha256 "56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"
end
def install
system "sh", "reconf.sh" if build.head?
python3 = "python3.11"
ENV.prepend_create_path "PYTHONPATH", libexec/Language::Python.site_packages(python3)
resource("Pygments").stage do
system python3, *Language::Python.setup_install_args(libexec, python3)
end
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--sysconfdir=#{etc}
--with-sqlite3=#{Formula["sqlite"].opt_prefix}
--with-universal-ctags=#{Formula["universal-ctags"].opt_bin}/ctags
]
system "./configure", *args
system "make", "install"
rewrite_shebang detected_python_shebang, share/"gtags/script/pygments_parser.py"
bin.env_script_all_files(libexec/"bin", PYTHONPATH: ENV["PYTHONPATH"])
etc.install "gtags.conf"
# we copy these in already
cd share/"gtags" do
rm %w[README COPYING LICENSE INSTALL ChangeLog AUTHORS]
end
end
test do
(testpath/"test.c").write <<~EOS
int c2func (void) { return 0; }
void cfunc (void) {int cvar = c2func(); }")
EOS
(testpath/"test.py").write <<~EOS
def py2func ():
return 0
def pyfunc ():
pyvar = py2func()
EOS
system bin/"gtags", "--gtagsconf=#{share}/gtags/gtags.conf", "--gtagslabel=pygments"
assert_match "test.c", shell_output("#{bin}/global -d cfunc")
assert_match "test.c", shell_output("#{bin}/global -d c2func")
assert_match "test.c", shell_output("#{bin}/global -r c2func")
assert_match "test.py", shell_output("#{bin}/global -d pyfunc")
assert_match "test.py", shell_output("#{bin}/global -d py2func")
assert_match "test.py", shell_output("#{bin}/global -r py2func")
assert_match "test.c", shell_output("#{bin}/global -s cvar")
assert_match "test.py", shell_output("#{bin}/global -s pyvar")
system bin/"gtags", "--gtagsconf=#{share}/gtags/gtags.conf", "--gtagslabel=exuberant-ctags"
# ctags only yields definitions
assert_match "test.c", shell_output("#{bin}/global -d cfunc # passes")
assert_match "test.c", shell_output("#{bin}/global -d c2func # passes")
assert_match "test.py", shell_output("#{bin}/global -d pyfunc # passes")
assert_match "test.py", shell_output("#{bin}/global -d py2func # passes")
refute_match "test.c", shell_output("#{bin}/global -r c2func # correctly fails")
refute_match "test.c", shell_output("#{bin}/global -s cvar # correctly fails")
refute_match "test.py", shell_output("#{bin}/global -r py2func # correctly fails")
refute_match "test.py", shell_output("#{bin}/global -s pyvar # correctly fails")
# Test the default parser
system bin/"gtags", "--gtagsconf=#{share}/gtags/gtags.conf", "--gtagslabel=default"
assert_match "test.c", shell_output("#{bin}/global -d cfunc")
assert_match "test.c", shell_output("#{bin}/global -d c2func")
assert_match "test.c", shell_output("#{bin}/global -r c2func")
assert_match "test.c", shell_output("#{bin}/global -s cvar")
# Test tag files in sqlite format
system bin/"gtags", "--gtagsconf=#{share}/gtags/gtags.conf", "--gtagslabel=pygments", "--sqlite3"
assert_match "test.c", shell_output("#{bin}/global -d cfunc")
assert_match "test.c", shell_output("#{bin}/global -d c2func")
assert_match "test.c", shell_output("#{bin}/global -r c2func")
assert_match "test.py", shell_output("#{bin}/global -d pyfunc")
assert_match "test.py", shell_output("#{bin}/global -d py2func")
assert_match "test.py", shell_output("#{bin}/global -r py2func")
assert_match "test.c", shell_output("#{bin}/global -s cvar")
assert_match "test.py", shell_output("#{bin}/global -s pyvar")
end
end