When using a long link line in a temporary file, print the command line first. ...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 4 Aug 2003 05:54:20 +0000 (05:54 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 4 Aug 2003 05:54:20 +0000 (05:54 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@759 fdb21ef1-2011-0410-befe-b5e4ea1792b1

doc/man/scons.1
src/CHANGES.txt
src/engine/SCons/Platform/win32.py

index 862b65fd257bcfee56279c026f6cb85be914e1b4..13320203dd1a5932d403c7db7678bd0dedfdd3e1 100644 (file)
@@ -2954,6 +2954,12 @@ General options passed to the M4 macro preprocessor.
 .IP M4COM
 The command line used to pass files through the macro preprocessor.
 
+.IP MAXLINELENGTH
+The maximum number of characters allowed on an external command line.
+On Win32 systems,
+link lines longer than this many characters
+are linke via a temporary file name.
+
 .IP MSVS
 When the Microsoft Visual Studio tools are initialized, they set up
 this dictionary with the following keys:
index 9a1966d17b2d08a4970a2f2030e1321e468c47b7..f10bb348609f28e66f07c287c1524ec430282ee3 100644 (file)
@@ -80,6 +80,9 @@ RELEASE 0.XX - XXX
   - Allow the "prefix" and "suffix" attributes of a Builder to be
     callable objects that return generated strings.
 
+  - Support a MAXLINELINELENGTH construction variable on Win32 systems
+    to control when a temporary file is used for long command lines.
+
   From Gary Oberbrunner:
 
   - Report the target being built in error messages when building
@@ -95,6 +98,10 @@ RELEASE 0.XX - XXX
 
   - Supply a stack trace if the Taskmaster catches an exception.
 
+  - When using a temporary file for a long link line on Win32 systems,
+    (also) print the command line that is being executed through the
+    temporary file.
+
   From Laurent Pelecq:
 
   - When the -debug=pdb option is specified, use pdb.Pdb().runcall() to
index 5303f3214a9ef8037e5529877016fde7cdffdad5..161da908f00212acccae19af1439f783e3852ffc 100644 (file)
@@ -39,6 +39,9 @@ import sys
 import tempfile
 from SCons.Platform.posix import exitvalmap
 
+# XXX See note below about why importing SCons.Action should be
+# eventually refactored.
+import SCons.Action
 import SCons.Util
 
 class TempFileMunge:
@@ -55,9 +58,14 @@ class TempFileMunge:
         self.cmd = cmd
 
     def __call__(self, target, source, env, for_signature):
+        if for_signature:
+            return self.cmd
         cmd = env.subst_list(self.cmd, 0, target, source)[0]
-        if for_signature or \
-           (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= 2048:
+        try:
+            maxline = int(env.subst('$MAXLINELENGTH'))
+        except ValueError:
+            maxline = 2048
+        if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline:
             return self.cmd
         else:
             # In Cygwin, we want to use rm to delete the temporary file,
@@ -82,6 +90,24 @@ class TempFileMunge:
 
             args = map(SCons.Util.quote_spaces, cmd[1:])
             open(tmp, 'w').write(string.join(args, " ") + "\n")
+            # XXX Using the SCons.Action.print_actions value directly
+            # like this is bogus, but expedient.  This class should
+            # really be rewritten as an Action that defines the
+            # __call__() and strfunction() methods and lets the
+            # normal action-execution logic handle whether or not to
+            # print/execute the action.  The problem, though, is all
+            # of that is decided before we execute this method as
+            # part of expanding the $TEMPFILE construction variable.
+            # Consequently, refactoring this will have to wait until
+            # we get more flexible with allowing Actions to exist
+            # independently and get strung together arbitrarily like
+            # Ant tasks.  In the meantime, it's going to be more
+            # user-friendly to not let obsession with architectural
+            # purity get in the way of just being helpful, so we'll
+            # reach into SCons.Action directly.
+            if SCons.Action.print_actions:
+                print("Using tempfile "+native_tmp+" for command line:\n"+
+                      str(cmd[0]) + " " + string.join(args," "))
             return [ cmd[0], '@' + native_tmp + '\n' + rm, native_tmp ]
 
 # The upshot of all this is that, if you are using Python 1.5.2,
@@ -289,4 +315,5 @@ def generate(env):
     env['SPAWN']          = spawn
     env['SHELL']          = cmd_interp
     env['TEMPFILE']       = TempFileMunge
+    env['MAXLINELENGTH']  = 2048
     env['ESCAPE']         = escape