Please note:The SCons wiki is now restored from the attack in March 2013. All old passwords have been invalidated. Please reset your password if you have an account. If you note missing pages, please report them to webmaster@scons.org. Also, new account creation is currently disabled due to an ongoing spam flood (2013/08/27).

This builder is exactly like the StaticLibrary builder, but uses position independant code (pic). It is useful when the library is meant to be statically linked to a shared library.

def createStaticPicLibraryBuilder(env):
    """This is a utility function that creates the StaticExtLibrary Builder in
    an Environment if it is not there already.

    If it is already there, we return the existing one."""
    import SCons.Action

    try:
        static_extlib = env['BUILDERS']['StaticPicLibrary']
    except KeyError:
        action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
        if env.Detect('ranlib'):
            ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
            action_list.append(ranlib_action)

    static_extlib = SCons.Builder.Builder(action = action_list,
                                          emitter = '$LIBEMITTER',
                                          prefix = '$LIBPREFIX',
                                          suffix = '$LIBSUFFIX',
                                          src_suffix = '$OBJSUFFIX',
                                          src_builder = 'SharedObject')

    env['BUILDERS']['StaticPicLibrary'] = static_extlib
    return static_extlib

You then just have to call the function createStaticPicLibrary(env), and then call the StaticPicLibrary builder, which has exactly the same semantics as the StaticLibrary one. The only difference with StaticLibrary is the src_builder: instead of calling StaticObject, it uses SharedObject.

Note that since scons uses a different suffix for pic object code and non pic object code, it may confuse some tools which expects .o in static libraries.

Question (thank you in advance AdrianNeagu):

StaticPicLibrary (last edited 2013-04-12 15:51:05 by AdrianNeagu)