我将我们的项目从make移植到scons,我遇到了一些问题。 我们有很多Perl脚本,它们通过make运行,生成一系列C++源文件。 然后这些文件被编译到一个静态库中。在
目前,我可以通过scons运行perl脚本,并使用一些额外的python脚本来编译文件,但是,似乎应该有一种更简单的方法来实现这一点。在
另外,我发现scons脚本似乎不是线性执行的。脚本的某些部分正在无序执行。在
这是我的手稿
// SConscript file
import platform
import os
import glob
import time
Import('directEnv')
cohEnv = directEnv.Clone()
includePath = Split("""
#Direct/include
#Direct/libsrc/liblog
#Direct/libsrc/libtime
#tools/include
#Direct/include
#Direct/engine
""")
if platform.machine() == 'i686':
includePath = includePath + ['#tools/coh-cpp-v3.6-linux-x32/coherence-cpp/include']
else:
includePath = includePath + ['#tools/cohe-cpp-v3.5.3b465-linux-x64/coherence cpp/include']
cohFiles = Split("""
#Direct/include/IntApi.h
#Direct/include/MessagingApiRisk.h
#Direct/include/MessagingApiCommon.h
""")
cohEnv.append(CPPPATH = includePath)
cohEnv.Append(CCFLAGS = '-D_FILE_OFFSET_BITS=64 -DUTPBRIDGE -Wno-unused-variable')
cohEnv.Append(LIBS = Split('nsl m rt'))
#
# Run Perl script - this generates approx 30 c++ source files
#
Clean('.', '#Direct/coh/cpp/CohMsgObj_0.cc')
temp1 = cohEnv.RunPerl('#Direct/coh/cpp/CohMsgObj_0.cc', '#Direct/coh/BuildCohObjs.pl')
Depends(temp1, '#Direct/coh/BuildCoherenceObjs.pl')
Depends(temp1, '#Direct/include/IntApi.h')
#
# Run Perl script - this generates 3 c++ source files
#
Clean('.', '#Direct/coh/cpp/Print_BinV4.cc')
temp2 = cohEnv.RunPerl('#Direct/coh/cpp/Print_BinV4.cc', '#Direct/coh/BuildCohObjsRisk.pl')
Depends(temp2, '#Direct/coh/BuildCohObjsRisk.pl')
#
# Build the object and library
#
print os.getcwd()
os.chdir('../../cpp')
path = os.getcwd()
print path
#
# get all the c++ source files that we need to compile
#
List = []
for infile in glob.glob(os.path.join(path, '*.cc')):
List.append(infile)
count = 0
suffix = ".cc"
ObjectList = []
#
# create objects for each source file
# I'm trying to create variables dynamically - incase the files which generates the
# source files change - I don;t want to manually list everything that needs to be compiled
for item in List:
locals()['obj%s' % count] = coherenceEnv.Object(item[:-len(suffix)] + '.o' , item)
print "obj%s" % count
ObjectList.append(coherenceEnv.Object(item[:-len(suffix)] + '.o' , item))
count = count + 1
#
# create a static library using the newly created objects
#
cohLib = cohEnv.StaticLibrary(target = 'riskpo', source = [cohFiles, ObjectList])
cohEnv.Install('#/lib', [cohLib])
目前,这是可行的,但它远远不是理想的。 有没有更好的更直截了当的方法来使用基本的scons命令来实现这一点, 另外,如何使用scon对执行流强制执行顺序。 谢谢 D
当从Make迁移到SCons时,人们通常遇到的一个问题是:对于SCons,您没有指定顺序,而是告诉SCons构建什么,然后SCons将(通常)连接点并确定顺序。在
对于生成许多.c文件的perl脚本,问题是SCons不知道这些生成的文件,因此无法找到它们,这意味着SCons不知道在执行任何使用它的输出的步骤之前运行perl脚本。在
您应该查看用户指南,尤其是有关此问题发射器的部分: http://scons.org/doc/production/HTML/scons-user/x3689.html
wiki是另一个例子来源。 http://scons.org/wiki/DynamicSourceGenerator 和 http://scons.org/wiki/ToolsForFools
可能适用。在
生成的C文件的列表是静态的和/或可以由另一个文件的内容决定吗?在
相关问题 更多 >
编程相关推荐