BuildSystem

Projects I have worked on have varied widely in the way that they were structured, but I have always found that they have benefited from specific structure and conventions. The most important goal to achieve is not convenience, but rather consistency.

It is like a game of psychological warfare that can be won with information. As a code body grows, it is likely to become less organized overall. If programmers should be using various utilities in their code, but don't know that the utilities exist, then they will tend to re-write local versions with slightly different interfaces and semantics. In addition, some of the benefits of those global utilities will not be reaped until they are almost universally applied. Consistency becomes a very powerful state for the code to be in, and allows for certain kinds of radical changes to be done in C++ and Java that maintain the essential stability of the code but restructure and generalize it as well.

One of the main tools to make a code body more consistent is an auto-build. In order to achieve this, a directory area must be set aside that is used to get an image of the source tree from the source code control repository. The requirements for an auto-build I am most familiar with are for Unix-based development, but can be adjusted for other platforms such as the Win32 platform.

Unix systems provide a few essential tools for auto-builds: soure code control, cron, make, the compiler and linker. Cron sets up the build process, which can be scheduled for daily or more frequent builds. Make needs to be set up in a specific way so that a hierarchy of directories can be built in dependency-sequence. The cron job also needs to extract all the current changes from the source code control repository before attempting to run make. If no changes have been added, then make need not be run. One of the most useful tools to enable all this is Perl. It consolidates the process control and text processing necessary to read the input fron the source code control system, create log files, and launch make. One last tool to use is email. The results of the build should be sent to all the developers and the version control manager for the project.

The examples I will give will use freely available tools, including CVS, Perl, GNU Make, the GNU Compiler, and the Java Compiler. These tools can be used on a variety of platforms, and are all able to be run from a command-line. This is obviously important for building everything from cron, since any GUI-based tool is better used interactively, however creative you could get with launching it from cron.

Step 1: Organizing the Development Source Tree

Step 2: Creating a Hierarchy of Makefiles

Step 3: Checking Everything into CVS

Step 4: Scripting the Auto-Build

Step 5: Advanced Topics

Additional Discussion: