aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorChristian E. Hopps2014-09-07 22:00:29 -0400
committerMike McQuaid2014-09-15 09:44:51 +0100
commit9f523d3b3f5f93ef6c4075279fe5b965cfbd3cfe (patch)
treee1a7f7787bbcc15ee593ed7c23e1c178b680b745 /Library
parentc7bfb9e213d7aab1f7b415426d7dae2e18ded16d (diff)
downloadhomebrew-9f523d3b3f5f93ef6c4075279fe5b965cfbd3cfe.tar.bz2
global: add pygments parser option.
Closes #32148.
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/global.rb75
1 files changed, 75 insertions, 0 deletions
diff --git a/Library/Formula/global.rb b/Library/Formula/global.rb
index 46734fac2..73280fd4a 100644
--- a/Library/Formula/global.rb
+++ b/Library/Formula/global.rb
@@ -21,12 +21,25 @@ class Global < Formula
end
option "with-exuberant-ctags", "Enable Exuberant Ctags as a plug-in parser"
+ option "with-pygments", "Enable Pygments as a plug-in parser (should enable exuberent-ctags too)"
if build.with? "exuberant-ctags"
depends_on "ctags"
skip_clean "lib/gtags/exuberant-ctags.la"
end
+ if build.with? "pygments"
+ if build.without? "exuberant-ctags"
+ opoo "suggest --with-exuberant-ctags as pygments parser symbol only without"
+ "to create definition and reference tags without it all tags will be symbols"
+ end
+ resource 'pygments' do
+ url "https://pypi.python.org/packages/source/P/Pygments/Pygments-1.6.tar.gz"
+ sha1 "53d831b83b1e4d4f16fec604057e70519f9f02fb"
+ end
+ skip_clean "lib/gtags/pygments-parser.la"
+ end
+
def install
system "sh", "reconf.sh" if build.head?
@@ -40,9 +53,19 @@ class Global < Formula
args << "--with-exuberant-ctags=#{HOMEBREW_PREFIX}/bin/ctags"
end
+ if build.with? "pygments"
+ ENV.prepend_create_path 'PYTHONPATH', libexec+'lib/python2.7/site-packages'
+ pygments_args = [ "build", "install", "--prefix=#{libexec}" ]
+ resource('pygments').stage { system "python", "setup.py", *pygments_args }
+ end
+
system "./configure", *args
system "make install"
+ if build.with? "pygments"
+ bin.env_script_all_files(libexec+'bin', :PYTHONPATH => ENV['PYTHONPATH'])
+ end
+
etc.install "gtags.conf"
# we copy these in already
@@ -50,4 +73,56 @@ class Global < Formula
rm %w[README COPYING LICENSE INSTALL ChangeLog AUTHORS]
end
end
+ test do
+ (testpath/'test.c').write <<-EOF.undent
+ int c2func (void) { return 0; }
+ void cfunc (void) {int cvar = c2func(); }")
+ EOF
+ if build.with? "pygments" or build.with? "exuberant-ctags"
+ (testpath/'test.py').write <<-EOF
+ def py2func ():
+ return 0
+ def pyfunc ():
+ pyvar = py2func()
+ EOF
+ end
+ if build.with? "pygments"
+ assert shell_output("#{bin}/gtags --gtagsconf=#{share}/gtags/gtags.conf --gtagslabel=pygments .")
+ if build.with? "exuberant-ctags"
+ assert shell_output("#{bin}/global -d cfunc").include?("test.c")
+ assert shell_output("#{bin}/global -d c2func").include?("test.c")
+ assert shell_output("#{bin}/global -r c2func").include?("test.c")
+ assert shell_output("#{bin}/global -s cvar").include?("test.c")
+ assert shell_output("#{bin}/global -d pyfunc").include?("test.py")
+ assert shell_output("#{bin}/global -r py2func").include?("test.py")
+ assert shell_output("#{bin}/global -s pyvar").include?("test.py")
+ else
+ # Everything is a symbol in this case
+ assert shell_output("#{bin}/global -s cfunc").include?("test.c")
+ assert shell_output("#{bin}/global -s c2func").include?("test.c")
+ assert shell_output("#{bin}/global -s cvar").include?("test.c")
+ assert shell_output("#{bin}/global -s pyfunc").include?("test.py")
+ assert shell_output("#{bin}/global -s py2func").include?("test.py")
+ assert shell_output("#{bin}/global -s pyvar").include?("test.py")
+ end
+ end
+ if build.with? "exuberant-ctags"
+ assert shell_output("#{bin}/gtags --gtagsconf=#{share}/gtags/gtags.conf --gtagslabel=exuberant-ctags .")
+ # ctags only yields definitions
+ assert shell_output("#{bin}/global -d cfunc # passes").include?("test.c")
+ assert shell_output("#{bin}/global -d c2func # passes").include?("test.c")
+ assert !shell_output("#{bin}/global -r c2func # correctly fails").include?("test.c")
+ assert !shell_output("#{bin}/global -s cvar # correctly fails").include?("test.c")
+ assert shell_output("#{bin}/global -d pyfunc # passes").include?("test.py")
+ assert shell_output("#{bin}/global -d py2func # passes").include?("test.py")
+ assert !shell_output("#{bin}/global -r py2func # correctly fails").include?("test.py")
+ assert !shell_output("#{bin}/global -s pyvar # correctly fails").include?("test.py")
+ end
+ # C should work with default parser for any build
+ assert shell_output("#{bin}/gtags --gtagsconf=#{share}/gtags/gtags.conf --gtagslabel=default .")
+ assert shell_output("#{bin}/global -d cfunc").include?("test.c")
+ assert shell_output("#{bin}/global -d c2func").include?("test.c")
+ assert shell_output("#{bin}/global -r c2func").include?("test.c")
+ assert shell_output("#{bin}/global -s cvar").include?("test.c")
+ end
end