summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/CHANGES.txt5
-rw-r--r--src/engine/SCons/Platform/win32.py24
-rw-r--r--src/engine/SCons/Tool/lib.py11
-rw-r--r--src/engine/SCons/Tool/mslink.py29
4 files changed, 43 insertions, 26 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 626db72..586f81a 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -23,6 +23,11 @@ RELEASE 0.09 -
- Support file names with odd characters in them.
+ From Matt Balvin:
+
+ - Add long command-line support to the "lib" (MicroSoft static library)
+ Tool, too.
+
From Steven Knight:
- Fix auto-deduction of target names so that deduced targets end
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.
diff --git a/src/engine/SCons/Tool/lib.py b/src/engine/SCons/Tool/lib.py
index d1b3bf0..ed93bb9 100644
--- a/src/engine/SCons/Tool/lib.py
+++ b/src/engine/SCons/Tool/lib.py
@@ -35,6 +35,15 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Defaults
+from SCons.Platform.win32 import TempFileMunge
+
+def win32ArGenerator(env, target, source, for_signature, **kw):
+ args = [ '$AR', '$ARFLAGS', '/OUT:%s' % target[0]]
+ args.extend(map(SCons.Util.to_String, source))
+ return TempFileMunge(env, args, for_signature)
+
+ArAction = SCons.Action.CommandGenerator(win32ArGenerator)
+
def generate(env, platform):
"""Add Builders and construction variables for lib to an Environment."""
env['BUILDERS']['Library'] = SCons.Defaults.StaticLibrary
@@ -42,7 +51,7 @@ def generate(env, platform):
env['AR'] = 'lib'
env['ARFLAGS'] = '/nologo'
- env['ARCOM'] = '$AR $ARFLAGS /OUT:$TARGET $SOURCES'
+ env['ARCOM'] = ArAction
def exists(env):
return env.Detect('lib')
diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py
index 79bf1d8..133e700 100644
--- a/src/engine/SCons/Tool/mslink.py
+++ b/src/engine/SCons/Tool/mslink.py
@@ -36,35 +36,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os.path
import string
+import SCons.Action
import SCons.Defaults
import SCons.Errors
-import SCons.Action
import SCons.Util
import msvc
+from SCons.Platform.win32 import TempFileMunge
from SCons.Tool.msvc import get_msdev_paths
-
-def win32TempFileMunge(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] ]
def win32LinkGenerator(env, target, source, for_signature):
args = [ '$LINK', '$LINKFLAGS', '/OUT:%s' % target[0],
@@ -74,7 +53,7 @@ def win32LinkGenerator(env, target, source, for_signature):
args.extend(['/PDB:%s'%target[0].File(env['PDB']), '/DEBUG'])
args.extend(map(SCons.Util.to_String, source))
- return win32TempFileMunge(env, args, for_signature)
+ return TempFileMunge(env, args, for_signature)
def win32LibGenerator(target, source, env, for_signature):
listCmd = [ "$SHLINK", "$SHLINKFLAGS" ]
@@ -103,7 +82,7 @@ def win32LibGenerator(target, source, env, for_signature):
# Just treat it as a generic source file.
listCmd.append(str(src))
- return win32TempFileMunge(env, listCmd, for_signature)
+ return TempFileMunge(env, listCmd, for_signature)
def win32LibEmitter(target, source, env):
msvc.validate_vars(env)