Search code examples
makefileprojectack

Can ack be coerced into searching a complicated project


ack is a great tool for searching, especially if everything you want to find is in nested directories below a top project dir.

I'd like to search a number of different directory trees, in order to search my whole project.

I could do something like this (there are 5 or 6 more directories I'd include):

ack sometext . ../../Libraries/CMSIS/Device/ST/STM32F4xx/ ../../Libraries/CMSIS/

I've also tried doing it via the makefile, where I'd make ack a phony target, invoking ack on the directories Makefile knows about. This works, but the syntax to invoke it is unfortunate:

gmake ack SVAL=sometext

where in the Makefile:

ack:
    $(ACK) $(SVAL) $(LIB_DIRS) $(DEVICE_DIRS) $(OTHER_PROJECT_DIRS)

Ideally, there would be something I could embed in the .ackrc to define the directories that ack searches. Anyone have a favorite way to use ack to search a complicated project directory structure?


Solution

  • Since ack can do what I want, with a complicated command line. My best answer to date is to embed it in a bash script, so I would type:

    ./pack foobar
    

    To search my entire project for foobar.

    The script pack would look like this:

    #!/bin/bash
    CONTEXT=-C1
    c:/bin/ack $CONTEXT $* . ../../Libraries/CMSIS/Device/ST/STM32F4xx/ \
    ../../Libraries/CMSIS/
    

    Still would prefer a .ackrc solution.