![](/img/trans.png)
[英]How can I specify a target library defined in an SConscript file to be built by calling its parent SConstruct from the command line?
[英]Calling CheckLib from SConscript file
我正在尝试从SConscript
文件内部检查是否存在库,如下所示:
# Not sure if this bit is relevant:
Import('env')
env = env.Clone()
# This is what I'm trying to do:
conf = env.Configure()
if conf.CheckLib('gcrypt'):
pass # actually something more interesting
...但是它不起作用。 我得到的只是来自scons
的不透明错误,如下所示:
scons: ***
File "/home/src/foo/bar/SConscript", line 49, in <module>
...其中第49行是conf = env.Configure()
行。
这是在Mac OS X上,我不希望在其中找到提到的库。 如何在我的SConscript
文件中检测到此情况?
我对此进行了测试,效果很好。 可能是您如何创建或传递环境的问题。 如果有帮助,这是我的示例代码:
构造
env = Environment()
env.SConscript('SConscript', exports='env', duplicate=0)
脚本
Import('env')
env = env.Clone()
conf = env.Configure()
if conf.CheckLib('gcrypt'):
pass
结果如下:
$ scons
scons: Reading SConscript files ...
Checking for C library gcrypt... no
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.