开发者

scons - source/include paths

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


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜