2015-12-22 39 views
0

嗨有一個Sconscript文件,用於構建兩個不同的目標 - 共享庫和動態庫。scons中的靜態和動態庫作爲目標的問題

發佈第一次發佈構建時,構建的靜態庫爲空。共享庫中沒有對象。 但是,如果我再次發出構建命令並且所有共享對象已經構建,則此時共享庫已正確構建。

包括對共享和動態的lib目標有一些共同文件

結構爲我Sconscript文件看起來如:

Import('module_env') 
env = module_env.clone() 

static_includes = ['inc1/', 'inc2'] 
static_sources = ['src1', 'src2'] 
#build static lib 
env.Append(CPPPATH = static_includes) 
lib = env.StaticLibrary(libname, static_sources) 

#build dynamic lib 
# same mechanism, parse through list of sources and build dynamic lib 
+1

我沒有看到你通過源列表解析...你指定完整的子文件夾爲您'static_sources'列表。請嘗試使用Glob()來查找所有源文件,並向我們展示如何設置動態庫。即使你可能認爲這並不重要也是重複的,它可以幫助其他人重現你的問題。 – dirkbaechle

回答

0

這個怎麼樣? 我還沒有嘗試過,但它應該工作..

Import('module_env') 
env = module_env.clone() 

static_includes = ['inc1', 'inc2'] 
static_source_dirs = ['src1', 'src2'] 
#build static lib 
env.Append(CPPPATH = static_includes) 

static_sources = [] 
for s in static_source_dirs: 
    static_sources.extend(Glob(os.path.join(s,'*.c'))) 

static_objects = [] 
for s in static_sources: 
    # note I'm constructing the target for the static object compile to have a different name than default. You only need this if you are going to build the same sources also as shared objects. 
    base_name = static_objects.extend("${SOURCE.basename}_static.$OBJSUFFIX",env.StaticObject(s)) 

lib = env.StaticLibrary(libname, static_objects) 

#build dynamic lib 
# same mechanism, parse through list of sources and build dynamic lib