conan.tools.scons¶
SConsDeps¶
The SConsDeps
是 SCons 的依赖生成器。它将生成一个 SConscript_conandeps 文件,其中包含 SCons 针对所需依赖项进行构建所需的信息。
The SConsDeps
生成器可以在 conanfile 中通过名称使用
conanfile.py¶
from conan import ConanFile
class Pkg(ConanFile):
generators = "SConsDeps"
conanfile.txt¶
[generators]
SConsDeps
它也可以在 conanfile 的 generate()
方法中完全实例化
from conan import ConanFile
from conan.tools.scons import SConsDeps
class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"
def generate(self):
tc = SConsDeps(self)
tc.generate()
执行 conan install
命令后,SConsDeps
生成器将创建 SConscript_conandeps 文件。此文件将为 SCons 提供以下信息:CPPPATH
, LIBPATH
, BINPATH
, LIBS
, FRAMEWORKS
, FRAMEWORKPATH
, CPPDEFINES
, CXXFLAGS
, CCFLAGS
, SHLINKFLAGS
和 LINKFLAGS
。这些信息是为所有依赖项的累积列表生成的,也是为每个需求生成的。您可以在消费者 SConscript 中像这样加载它
消费者 SConscript¶
...
info = SConscript('./SConscript_conandeps')
# You can use conandeps to get the information
# for all the dependencies.
flags = info["conandeps"]
# Or use the name of the requirement if
# you only want the information about that one.
flags = info["zlib"]
env.MergeFlags(flags)
...