Add SCons files to ack searches
Asked Answered
S

3

6

I love the code search utility ack. It is smart enough to look through Makefiles, but doesn't know about the SConstruct and SConscript files that scons uses. How do I add those to the files that ack will look in?

Schmeltzer answered 28/12, 2010 at 17:25 Comment(0)
A
2

This can't be done using ack's type sets. Makefiles and Rakefiles are hard-coded in the source. I thought you could add a scons type by modifying $HOME/.ackrc and adding --type-set=scons=SConstruct,SConscript, but that will search for a file that ends in ".SConstruct" or ".SConscript".

The easiest workaround is to add the -a (all file types) flag to ack.

If you just want ack to search and be able to filter the SConstruct somehow, then you could add #!/usr/bin/python as the first line of the SConstruct file. Ack will then treat the file as python source code, and you can filter with --python.

Arcane answered 28/12, 2010 at 19:16 Comment(3)
That only seems to work for .scons files, not SConstruct or SConscript.Schmeltzer
Gah, you're right. Just checked the source - "makefile" and "rakefile" are hard-coded exceptions.Arcane
Thanks for looking that up. I was able to modify my local version to add SConstruct and SConscript in the same way makefiles are in there, maybe I'll submit a patch. I must say I'm not crazy about the scons design decision to use files w/out extensions, though I've seen other build systems that do the same.Schmeltzer
V
3

Here is a patch that treats SCons files like make files:

--- ~/bin/ack-old 2011-06-01 15:43:51.000000000 -0600
+++ ~/bin/ack     2011-06-01 15:42:09.000000000 -0600
@@ -1583,6 +1583,8 @@

     return 'skipped' unless is_searchable( $basename );

+    return ('python',TEXT)      if $basename eq 'SConstruct' || $basename eq 'SConscript';
+
     my $lc_basename = lc $basename;
     return ('make',TEXT)        if $lc_basename eq 'makefile' || $lc_basename eq 'gnumakefile';
     return ('rake','ruby',TEXT) if $lc_basename eq 'rakefile';
Verla answered 1/6, 2011 at 21:51 Comment(1)
I'm running the deb package of ack version 1.92 on Ubuntu 10.04, and the same patch can be manually applied to /usr/share/perl5/App/Ack.pm at around line 476.Plunger
A
2

This can't be done using ack's type sets. Makefiles and Rakefiles are hard-coded in the source. I thought you could add a scons type by modifying $HOME/.ackrc and adding --type-set=scons=SConstruct,SConscript, but that will search for a file that ends in ".SConstruct" or ".SConscript".

The easiest workaround is to add the -a (all file types) flag to ack.

If you just want ack to search and be able to filter the SConstruct somehow, then you could add #!/usr/bin/python as the first line of the SConstruct file. Ack will then treat the file as python source code, and you can filter with --python.

Arcane answered 28/12, 2010 at 19:16 Comment(3)
That only seems to work for .scons files, not SConstruct or SConscript.Schmeltzer
Gah, you're right. Just checked the source - "makefile" and "rakefile" are hard-coded exceptions.Arcane
Thanks for looking that up. I was able to modify my local version to add SConstruct and SConscript in the same way makefiles are in there, maybe I'll submit a patch. I must say I'm not crazy about the scons design decision to use files w/out extensions, though I've seen other build systems that do the same.Schmeltzer
B
1

A new ack2 is in development which will allow exact file matching in the .ackrc file. That will enable easier support for Scons and Jam.

Bane answered 26/1, 2012 at 19:49 Comment(1)
See #9508931 for more on this.Whitelivered

© 2022 - 2024 — McMap. All rights reserved.