Chapter 3. Less Simple Things to Do With Builds

In this chapter, you will see several examples of very simple build configurations using SCons, which will demonstrate how easy it is to use SCons to build programs from several different programming languages on different types of systems.

3.1. Specifying the Name of the Target (Output) File

You've seen that when you call the Program builder method, it builds the resulting program with the same base name as the source file. That is, the following call to build an executable program from the hello.c source file will build an executable program named hello on POSIX systems, and an executable program named hello.exe on Windows systems:


       Program('hello.c')
    

If you want to build a program with a different name than the base of the source file name, you simply put the target file name to the left of the source file name:


       Program('new_hello', 'hello.c')
    

(SCons requires the target file name first, followed by the source file name, so that the order mimics that of an assignment statement in most programming languages, including Python: "program = source files".)

Now SCons will build an executable program named new_hello when run on a POSIX system:


       % scons -Q
       cc -o hello.o -c hello.c
       cc -o new_hello hello.o
    

And SCons will build an executable program named new_hello.exe when run on a Windows system:


       C:\>scons -Q
       cl /Fohello.obj /c hello.c /nologo
       link /nologo /OUT:new_hello.exe hello.obj
       embedManifestExeCheck(target, source, env)