开发者

scons Dependencies for wrapper methods

I use a wrapper method to combine static libraries as shown below.

def MergeLibs(env, tgt, src_list)
....
    return lib

and used as,

lib = env.MergeLibs(tgt, src_lists)
env.Depends(lib, <path_to_lib1>)
...
env.Depends(lib, <path_to_li开发者_JAVA百科bn>)

But MergeLibs() method is being executed in scons parse phase itself.

How can I use dependencies here.

Thanks


Well I'm not too sure on the details of the MergeLib step but it seems like you would want something else to depend on your merge lib step.. like your final program?

import SCons

env = Environment()

def merge_libs(self, target, source, env):
    print "hi"
    return env.StaticLibrary(target, source)

env.Append(BUILDERS = {'MergeLibs' : merge_libs})

lib = env.MergeLibs('mrglibs', ['some_file.cpp', 'some_file2.cpp'], env)

prog = env.Program('test.cpp')

env.Depends(prog, lib)

This gives me the output:

scons: Reading SConscript files ...
hi
scons: done reading SConscript files.
scons: Building targets ...
g++ -o some_file.o -c some_file.cpp
g++ -o some_file2.o -c some_file2.cpp
ar rc libmrglibs.a some_file.o some_file2.o
ranlib libmrglibs.a
g++ -o test.o -c test.cpp
g++ -o test test.o
scons: done building targets.

So its definitely still read during the parse phase (I think it has to be) but it should get you what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜