简体   繁体   English

SCons无法找到生成的文件

[英]SCons fails to find generated file

I am tring to generate some source file, and use the generated file to compile.. 我正在尝试生成一些源文件,并使用生成的文件进行编译。

gen = env.Command("/tmp/dummy", "demo.json","demo.py $SOURCE > $TARGET")
env.AlwaysBuild(gen)

bin=env.Program(target='demo', source=[Glob("*.cc")])
env.Depends(bin, gen)

the gen will generate required demo.cc gen将生成所需的demo.cc

gen = env.Command("/tmp/dummy", "demo.json","demo.py $SOURCE > $TARGET") gen = env.Command(“ / tmp / dummy”,“ demo.json”,“ demo.py $ SOURCE> $ TARGET”)

But get error when compiling demo as follows: 但是在编译演示时出现如下错误:

failed: Source demo.cc' not found, needed by target demo.o'. 失败: demo.cc' not found, needed by target demo.o' demo.cc' not found, needed by target源demo.cc'。

By ls demo.cc, I am sure that the required file demo.cc is indeed generated in the correct directory. 通过ls demo.cc,我确定所需文件demo.cc确实在正确的目录中生成。

The cause should be something with dependency. 原因应该是有依赖性的。 Noted that I specify explicit dependency of the bin on demo.cc. 注意,我指定了bin对demo.cc的显式依赖。 Still failed. 仍然失败。

Any ideas why ? 有什么想法吗?

===== More details ===== =====更多细节=====

Every clean build, ie scons -c && scons -j4, works. 每个干净的构建,即scons -c && scons -j4,都可以工作。 But afterword build fails even with the demo.cc file in place. 但是,即使安装了demo.cc文件,后续语言构建也会失败。

You are telling SCons that the result (=target) of your env.Command() is " /tmp/dummy ". 您告诉SCons您的env.Command()的结果(=目标env.Command()是“ /tmp/dummy ”。 Try to use 尝试使用

gen = env.Command("demo.cc", "demo.json","demo.py $SOURCE > $TARGET")

instead, such that SCons can pick up the dependency automatically. 相反, SCons可以自动获取依赖项。 You don't need the explicit Depends() . 您不需要显式的Depends()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM