Sunday, June 03, 2012

A make pattern


test: run-test1 run-test2

.PHONY: run-test1
run-test1: test1.x
        ./test.x
test1.x: test1.cpp ...
        gcc -o test1.x test1.cpp ...
Of course, in a decent build system, this is a macro Build_Targets_For("foo.cpp"), rather than having to write them all out by hand. Scons may not be the best, but it avoids much clutter.

2 comments:

  1. Observe the meta-pattern: Define individual actions, but have them registered with a bigger action that runs all the actions of a type.

    ReplyDelete
  2. Flip side: make pattern to only run the tests if there is reason to expect that they have changed. Note that we want both: sometimes tests are dependent on time, etc. Want to rerun if the surrounding environment has changed.

    ReplyDelete