homebrew-core/Formula/global.rb
2020-01-11 11:00:23 +01:00

104 lines
4.1 KiB
Ruby

class Global < Formula
desc "Source code tag system"
homepage "https://www.gnu.org/software/global/"
url "https://ftp.gnu.org/gnu/global/global-6.6.4.tar.gz"
mirror "https://ftpmirror.gnu.org/global/global-6.6.4.tar.gz"
sha256 "987e8cb956c53f8ebe4453b778a8fde2037b982613aba7f3e8e74bcd05312594"
revision 1
bottle do
sha256 "748524c4b316196e41e0f54df683117c61f7dfdbab1c3e641c36ae4eed7f1013" => :catalina
sha256 "848b4e78c1f507bc4356b285164368641125194e730accf46c540af5806a600f" => :mojave
sha256 "ba9cdd8c988ca4aff95538b8d30cb9f97c99dd6f5e91e296db121c8b53459cf0" => :high_sierra
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 "ctags"
depends_on "python@3.8"
skip_clean "lib/gtags"
resource "Pygments" do
url "https://files.pythonhosted.org/packages/cb/9f/27d4844ac5bf158a33900dbad7985951e2910397998e85712da03ce125f0/Pygments-2.5.2.tar.gz"
sha256 "98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe"
end
def install
system "sh", "reconf.sh" if build.head?
xy = Language::Python.major_minor_version "python3"
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python#{xy}/site-packages"
pygments_args = %W[build install --prefix=#{libexec}]
resource("Pygments").stage { system "python3", "setup.py", *pygments_args }
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--sysconfdir=#{etc}
--with-exuberant-ctags=#{Formula["ctags"].opt_bin}/ctags
]
system "./configure", *args
system "make", "install"
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
assert shell_output("#{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")
assert shell_output("#{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")
assert_no_match(/test\.c/, shell_output("#{bin}/global -r c2func # correctly fails"))
assert_no_match(/test\.c/, shell_output("#{bin}/global -s cvar # correctly fails"))
assert_no_match(/test\.py/, shell_output("#{bin}/global -r py2func # correctly fails"))
assert_no_match(/test\.py/, shell_output("#{bin}/global -s pyvar # correctly fails"))
# Test the default parser
assert shell_output("#{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")
end
end