diff options
author | Andy Schwerin <schwerin@10gen.com> | 2012-01-20 22:31:08 -0800 |
---|---|---|
committer | Andy Schwerin <schwerin@10gen.com> | 2012-01-20 22:33:40 -0800 |
commit | 2479794acdd9101efaee829b12bd2c8097dd62b4 (patch) | |
tree | 76d6b8abde697a0a20d808464cec5393b53da888 /site_scons/site_tools | |
parent | fe7421e8f00f00cc723bbe0144319f6fac274562 (diff) | |
download | mongo-2479794acdd9101efaee829b12bd2c8097dd62b4.tar.gz |
SCons: Change implementation of MergeLibrary, to make its behavior consistent on Windows and
Posix systems.
Diffstat (limited to 'site_scons/site_tools')
-rw-r--r-- | site_scons/site_tools/mergelib.py | 24 | ||||
-rw-r--r-- | site_scons/site_tools/mergelibposix.py | 42 | ||||
-rw-r--r-- | site_scons/site_tools/mergelibwin.py | 34 |
3 files changed, 16 insertions, 84 deletions
diff --git a/site_scons/site_tools/mergelib.py b/site_scons/site_tools/mergelib.py index 8c63d3aacce..d8fcf3347ba 100644 --- a/site_scons/site_tools/mergelib.py +++ b/site_scons/site_tools/mergelib.py @@ -6,19 +6,27 @@ The following rule creates a library "mylib" whose contents are the contents of be distributed to customers. MergeLibrary('mylib', ['firstlib', 'secondlib']) -MergeSharedLibrary('mylib', ['firstlib', 'secondlib']) -This file provides the platform-independent tool, which just selects and imports -the platform-specific tool providing MergeLibrary and MergeSharedLibrary. """ -import sys +import libdeps +from SCons.Action import Action +from SCons.Builder import Builder + +def merge_library_method(env, target, source, LIBDEPS=None, **kwargs): + return env._MergeLibrary(target, [], LIBDEPS=source, **kwargs) def exists( env ): return True def generate( env ): - if sys.platform == 'win32': - env.Tool( 'mergelibwin' ) - else: - env.Tool( 'mergelibposix' ) + merge_library = Builder( + action='$ARCOM $_LIBDEPS_OBJS', + src_prefix='$LIBPREFIX', + src_suffix='$LIBSUFFIX', + prefix='$LIBPREFIX', + suffix='$LIBSUFFIX', + emitter=libdeps.libdeps_emitter ) + libdeps.update_scanner( merge_library ) + env['BUILDERS']['_MergeLibrary'] = merge_library + env.AddMethod( merge_library_method, 'MergeLibrary' ) diff --git a/site_scons/site_tools/mergelibposix.py b/site_scons/site_tools/mergelibposix.py deleted file mode 100644 index d93dbaf3ae5..00000000000 --- a/site_scons/site_tools/mergelibposix.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Builder for static libraries composed of the contents of other static libraries. - -The following rule creates a library "mylib" whose contents are the contents of -"firstlib", "secondlib", and all LIBDEPS dependencies of "firstlib" and -"secondlib". This creates self-contained static and shared libraries that can -be distributed to customers. - -MergeLibrary('mylib', ['firstlib', 'secondlib']) -MergeSharedLibrary('mylib', ['firstlib', 'secondlib']) - -This implementation is for posix systems whose linkers can generate "relocatable -objects" (usually with the -r option). -""" - -import libdeps -from SCons.Action import Action -from SCons.Builder import Builder - -def merge_library_method( env, target, source, LIBDEPS=None, **kwargs ): - robj_name = env.subst( '${TARGET}-mergelib', target=target, source=source ) - robj = env.RelocatableObject( robj_name, [], LIBDEPS=source, **kwargs ) - return env.Library( target, robj, LIBDEPS=LIBDEPS or [], **kwargs ) - -def merge_shared_library_method( env, target, source, LIBDEPS=None, **kwargs ): - robj_name = env.subst( '${TARGET}-mergeshlib', target=target, source=source ) - robj = env.RelocatableObject( robj_name, [], LIBDEPS=source, **kwargs ) - return env.SharedLibrary( target, robj, LIBDEPS=LIBDEPS or [], **kwargs ) - -def exists( env ): - return True - -def generate( env ): - env['_RELOBJDEPSFLAGS'] = '$RELOBJ_LIBDEPS_START ${_concat("$RELOBJ_LIBDEPS_ITEM ", __env__.subst(_LIBDEPS, target=TARGET, source=SOURCE), "", __env__, target=TARGET, source=SOURCE)} $RELOBJ_LIBDEPS_END' - env['RELOBJCOM'] = 'ld -o $TARGET $RELOBJFLAGS -r $SOURCES $_RELOBJDEPSFLAGS' - relobj_builder = Builder( action='$RELOBJCOM', - prefix="$OBJPREFIX", - suffix="$OBJSUFFIX", - emitter=libdeps.libdeps_emitter ) - libdeps.update_scanner( relobj_builder ) - env['BUILDERS']['RelocatableObject'] = relobj_builder - env.AddMethod( merge_library_method, 'MergeLibrary' ) - env.AddMethod( merge_shared_library_method, 'MergeSharedLibrary' ) diff --git a/site_scons/site_tools/mergelibwin.py b/site_scons/site_tools/mergelibwin.py deleted file mode 100644 index 680ccdd5b9a..00000000000 --- a/site_scons/site_tools/mergelibwin.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Builder for static libraries composed of the contents of other static libraries. - -The following rule creates a library "mylib" whose contents are the contents of -"firstlib", "secondlib", and all LIBDEPS dependencies of "firstlib" and -"secondlib". This creates self-contained static and shared libraries that can -be distributed to customers. - -MergeLibrary('mylib', ['firstlib', 'secondlib']) -MergeSharedLibrary('mylib', ['firstlib', 'secondlib']) - -This implementation is for win32 systems using msvc. -""" - -import libdeps -from SCons.Action import Action -from SCons.Builder import Builder - -def merge_library_method( env, target, source, LIBDEPS=None, **kwargs ): - return env._MergeLibrary( target, [], LIBDEPS=source, **kwargs ) - -def exists( env ): - return True - -def generate( env ): - merge_library = Builder( - action='${TEMPFILE("$AR $ARFLAGS /OUT:$TARGET $_LIBDEPS")}', - src_prefix='$LIBPREFIX', - src_suffix='$LIBSUFFIX', - prefix='$LIBPREFIX', - suffix='$LIBSUFFIX', - emitter=libdeps.libdeps_emitter ) - libdeps.update_scanner( merge_library ) - env['BUILDERS']['_MergeLibrary'] = merge_library - env.AddMethod( merge_library_method, 'MergeLibrary' ) |