
SideEffect(side_effect, target)

A side effect is a target that is created as a side effect of building other targets. (For example, a Windows PDB file is created as a side effect of building the .obj files for a static library.) This method declares side_effect as a side effect of building target. Both side_effect and target can be a list, a file name, or a node. If a target is a side effect of multiple build commands, SCons will ensure that only one set of commands is executed at a time. Consequently, you only need to use this method for side-effect targets that are built as a result of multiple build commands.

It should be noted that side effects are not automatically cleaned by scons -c. To do that, please see Clean.

For example, if there are two commands that write information to a shared log file, the two commands should not be run in parallel:

The SideEffect() method can be used to say that these two commands should not be run at the same time. It can be specified a number of ways:

or equivalently:

Side effects accumulate, so this sequence is equivalent as well:

As is this sequence:

The SideEffect() method returns a list of the side-effect files, so this will also work:

The file need not exist (or ever be created); by specifying a dummy side-effect file, this method still prevents parallel builds:

TODO: Add an example of a Builder that contains a SideEffect() call.

SConsMethods/SideEffect (last edited 2010-07-03 15:43:45 by JustinDearing)