summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-08-20 04:13:59 (GMT)
committerSteven Knight <knight@baldmt.com>2005-08-20 04:13:59 (GMT)
commit363f4dd969747edcc783584138a8daf018417a47 (patch)
tree27a3ab63f74f7693bb5954d60dae2cb0a09cb937 /etc
parentd8075b1a39a6d29bf2724e02a7b27dc35f794b70 (diff)
downloadSCons-363f4dd969747edcc783584138a8daf018417a47.zip
SCons-363f4dd969747edcc783584138a8daf018417a47.tar.gz
SCons-363f4dd969747edcc783584138a8daf018417a47.tar.bz2
Have Visual Studio echo that we're using SCons to build things, to work around a quoting issue. (Shannon Mann)
Diffstat (limited to 'etc')
-rw-r--r--etc/TestCmd.py30
-rw-r--r--etc/TestSCons.py53
2 files changed, 73 insertions, 10 deletions
diff --git a/etc/TestCmd.py b/etc/TestCmd.py
index 79ec8dc..e4cae74 100644
--- a/etc/TestCmd.py
+++ b/etc/TestCmd.py
@@ -175,8 +175,8 @@ version.
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCmd.py 0.15.D001 2005/08/16 17:14:33 knight"
-__version__ = "0.15"
+__revision__ = "TestCmd.py 0.16.D002 2005/08/19 16:58:31 knight"
+__version__ = "0.16"
import os
import os.path
@@ -217,9 +217,11 @@ else:
tempfile.template = 'testcmd.'
+re_space = re.compile('\s')
+
if os.name == 'posix':
- def escape_cmd(arg):
+ def escape(arg):
"escape shell special characters"
slash = '\\'
special = '"$'
@@ -228,14 +230,19 @@ if os.name == 'posix':
for c in special:
arg = string.replace(arg, c, slash+c)
- return '"' + arg + '"'
+ if re_space.search(arg):
+ arg = '"' + arg + '"'
+ return arg
else:
# Windows does not allow special characters in file names
# anyway, so no need for an escape function, we will just quote
# the arg.
- escape_cmd = lambda x: '"' + x + '"'
+ def escape(arg):
+ if re_space.search(arg):
+ arg = '"' + arg + '"'
+ return arg
_Cleanup = []
@@ -633,6 +640,9 @@ class TestCmd:
"""Runs a test of the program or script for the test
environment. Standard output and error output are saved for
future retrieval via the stdout() and stderr() methods.
+
+ The specified program will have the original directory
+ prepending unless it is enclosed in a [list].
"""
if chdir:
oldcwd = os.getcwd()
@@ -642,26 +652,28 @@ class TestCmd:
sys.stderr.write("chdir(" + chdir + ")\n")
os.chdir(chdir)
if program:
- if not os.path.isabs(program):
+ if type(program) == type('') and not os.path.isabs(program):
program = os.path.join(self._cwd, program)
else:
program = self.program
if not interpreter:
interpreter = self.interpreter
- cmd = [program]
+ if type(program) != type([]):
+ program = [program]
+ cmd = program
if interpreter:
cmd = [interpreter] + cmd
if arguments:
if type(arguments) == type(''):
arguments = string.split(arguments)
cmd.extend(arguments)
- cmd_string = string.join(cmd, ' ')
+ cmd_string = string.join(map(escape, cmd), ' ')
if self.verbose:
sys.stderr.write(cmd_string + "\n")
try:
p = popen2.Popen3(cmd, 1)
except AttributeError:
- (tochild, fromchild, childerr) = os.popen3(cmd_string)
+ (tochild, fromchild, childerr) = os.popen3(' ' + cmd_string)
if stdin:
if is_List(stdin):
for line in stdin:
diff --git a/etc/TestSCons.py b/etc/TestSCons.py
index 7fd76d2..520bbfd 100644
--- a/etc/TestSCons.py
+++ b/etc/TestSCons.py
@@ -12,7 +12,7 @@ from those classes, as well as any overridden or additional methods or
attributes defined in this subclass.
"""
-# Copyright 2001, 2002, 2003 Steven Knight
+# __COPYRIGHT__
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
@@ -424,6 +424,57 @@ Export("env dup")
SConscript( sconscript )
""" % (self.QT, self.QT_LIB, self.QT_MOC, self.QT_UIC))
+ def msvs_versions(self):
+ if not hasattr(self, '_msvs_versions'):
+
+ # Determine the SCons version and the versions of the MSVS
+ # environments installed on the test machine.
+ #
+ # We do this by executing SCons with an SConstruct file
+ # (piped on stdin) that spits out Python assignments that
+ # we can just exec(). We construct the SCons.__"version"__
+ # string in the input here so that the SCons build itself
+ # doesn't fill it in when packaging SCons.
+ input = """\
+import SCons
+print "self._scons_version =", repr(SCons.__%s__)
+env = Environment();
+print "self._msvs_versions =", str(env['MSVS']['VERSIONS'])
+""" % 'version'
+
+ self.run(arguments = '-n -q -Q -f -', stdin = input)
+ exec(self.stdout())
+
+ return self._msvs_versions
+
+ def vcproj_sys_path(self, fname):
+ """
+ """
+ orig = 'sys.path = [ join(sys'
+
+ enginepath = repr(os.path.join(self._cwd, '..', 'engine'))
+ replace = 'sys.path = [ %s, join(sys' % enginepath
+
+ contents = self.read(fname)
+ contents = string.replace(contents, orig, replace)
+ self.write(fname, contents)
+
+ def msvs_substitute(self, input, msvs_ver, python=sys.executable):
+ if not hasattr(self, '_msvs_versions'):
+ self.msvs_versions()
+
+ if msvs_ver in ['7.1']:
+ python = '&quot;' + python + '&quot;'
+
+ exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self._scons_version, self._scons_version)
+ exec_script_main_xml = string.replace(exec_script_main, "'", "&apos;")
+
+ result = string.replace(input, r'<WORKPATH>', self.workpath())
+ result = string.replace(result, r'<PYTHON>', python)
+ result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main)
+ result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
+ return result
+
# In some environments, $AR will generate a warning message to stderr
# if the library doesn't previously exist and is being created. One
# way to fix this is to tell AR to be quiet (sometimes the 'c' flag),