Please note:The SCons wiki is now restored from the attack in March 2013. All old passwords have been invalidated. Please reset your password if you have an account. If you note missing pages, please report them to Also, new account creation is currently disabled due to an ongoing spam flood (2013/08/27).

Use external files with scons, e.g. a linker script

In some cases, you need to give tools additional files per command line, e.g. a linker script to a linker. The easiest way would be to manipulate the SConscript environment variables, like:

env = Environment()
# force scons to use '/usr/bin/ld' as linker (not gcc)
env['LINK'] = '/usr/bin/ld'
# pass it a linker script per commandline
env['LINKFLAGS']+=' -T '

However, the disadvantages of this are

  1. SCons doesn't know what you're doing
  2. You need to give a filename relative to the SConstruct directory (i.e. 'src/subtree1/')
  3. SCons doesn't add the file to the dependencies (you could do this manually with Depends(program, filename))
  4. It's (of course) unportable (ok, with the linkerscripts example that doesn't make sense, since linkerscripts mostly are unportable, but there maybe more examples, where portability makes sense)

A solution may be to write a custom Builder.

ExternalFiles (last edited 2010-11-05 23:30:39 by WagnerBruna)