0

I'm using SCons to build a very large project, with many buildable sub-projects. I can easily use keyword commands like scons group=ai to build the AI sub-projects with if statements (choosing the right SConscripts based on the keyword command), but I want to make it as easy as possible for others to use scons. Ideally, I'd like to use it like so: scons ai to build the AI components. However, the only single-word command functionality I've found in SCons so far is aliasing, and all the examples are about changing the target. This is not what I want. Since I have a very large project with multiple sub-SConscript files to build the subprojects, I want to call the SConscripts selectively. I've tried code like so:

env.Alias("ai", SConscript("ai/SConscript", 'env'))

but this calls the AI SConscript every time, regardless of whether I use the "ai" alias or a different one. Does anyone know if it is possible to use aliasing this way to selectively call SConscripts based on the alias?

4

1 回答 1

2

正如您所提到的,该Alias()功能仅用于目标。我可以想到两种方法来解决这个问题

Alias() 可以为具有不同目标的同一个别名多次调用,因此您可以为每个 SConscript 中的所有目标调用它,然后您可以在 SConscript 中构建所有内容。这是我的意思的一个例子:

ai/SConscript:

# targets, etc

env.Alias("ai", target1)
env.Alias("ai", target2)
...
env.Alias("ai", targetn)

另一种选择是将一些逻辑放在您的根 SConstruct 中,以便它仅基于命令行参数调用子项目 SConscript。此选项将要求您使用以下形式的命令行参数:group=ai

于 2013-06-26T06:58:11.960 回答