-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
global.rb
124 lines (106 loc) 路 5.15 KB
/
global.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
class Global < Formula
include Language::Python::Shebang
include Language::Python::Virtualenv
desc "Source code tag system"
homepage "https://www.gnu.org/software/global/"
url "https://ftp.gnu.org/gnu/global/global-6.6.12.tar.gz"
mirror "https://ftpmirror.gnu.org/global/global-6.6.12.tar.gz"
sha256 "542a5b06840e14eca548b4bb60b44c0adcf01024e68eb362f8bf716007885901"
license "GPL-3.0-or-later"
bottle do
rebuild 1
sha256 arm64_sonoma: "b02f7ab847bbff8ed6ae98ba5ae9057e87ceed845a3626863e933a3731dea8c8"
sha256 arm64_ventura: "853208dcab6b2da814d4144e13a385c54c674b83c5660aaf9452e599f8dd9b0e"
sha256 arm64_monterey: "ec4a0d0255b7023bdeb89d98086ff021ef7cdf99cc97c40199ef467c4d5a02ba"
sha256 sonoma: "47b9879a3743bfa7f1dadb1a05c2e45182c03c7722453c0f2b1076d01f77c774"
sha256 ventura: "41a680877f21ca02b2b0aea13da1c8e9ce8722a43e6f8e93363dd73ccc2a6098"
sha256 monterey: "27f2fa10cea92c3e4261ba98f2f164a42cdde4b02de6cf8b8cc50320a8cf452e"
sha256 x86_64_linux: "1423d091f9579d8688e5c20de615a4e54e094e45cb8662f2b670ceee8e947872"
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.12"
depends_on "sqlite"
depends_on "universal-ctags"
skip_clean "lib/gtags"
resource "pygments" do
url "https://files.pythonhosted.org/packages/55/59/8bccf4157baf25e4aa5a0bb7fa3ba8600907de105ebc22b0c78cfbf6f565/pygments-2.17.2.tar.gz"
sha256 "da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"
end
def install
system "sh", "reconf.sh" if build.head?
python3 = "python3.12"
venv = virtualenv_create(libexec, python3)
venv.pip_install resources
args = %W[
--disable-dependency-tracking
--sysconfdir=#{etc}
--with-sqlite3=#{Formula["sqlite"].opt_prefix}
--with-python-interpreter=#{venv.root}/bin/python
--with-universal-ctags=#{Formula["universal-ctags"].opt_bin}/ctags
]
system "./configure", *args, *std_configure_args
system "make", "install"
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