Please note:The SCons wiki is in read-only mode due to ongoing spam/DoS issues. Also, new account creation is currently disabled. We are looking into alternative wiki hosts.

Sometimes you wish that SCons could build a file right after you create its node in the SConscript, before you've finished processing the rest of the SConscript. Maybe the output of that file will determine what other targets you need to build, or what options you build them with. DynamicSourceGenerator and BuildTimeCallback may be able to solve your particular problem, but maybe not. Even if they can, they may be too awkward to use. RightNow fills that gap. When you tell SCons to build a target RightNow, it builds it (if it's out of date), Right Now.

RightNow is a function that takes any list of nodes (such as the return value from a Builder) as its sole argument and builds them all if any are out of date. You can find the code at https://code.edge.launchpad.net/~asomers/sconsaddons/rightnow (for a full list of external SCons Tools check out the ToolsIndex). An example SConstruct is below. In the example, in should contain the name of the file that you wish for your final output.

# vim: syntax=python
env = DefaultEnvironment(tools = ['default', 'rightnow'])
x = Command(['intermediate'], ['in'],
    '''cat $SOURCE > $TARGET'''
    )
env.RightNow(x)

try:
    f = open('intermediate', 'r')
    outname = f.read().rstrip('\n')
    f.close()
    Command([outname], ['intermediate'],
        '''cat $SOURCE > $TARGET'''
        )
except IOError:
    #Intermediate file must not yet exist
    pass

RightNow (last edited 2010-04-13 11:05:22 by DirkBaechle)