sconsnightly-build

Exclude deprecated files from build using SCons


How can I tell Scons to exclude some files from build sources.

I have all files in folder called src. Following is my code snippet which include files for build.

env = Environment()
env.Program(target='project’,  source=[Glob(’src/*.cpp’)]   )

Thanks in advance


Solution

  • If you check the existing documentation, the MAN page as well as the UserGuide, you'll find that the Glob() command supports the exclude parameter. You can use it to specify a list of patterns that should get excluded from the returned list.

    Another option is to simply filter the list of found entries yourself, remember that you have the full power of Python at your fingertips:

    excluded_files = ['src/a.cpp', 'src/b.cpp']
    sources = [x for x in Glob('src/*.cpp') if str(x) not in excluded_files]
    env.Program('project', sources)