From bb2a3a476f2ae500d381561360da3cb710b978ba Mon Sep 17 00:00:00 2001 From: stevenknight Date: Mon, 4 Aug 2003 05:54:20 +0000 Subject: [PATCH] When using a long link line in a temporary file, print the command line first. (Gary Oberbrunner) Support a MAXLINELENGTH construction variable so the threshold can be configured in a construction environment. git-svn-id: http://scons.tigris.org/svn/scons/trunk@759 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- doc/man/scons.1 | 6 ++++++ src/CHANGES.txt | 7 +++++++ src/engine/SCons/Platform/win32.py | 31 ++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 862b65fd..13320203 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -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: diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9a1966d1..f10bb348 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 5303f321..161da908 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -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 -- 2.26.2