SCons - 如何为跨脚本的目标提供显式依赖关系
这是我的主要 SConstruct 文件
env = Environment()
gen_source = env.SConscript(
'generate_sources.scons',
variant_dir='derived_src', src_dir='src',
duplicate=0)
compile_source = env.SConscript('compile.scons',
variant_dir='build', src_dir='derived_src',
duplicate=0)
env.Depends('build/', 'derived_src/')
gen_source
是一个具有一个源生成器目标的脚本,该目标从我的源目录输出 衍生_src/
中的文件,以及 compile_source
是一个具有多个目标的脚本。
如果命令行中没有提供目标,即运行scons
,它将生成源代码然后编译,但如果提供了目标,例如scons pg_test
,那么scons将失败并抱怨 衍生_src/some_file
不存在。
对这种目标关系进行建模的最佳方法是什么?最好我希望改变它的行为,以便它只生成要编译的源代码。
This is my main SConstruct file
env = Environment()
gen_source = env.SConscript(
'generate_sources.scons',
variant_dir='derived_src', src_dir='src',
duplicate=0)
compile_source = env.SConscript('compile.scons',
variant_dir='build', src_dir='derived_src',
duplicate=0)
env.Depends('build/', 'derived_src/')
The gen_source
is a script with one source generator target which outputs files in derived_src/
from my source directory, and compile_source
is a script with multiple targets.
If no target is provided in command line, i.e. run scons
, it will generate sources then compile, but if a target is provided, such as scons pg_test
then scons will fail and complain about derived_src/some_file
does not exist.
What is the best way to model such a relationship of targets? Preferably I hope to change its behaviour such that it only generates the sources that are going to be compiled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您从 gen_source 和compile_source SConscript 执行返回的内容,如果它是一个目标列表,那么我认为像这样设置依赖关系会更有意义:
或者如果您没有返回目标列表,那么在至少,将目录放在相对于根 SConstruct 的位置,如下所示:
进一步的一步是指定这些目录中的文件,可能使用 Glob()
希望有帮助。
Depending on what you are returning from the gen_source and compile_source SConscript executions, if its a list of targets then I think it would make more sense to setup the dependencies like this:
Or if you're not returning a list of targets, then at the very least, put the directories relative to the root SConstruct, like this:
And one step further would be to specify the files in those directories, possibly with Glob()
Hope that helps.