【发布时间】:2015-03-06 21:03:52
【问题描述】:
在 SCons 中,我有一个生成未知数量文件的预构建步骤。生成这些文件后,我需要能够将 cpp 文件添加到我的源列表中。我是 SCons 的绝对初学者,我不确定正确的路径是什么。这样做的最佳方法是什么?
原文: 基本/原始构建步骤如下:
fpmFile = Dir('#').Dir('src').entry_abspath("FabricKINECT.fpm.json")
# The next step generates a bunch of source files
cppHeader = env.Command(
[env.File(target + '.h')],
klSources,
[[kl2edkBin, fpmFile, "-o", hdir, "-c", cppdir]]
)
env.Depends(cppSources, cppHeader)
# We pass in the supplied filelist to the build command
# however, this list does not include the cpp files generated above
# Currently I am hard-coding the generated files into
# the cppSources list, but I want to add them in dynamically
return env.SharedLibrary(
'-'.join([target, buildOS, buildArch]),
cppSources
)
我的尝试 我尝试了几个不同的角度:
http://www.scons.org/wiki/DynamicSourceGenerator,但据我所知,这会为每个文件创建单独的构建目标,而我希望它们都包含在我的库构建中
使用发射器:SCons to generate variable number of targets,但我似乎无法解决依赖关系 - 无论我如何分配依赖关系,我的扫描仪都会先运行
我尝试制作另一个命令来收集文件列表 -
def gatherGenCpp(target, source, env):
allFiles = Glob('generated/cpp/*.cpp')
# clear dummy target
del target[:]
for f in allFiles:
target.append(f)
genSources = env.Command(['#dummy-file'], cppdir, gatherGenCpp)
env.Depends(genSources, cppSources)
allSources = genSources + cppSources
return env.SharedLibrary(
'-'.join([target, buildOS, buildArch]),
allSources
)
然而,这失败了
致命错误 LNK1181:无法打开输入文件 'dummy-file.obj'
我猜是因为即使我从命令的目标中清除了虚拟文件条目,这也会发生在它向构建系统注册之后(并且生成了预期的目标。
所有这一切 - 你将如何实现以下内容:
- 一个命令生成一堆 CPP 文件
- 这些文件被添加到传入的文件列表中
- 我们根据这个 cpp 文件列表构建一个 dll。
有什么建议吗?
【问题讨论】: