diff options
author | Steven Knight <knight@baldmt.com> | 2004-01-10 12:32:21 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-01-10 12:32:21 (GMT) |
commit | 01cc03bfdf22b3119cff73283bbf5280f7a591d5 (patch) | |
tree | e7acc6be78dfb24b15dc8bd642d620059c801e51 /src | |
parent | a2217939a6af4b0a808fc0325f73b9c718dfc6c2 (diff) | |
download | SCons-01cc03bfdf22b3119cff73283bbf5280f7a591d5.zip SCons-01cc03bfdf22b3119cff73283bbf5280f7a591d5.tar.gz SCons-01cc03bfdf22b3119cff73283bbf5280f7a591d5.tar.bz2 |
Make the static/shared object check work even if the object was already created.
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Defaults.py | 82 | ||||
-rw-r--r-- | src/engine/SCons/Tool/__init__.py | 28 | ||||
-rw-r--r-- | src/engine/SCons/Tool/msvc.py | 15 |
4 files changed, 70 insertions, 59 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 73f9d4f..474514e 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -115,6 +115,10 @@ RELEASE 0.95 - XXX - Fix specifying .class files as input to JavaH with the .class suffix when they weren't generated using the Java Builder. + - Make the check for whether all of the objects going into a + SharedLibrary() are shared work even if the object was built in a + previous run. + From Vincent Risi: - Add support for the bcc32, ilink32 and tlib Borland tools. diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index cbd468d..bf6d59f 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -67,53 +67,49 @@ def DefaultEnvironment(*args, **kw): _default_env._calc_module = SCons.Sig.default_module return _default_env +# Emitters for setting the shared attribute on object files, +# and an action for checking that all of the source files +# going into a shared library are, in fact, shared. +def StaticObjectEmitter(target, source, env): + for tgt in target: + tgt.attributes.shared = None + return (target, source) + +def SharedObjectEmitter(target, source, env): + for tgt in target: + tgt.attributes.shared = 1 + return (target, source) + +def SharedFlagChecker(source, target, env): + same = env.subst('$STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME') + if same == '0' or same == '' or same == 'False': + for src in source: + try: + shared = src.attributes.shared + except AttributeError: + shared = None + if not shared: + raise SCons.Errors.UserError, "Source file: %s is static and is not compatible with shared target: %s" % (src, target[0]) + +SharedCheck = SCons.Action.Action(SharedFlagChecker, None) + +# Scanners and actions for common language(s). CScan = SCons.Scanner.C.CScan() FortranScan = SCons.Scanner.Fortran.FortranScan() -class SharedFlagChecker: - """This is a callable class that is used as - a build action for all objects, libraries, and programs. - Its job is to run before the "real" action that builds the - file, to make sure we aren't trying to link shared objects - into a static library/program, or static objects into a - shared library.""" - - def __init__(self, shared, set_target_flag): - self.shared = shared - self.set_target_flag = set_target_flag - - def __call__(self, source, target, env, **kw): - if kw.has_key('shared'): - raise SCons.Errors.UserError, "The shared= parameter to Library() or Object() no longer works.\nUse SharedObject() or SharedLibrary() instead." - if self.set_target_flag: - for tgt in target: - tgt.attributes.shared = self.shared - - same = env.subst('$STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME') - if same == '0' or same == '' or same == 'False': - for src in source: - if hasattr(src.attributes, 'shared'): - if self.shared and not src.attributes.shared: - raise SCons.Errors.UserError, "Source file: %s is static and is not compatible with shared target: %s" % (src, target[0]) - -SharedCheck = SCons.Action.Action(SharedFlagChecker(1, 0), None) -StaticCheck = SCons.Action.Action(SharedFlagChecker(0, 0), None) -SharedCheckSet = SCons.Action.Action(SharedFlagChecker(1, 1), None) -StaticCheckSet = SCons.Action.Action(SharedFlagChecker(0, 1), None) - -CAction = SCons.Action.Action([ StaticCheckSet, "$CCCOM" ]) -ShCAction = SCons.Action.Action([ SharedCheckSet, "$SHCCCOM" ]) -CXXAction = SCons.Action.Action([ StaticCheckSet, "$CXXCOM" ]) -ShCXXAction = SCons.Action.Action([ SharedCheckSet, "$SHCXXCOM" ]) - -F77Action = SCons.Action.Action([ StaticCheckSet, "$F77COM" ]) -ShF77Action = SCons.Action.Action([ SharedCheckSet, "$SHF77COM" ]) -F77PPAction = SCons.Action.Action([ StaticCheckSet, "$F77PPCOM" ]) -ShF77PPAction = SCons.Action.Action([ SharedCheckSet, "$SHF77PPCOM" ]) - -ASAction = SCons.Action.Action([ StaticCheckSet, "$ASCOM" ]) -ASPPAction = SCons.Action.Action([ StaticCheckSet, "$ASPPCOM" ]) +CAction = SCons.Action.Action("$CCCOM") +ShCAction = SCons.Action.Action("$SHCCCOM") +CXXAction = SCons.Action.Action("$CXXCOM") +ShCXXAction = SCons.Action.Action("$SHCXXCOM") + +F77Action = SCons.Action.Action("$F77COM") +ShF77Action = SCons.Action.Action("$SHF77COM") +F77PPAction = SCons.Action.Action("$F77PPCOM") +ShF77PPAction = SCons.Action.Action("$SHF77PPCOM") + +ASAction = SCons.Action.Action("$ASCOM") +ASPPAction = SCons.Action.Action("$ASPPCOM") ProgScan = SCons.Scanner.Prog.ProgScan() diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 34e9e0d..97da344 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -98,14 +98,13 @@ def createProgBuilder(env): try: program = env['BUILDERS']['Program'] except KeyError: - program = SCons.Builder.Builder(action=[ SCons.Defaults.StaticCheck, - '$LINKCOM' ], - emitter='$PROGEMITTER', - prefix='$PROGPREFIX', - suffix='$PROGSUFFIX', - src_suffix='$OBJSUFFIX', - src_builder='Object', - scanner = SCons.Defaults.ProgScan) + program = SCons.Builder.Builder(action = '$LINKCOM', + emitter = '$PROGEMITTER', + prefix = '$PROGPREFIX', + suffix = '$PROGSUFFIX', + src_suffix = '$OBJSUFFIX', + src_builder = 'Object', + scanner = SCons.Defaults.ProgScan) env['BUILDERS']['Program'] = program return program @@ -120,8 +119,7 @@ def createStaticLibBuilder(env): try: static_lib = env['BUILDERS']['StaticLibrary'] except KeyError: - static_lib = SCons.Builder.Builder(action=[ SCons.Defaults.StaticCheck, - "$ARCOM" ], + static_lib = SCons.Builder.Builder(action = "$ARCOM", emitter = '$LIBEMITTER', prefix = '$LIBPREFIX', suffix = '$LIBSUFFIX', @@ -142,8 +140,8 @@ def createSharedLibBuilder(env): try: shared_lib = env['BUILDERS']['SharedLibrary'] except KeyError: - shared_lib = SCons.Builder.Builder(action=[ SCons.Defaults.SharedCheck, - "$SHLINKCOM" ], + action_list = [ SCons.Defaults.SharedCheck, "$SHLINKCOM" ] + shared_lib = SCons.Builder.Builder(action = action_list, emitter = "$SHLIBEMITTER", prefix = '$SHLIBPREFIX', suffix = '$SHLIBSUFFIX', @@ -171,22 +169,24 @@ def createObjBuilders(env): static_obj = env['BUILDERS']['StaticObject'] except KeyError: static_obj = SCons.Builder.Builder(action = {}, - emitter="$OBJEMITTER", + emitter = "$OBJEMITTER", prefix = '$OBJPREFIX', suffix = '$OBJSUFFIX', src_builder = ['CFile', 'CXXFile']) env['BUILDERS']['StaticObject'] = static_obj env['BUILDERS']['Object'] = static_obj + env['OBJEMITTER'] = SCons.Defaults.StaticObjectEmitter try: shared_obj = env['BUILDERS']['SharedObject'] except KeyError: shared_obj = SCons.Builder.Builder(action = {}, + emitter = "$SHOBJEMITTER", prefix = '$SHOBJPREFIX', suffix = '$SHOBJSUFFIX', - emitter="$OBJEMITTER", src_builder = ['CFile', 'CXXFile']) env['BUILDERS']['SharedObject'] = shared_obj + env['SHOBJEMITTER'] = SCons.Defaults.SharedObjectEmitter return (static_obj, shared_obj) diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index b9ce9bc..fac178c 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -354,11 +354,13 @@ def pch_emitter(target, source, env): return (target, source) -def object_emitter(target, source, env): +def object_emitter(target, source, env, parent_emitter): """Sets up the PDB and PCH dependencies for an object file.""" validate_vars(env) + parent_emitter(target, source, env) + if env.has_key('PDB') and env['PDB']: env.SideEffect(env['PDB'], target) env.Precious(env['PDB']) @@ -368,6 +370,14 @@ def object_emitter(target, source, env): return (target, source) +def static_object_emitter(target, source, env): + return object_emitter(target, source, env, + SCons.Defaults.StaticObjectEmitter) + +def shared_object_emitter(target, source, env): + return object_emitter(target, source, env, + SCons.Defaults.SharedObjectEmitter) + pch_builder = SCons.Builder.Builder(action='$PCHCOM', suffix='.pch', emitter=pch_emitter) res_builder = SCons.Builder.Builder(action='$RCCOM', suffix='.res') @@ -402,7 +412,8 @@ def generate(env): env['CPPDEFSUFFIX'] = '' env['INCPREFIX'] = '/I' env['INCSUFFIX'] = '' - env['OBJEMITTER'] = object_emitter + env['OBJEMITTER'] = static_object_emitter + env['SHOBJEMITTER'] = shared_object_emitter env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 env['RC'] = 'rc' |