Oh Roomba, How I Love Thee
Switching from AOP to OOP - Strategy and Factory Patterns

Auto-dependency Generation

I mentioned in a previous post that I've been ramping up Vera over the last few weeks.  So far, so good.  One question I had for some of the other guys at Verilab was whether there was a way to easily generate dependencies for a collection of Vera files to use in a Makefile.  As it turns out, Vera has some tricks (which I have yet to fully explore) to help manage which files should be compiled without the user needing to do much at all.  However, our very own Will Partain provided an interesting solution that has the potential to solve the general problem of generating dependencies for any build environment. 

His suggestion was to use strace (truss on Solaris) to record a list of file-opening system calls which he then post processes with a Perl script he wrote called trussdep.  The end result theoretically should be similar to what happens when you run clearmake under Clearcase - namely that all dependencies are captured regardless of what you're actually building. 

Here is the suggested make target if you were going to try this with Vera:

TRUSS_ME := /usr/bin/strace -fF -e trace=file

# pattern rule for vera compilation (not pretty):
%.vro : %.vr
@/bin/rm -f $@ [email protected] [email protected]
out_root=`dirname $@` \
&& $(TRUSS_ME) -o [email protected] \
   vera -cmp $(VERA_FLAGS) $(extra_tool_flags) $< $$out_root \
&& $(TRUSSDEP) $@ < [email protected] > [email protected]
@/bin/rm -f [email protected]

(on Solaris, you'll need to use 'truss' rather than Linux's 'strace')

Somewhere in your make stuff, you need to 'include' the .P files.

Big disclaimer -- the above code has not been tested by me (or Will as far as I know).  But the general idea is known to work.

The command that is being run looks like this once you take out all the tricky make stuff:

strace -fF -e trace=file -o a-temp-file vera -cmp <vera flags> <input>.vr

To use "truss" on Solaris, you need to make some modifications as described here:

   truss -something-to-follow-forks \
         -something-to-only-care-about-file-related-syscalls \
-something-to-say-write-the-log-into-a-file \
         vera -cmp <vera flags> <input>.vr

Will -- if I've quoted you incorrectly on any of the stuff above let me know ASAP!  If I get some free time I hope to be able to give it a try.  In the meantime, comments or suggestions for improvement are welcome!