Chapter 17. Extending SCons: Writing Your Own Builders

Although SCons provides many useful methods for building common software products (programs, libraries, documents, etc.), you frequently want to be able to build some other type of file not supported directly by SCons. Fortunately, SCons makes it very easy to define your own Builder objects for any custom file types you want to build. (In fact, the SCons interfaces for creating Builder objects are flexible enough and easy enough to use that all of the the SCons built-in Builder objects are created using the mechanisms described in this section.)

17.1. Writing Builders That Execute External Commands

The simplest Builder to create is one that executes an external command. For example, if we want to build an output file by running the contents of the input file through a command named foobuild, creating that Builder might look like:

bld = Builder(action = 'foobuild < $SOURCE > $TARGET')
    

All the above line does is create a free-standing Builder object. The next section will show us how to actually use it.