Build systems are used in all but the smallest software projects to invoke the right build tools on the right files in the right order. A build system must be sound (after a build, generated files consistently reflect the latest source files) and efficient (recheck and rebuild as few build units as possible). Contemporary build systems provide limited efficiency because they lack support for expressing fine-grained file dependencies.
We present a build system called ClearDep that supports the definition of reusable, parameterized, interconnected builders. When run, a builder notifies the build system about required and produced files as well as about other builders whose results are needed. To support fine-grained file dependencies, we generalize the traditional notion of time stamps to allow builders to declare their actual requirements on a file’s content. ClearDep collects the requirements and products of a builder with their stamps in a build summary. This enables ClearDep to provide provably sound and optimal incremental rebuilding, even after changing a builder’s definition itself. We have developed ClearDep as a Java API and used it to implement more than 25 builders. We describe our experience with migrating a larger Ant build script to ClearDep and compare the respective build times.