tags:

views:

55

answers:

1

Hi

Let's say I have this directory structure:

  • SConstruct
  • src/
    • a.cpp
    • b.cpp
  • include/
    • a.h
    • b.h

in SConstruct I don't want to specify ['src/a.cpp', 'scr/b.cpp'] every time; I'm looking for some way to set the base source directory to 'src'

any hint? I've been looking into the docs but can't find anything useful

+1  A: 

A couple of options for you:

First, scons likes to use SConscript files for subdirectories. Put an SConscript in src/ and it can refer to local files (and will generate output in a build subdir as well). You can set up your environment once in the SConstruct. Then you "load" the SConscript from your master SConstruct.

SConscript('src/SConscript')

As your project grows, managing SConscript files in subdirectories is easier than putting everything in the master SConstruct.

Second, here's a similar question / answer that might help -- it uses Glob with a very simple example.

Third, since it's just python, you can make a list of files without the prefix and use a list comprehension to build the real list:

file_sources = [ 'a.c', 'b.c' ]
real_sources = [os.path.join('src', f) for f in file_sources]
Dave Bacher