我们在指定库依赖项时使用间接,例如,
$(document).on({
mouseenter: function(e){
$('.hidden').text($(e.target).text());
$(".hidden").css({
'display' : 'block'
});
},
mouseleave: function(){
$(".hidden").css({
'display' : 'none'
});
}
}, '.parent');
LIBS_A,LIBS_B和LIBS_C在其他SConscript文件中指定。
假设:
env.Program(TARGET, SOURCE, LIBS = [ $LIBS_A, $LIBS_B, $LIBS_C ])
然后最终的连接线将具有:
LIBS_A/Sconscript has LIBS_A = [ foo, bar, baz ]
LIBS_B/Sconscript has LIBS_B = [ foo, bar, bat ]
LIBS_C/Sconscript has LIBS_C = [ foo, bar, ben ]
我们如何删除重复项并读取链接器行:
-lfoo -lbar -lbaz -lfoo -lbar -lbat -lfoo -lbar -lben
答案 0 :(得分:1)
这是怎么回事。文件完全列出。
main.cxx
#include <iostream>
int main()
{
std::cout << "Hello World!";
}
SConstruct
env=Environment()
Export('env')
for l in ['A','B','C']:
env.SConscript("LIBS_%s/SConscript"%l)
env.Program('myprogram',['main.cxx'], LIBS = list(set(env['LIBS_A'] + env['LIBS_B'] + env['LIBS_C'])))
LIBS_A / SConscript 导入(&#39; ENV&#39)
env['LIBS_A'] = ['foo','bar','baz']
LIBS_B / SConscript 导入(&#39; ENV&#39)
env['LIBS_B'] = ['foo','bar','bat']
LIBS_C / SConscript 导入(&#39; ENV&#39)
env['LIBS_C'] = ['foo','bar','ben']
收率:
g ++ -o myprogram main.o -lbaz -lbat -lfoo -lbar -lben
如果这些都不适合你,那么这应该是一个更复杂的方式:
class foo(object):
def __init__(self, arg):
self.arg = arg
def __call__(self, target, source, env, for_signature):
print "LIBS_A: %s LIBS_B: %s"%(env['LIBS_A'],env['LIBS_B'])
rc = list(set(env['LIBS_A']+env['LIBS_B']))
print "Unique: %s"%rc
print "SIG:%s"%for_signature
return rc
# Will call our foo method to uniquify LIBS_*
env=Environment(FOO=foo, BAR="${FOO('$LIBS_A $LIBS_B')}")
env.Command('foo.XXXXX','foo.in',action="echo LIBS: $LIBS",LIBS="$BAR",
LIBS_A=['a','b','c','d','e','f','f','b'],
LIBS_B=['b','d','e','g','x'])
答案 1 :(得分:1)
这对我有用。非常感谢@bdbaddog
class uniquify_libs(object):
def __init__(self, arg):
self.arg = arg
def __call__(self, target, source, env, for_signature):
rc = list(set(env.subst(env[self.arg])[0].split()))
return rc
LIBS = ['$LIBS_A', '$LIBS_B'] ## defined in other SConscripts
Program(
target = TARGET,
source = SOURCE,
UNIQUE = uniquify_libs,
MYLIBS = LIBS,
LIBS = "${UNIQUE('MYLIBS')}",
)