From: g0dil Date: Fri, 4 Sep 2009 10:26:58 +0000 (+0000) Subject: Add some documentation to the SCons-version-switching hack X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=4b94735961fc9474411a1ca200c3a00f744ec3f1;p=senf.git Add some documentation to the SCons-version-switching hack git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1381 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/site_scons/site_init.py b/site_scons/site_init.py index a8d5c42..1a41a75 100644 --- a/site_scons/site_init.py +++ b/site_scons/site_init.py @@ -11,15 +11,31 @@ sconsscript = os.path.join(os.path.join(sconsbase, 'script'),'scons') if os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(SCons.__file__)))) != sconsbase: import os, sys, SCons.Util SCons.Util.display("scons: Switching version") + + # BEGIN HACK + # This is really ugly. SCons has already switched into the + # top-level directory when this code is executed. To make 'scons + # -u ' work, we need to switch back into the orgiginal + # startup dir. This directory however is only available in a local + # variable called 'target_top' in SCons.Script.Main._main. + # + # We walk the stack to find a local variable called + # 'target_top'. If we can't find it (could really only happen if + # the SCons.Main code is changed considerably), we output a + # warning, that '-u' will probably fail (we re-start scons from + # the top-level directory, relative targets therefore will not + # work) frame = sys._getframe() - marker = [] - target_top = marker + target_top = marker = [] while frame and target_top is marker: target_top = frame.f_locals.get('target_top',marker) frame = frame.f_back if target_top is marker: - SCons.Util.display("scons: WARNING: scons -u will fail") - elif target_top is not None: - os.chdir(target_top) + SCons.Util.display("scons: WARNING: scons -u will probably fail") + if not target_top: + target_top = '.' + # END HACK + + os.chdir(target_top) os.environ['SCONS_LIB_DIR'] = sconsengine os.execv(sconsscript, sys.argv)