0
votes

Hi have a Sconscript file that is used to build two different targets - a shared lib and a dynamic lib.

Issue the first time when I issue a build the static lib that is build is empty. There are no object in the shared lib. However, if I again issue a build command and all shared object are already build this time shared lib is build correctly.

Includes for both shared and dynamic lib target have some common files

Structure for my Sconscript file looks as :

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
I don't see you parsing through the list of sources...you're specifying complete subfolders for your static_sources list. Please try to use Glob() to find all source files, and also show us how exactly you're setting up the dynamic library. Even though you may think it doesn't matter and is repetitive, it helps other people to reproduce your problem. - dirkbaechle

1 Answers

0
votes

How about this? I've not tried it, but it should work..

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