I am trying to improve the performance of our builds by caching the results of system commands that run during the parse stage to determine which source files to include in various libraries.

Some background:

I have a custom rule to generate a shared library from a large set of files.  Separate text files contain the list of functions actually needed for that library.  The functions are generally in separate source files.  I added some SHELL commands to the rule so that we will grep through the text files and determine which source files to include in the library.  This ends up taking quite a lot of time when building, so I thought I'd try to save the results of the grep to a file.

I have run into 2 main problems:

First, I can't figure out a nice boost way to save the grep results in a file, because I need to results of the grep during the parsing stage, but any files I generate using boost rules will only get created during the update stage.  I tried using the make rule to generate a new file with the results of the grep in it and then just cat this file in my rule, but I don't think this will work due to the parse then update nature of boost.  If someone has a good solution to this I'd love to try it.

This led to my second problem.  I decided I'd need a separate script/rule/whatever to run the grep commands if the file doesn't needs updating or just cat the file if everything is up to date.  I'd like this file to end up in the same place as my .o and .so files.  How do I determine the current output directory for built targets (meaning build-dir/.../linux/gcc/debug or whatever) so I can pass it to my rule/script?

I'd greatly appreciate any help with either of these issues.

Thanks,
Ashley