From: stevenknight Date: Sun, 6 Nov 2005 15:03:10 +0000 (+0000) Subject: Add support for an explicit SCONS_HOME variable for writing the SCons execution line... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7067c0184230f71269eeb3bcc995cda96aeef60e;p=scons.git Add support for an explicit SCONS_HOME variable for writing the SCons execution line in Visual Studio project files. (Dobes Vandermeer) Two minor test fixes for win32 portability. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1382 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 47a74d47..d2e69fd5 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -7226,6 +7226,15 @@ This can be set, for example, to .I -e to check out editable files from SCCS. +.IP SCONS_HOME +The (optional) path to the SCons library directory, +initialized from the external environment. +If set, this is used to construct a shorter and more +efficient search path in the +.B MSVSSCONS +command line executed +from Microsoft Visual Studio project files. + .IP SHCC The C compiler used for generating shared-library objects. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b94a7f7d..ff46247c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -724,6 +724,10 @@ RELEASE 0.97 - XXX $MSVS_PROJECT_GUID, $MSVS_SCC_AUX_PATH, $MSVS_SCC_LOCAL_PATH, $MSVS_SCC_PROJECT_NAME, $MSVS_SCC_PROVIDER, + - Add support for using a $SCONS_HOME variable (imported from the + external environment, or settable internally) to put a shortened + SCons execution line in the Visual Studio project file. + From Greg Ward: - Fix a misplaced line in the man page. diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index e3a28ec6..c2bd20e4 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -66,6 +66,12 @@ def _hexdigest(s): r = r + h[(i >> 4) & 0xF] + h[i & 0xF] return r +def xmlify(s): + s = string.replace(s, "&", "&") # do this first + s = string.replace(s, "'", "'") + s = string.replace(s, '"', """) + return s + def _generateGUID(slnfile, name): """This generates a dummy GUID for the sln file to use. It is based on the MD5 signatures of the sln filename plus the name of @@ -84,7 +90,15 @@ def _generateGUID(slnfile, name): # things and ends up with "-c" as sys.argv[0]. Consequently, we have # the MSVS Project file invoke SCons the same way that scons.bat does, # which works regardless of how we were invoked. -exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-__VERSION__'), join(sys.prefix, 'scons-__VERSION__'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" +def getExecScriptMain(env, xml=None): + scons_home = env.get('SCONS_HOME') + if scons_home: + exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % scons_home + else: + exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-__VERSION__'), join(sys.prefix, 'scons-__VERSION__'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" + if xml: + exec_script_main = xmlify(exec_script_main) + return exec_script_main # The string for the Python executable we tell the Project file to use # is either sys.executable or, if an external PYTHON_ROOT environment @@ -543,12 +557,6 @@ class _GenerateV7DSP(_DSPGenerator): outdir = self.configs[kind].outdir buildtarget = self.configs[kind].buildtarget - def xmlify(cmd): - cmd = string.replace(cmd, "&", "&") # do this first - cmd = string.replace(cmd, "'", "'") - cmd = string.replace(cmd, '"', """) - return cmd - env_has_buildtarget = self.env.has_key('MSVSBUILDTARGET') if not env_has_buildtarget: self.env['MSVSBUILDTARGET'] = buildtarget @@ -1466,7 +1474,7 @@ def generate(env): default_MSVS_SConscript = env.File('SConstruct') env['MSVSSCONSCRIPT'] = default_MSVS_SConscript - env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, exec_script_main) + env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env)) env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.abspath}" -f ${MSVSSCONSCRIPT.name}' env['MSVSSCONSCOM'] = '$MSVSSCONS $MSVSSCONSFLAGS' env['MSVSBUILDCOM'] = '$MSVSSCONSCOM $MSVSBUILDTARGET' @@ -1497,6 +1505,7 @@ def generate(env): env['GET_MSVSSOLUTIONSUFFIX'] = GetMSVSSolutionSuffix env['MSVSPROJECTSUFFIX'] = '${GET_MSVSPROJECTSUFFIX}' env['MSVSSOLUTIONSUFFIX'] = '${GET_MSVSSOLUTIONSUFFIX}' + env['SCONS_HOME'] = os.environ.get('SCONS_HOME') def exists(env): try: diff --git a/src/engine/SCons/Tool/msvs.xml b/src/engine/SCons/Tool/msvs.xml index c972ac2b..9af09608 100644 --- a/src/engine/SCons/Tool/msvs.xml +++ b/src/engine/SCons/Tool/msvs.xml @@ -534,3 +534,15 @@ and when using earlier versions of Visual Studio. + + + +The (optional) path to the SCons library directory, +initialized from the external environment. +If set, this is used to construct a shorter and more +efficient search path in the +&cv-MSVSSCONS; +command line executed +from Microsoft Visual Studio project files. + + diff --git a/test/QT/generated-ui.py b/test/QT/generated-ui.py index 16744879..7125dd9a 100644 --- a/test/QT/generated-ui.py +++ b/test/QT/generated-ui.py @@ -28,10 +28,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Test that the UI scanning logic correctly picks up scansG """ +import os + import TestSCons test = TestSCons.TestSCons() +if not os.environ.get('QTDIR', None): + x ="External environment variable $QTDIR not set; skipping test(s).\n" + test.skip_test(x) + test.subdir(['layer'], ['layer', 'aclock'], ['layer', 'aclock', 'qt_bug']) diff --git a/test/rebuild-generated.py b/test/rebuild-generated.py index 03acf6d3..973fc8f8 100644 --- a/test/rebuild-generated.py +++ b/test/rebuild-generated.py @@ -50,6 +50,7 @@ without arguments. This may be a duplicate to bug 1019683. """ +import os import sys import TestSCons @@ -83,11 +84,11 @@ kernelImporter = env.Program( kernelImports = env.Command( "KernelImport.hh", kernelImporter, - "./$SOURCE > $TARGET") + ".%s$SOURCE > $TARGET") osLinuxModule = env.StaticObject( ["target.cc"]) -""" % (generator_name, kernel_action)) +""" % (generator_name, kernel_action, os.sep)) test.write('main.cc', """\ int