previous up next print clean
Next: PHILOSOPHY AND PITFALLS Up: Claerbout and Karrenbach: Cake Previous: Defining your own actions

OTHER DIRECTORIES

Both makefiles and cakefiles tend to be self-contained entities, controlling the directory in which they reside but being ignorant of relationships within other directories that are managed by other cakefiles. Sometimes, we can merge the wisdom of two cakefiles by having one invoke the other. There are subtle pitfalls, however, that Dave Nichols taught us how to avoid. If you depend on a file named foo in a sister directory ../Data (which might be created and maintained by someone else) and you need ../Data/foo to be built and up-to-date, the simplest thing you can do is

../Data/foo :  
        cd ../Data;  cake foo

which you probably don't want to do for the subtle reason that the descendants of ../Data/foo will always be rebuilt regardless whether ../Data/foo rebuilds or not (notice that cake does not analyze both cakefiles simultaneously). Instead, you could do

../Data/foo:  if not exist ../Data/foo
        cd ../Data;  cake foo

which would build ../Data/foo the first time (when it didn't exist) but then never again, even if something had changed in the sister directory that made ../Data/foo out of date, so you probably don't want this either. Most likely, below is what you want:

../Data/foo:  if not {{ cd ../Data ; cake -q foo}}
        cd ../Data;  cake foo

which ensures that both ../Data/foo and its descendants are rebuilt if only if they are out-of-date. The way this works is that the construction {{ cd ../Data ; cake -q foo }} is replaced by the return code of running cake -q in the directory ../Data. (We learn from man cake that cake -q returns exit status 0 if targets are up-to-date and 1 otherwise.) Thus the obtuse rule above is an idiom that enables one cakefile to incorporate knowledge of another.


previous up next print clean
Next: PHILOSOPHY AND PITFALLS Up: Claerbout and Karrenbach: Cake Previous: Defining your own actions
Stanford Exploration Project
11/17/1997