summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Platform
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-11-30 22:28:19 (GMT)
committerSteven Knight <knight@baldmt.com>2002-11-30 22:28:19 (GMT)
commitbda7af53f40111daabfbcbb07e745e0afce95d2f (patch)
tree26d7804c0bfde9935dc7970a7e4d37ec5ddc0891 /src/engine/SCons/Platform
parent454239b699f5b3b81ef3b10aa3e97361eadbf5f4 (diff)
downloadSCons-bda7af53f40111daabfbcbb07e745e0afce95d2f.zip
SCons-bda7af53f40111daabfbcbb07e745e0afce95d2f.tar.gz
SCons-bda7af53f40111daabfbcbb07e745e0afce95d2f.tar.bz2
Extend Win32 long command-line processing to lib.py. (Matt Balvin)
Diffstat (limited to 'src/engine/SCons/Platform')
-rw-r--r--src/engine/SCons/Platform/win32.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
index b54aefe..db601e1 100644
--- a/src/engine/SCons/Platform/win32.py
+++ b/src/engine/SCons/Platform/win32.py
@@ -38,6 +38,30 @@ import os.path
import string
import sys
+#
+
+def TempFileMunge(env, cmd_list, for_signature):
+ """Given a list of command line arguments, see if it is too
+ long to pass to the win32 command line interpreter. If so,
+ create a temp file, then pass "@tempfile" as the sole argument
+ to the supplied command (which is the first element of cmd_list).
+ Otherwise, just return [cmd_list]."""
+ cmd = env.subst_list(cmd_list)[0]
+ if for_signature or \
+ (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= 2048:
+ return [cmd_list]
+ else:
+ import tempfile
+ # We do a normpath because mktemp() has what appears to be
+ # a bug in Win32 that will use a forward slash as a path
+ # delimiter. Win32's link mistakes that for a command line
+ # switch and barfs.
+ tmp = os.path.normpath(tempfile.mktemp())
+ args = map(SCons.Util.quote_spaces, cmd[1:])
+ open(tmp, 'w').write(string.join(args, " ") + "\n")
+ return [ [cmd[0], '@' + tmp],
+ ['del', tmp] ]
+
# The upshot of all this is that, if you are using Python 1.5.2,
# you had better have cmd or command.com in your PATH when you run
# scons.