From f7e5d2b46b03cc4bc09c38f7e0873378bb9c3b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 21 Jun 2015 07:55:15 +0200 Subject: Imported Upstream version 2.3.5 --- src/engine/SCons/Platform/PlatformTests.py | 35 +++++++++++++++++++++++++++-- src/engine/SCons/Platform/__init__.py | 36 ++++++++++++++++++++++++------ src/engine/SCons/Platform/__init__.xml | 2 +- src/engine/SCons/Platform/aix.py | 4 ++-- src/engine/SCons/Platform/cygwin.py | 4 ++-- src/engine/SCons/Platform/darwin.py | 4 ++-- src/engine/SCons/Platform/hpux.py | 4 ++-- src/engine/SCons/Platform/irix.py | 4 ++-- src/engine/SCons/Platform/os2.py | 4 ++-- src/engine/SCons/Platform/posix.py | 4 ++-- src/engine/SCons/Platform/posix.xml | 2 +- src/engine/SCons/Platform/sunos.py | 4 ++-- src/engine/SCons/Platform/sunos.xml | 2 +- src/engine/SCons/Platform/win32.py | 4 ++-- src/engine/SCons/Platform/win32.xml | 2 +- 15 files changed, 84 insertions(+), 31 deletions(-) (limited to 'src/engine/SCons/Platform') diff --git a/src/engine/SCons/Platform/PlatformTests.py b/src/engine/SCons/Platform/PlatformTests.py index 69128b2..da7adac 100644 --- a/src/engine/SCons/Platform/PlatformTests.py +++ b/src/engine/SCons/Platform/PlatformTests.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001 - 2014 The SCons Foundation +# Copyright (c) 2001 - 2015 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/PlatformTests.py 2014/09/27 12:51:43 garyo" +__revision__ = "src/engine/SCons/Platform/PlatformTests.py pchdll:3325:cd517fae59a4 2015/06/18 06:53:27 bdbaddog" import SCons.compat @@ -156,6 +156,37 @@ class TempFileMungeTestCase(unittest.TestCase): SCons.Action.print_actions = old_actions assert cmd != defined_cmd, cmd + def test_tempfilecreation_once(self): + # Init class with cmd, such that the fully expanded + # string reads "a test command line". + # Note, how we're using a command string here that is + # actually longer than the substituted one. This is to ensure + # that the TempFileMunge class internally really takes the + # length of the expanded string into account. + defined_cmd = "a $VERY $OVERSIMPLIFIED line" + t = SCons.Platform.TempFileMunge(defined_cmd) + env = SCons.Environment.SubstitutionEnvironment(tools=[]) + # Setting the line length high enough... + env['VERY'] = 'test' + env['OVERSIMPLIFIED'] = 'command' + expanded_cmd = env.subst(defined_cmd) + env['MAXLINELENGTH'] = len(expanded_cmd)-1 + # Disable printing of actions... + old_actions = SCons.Action.print_actions + SCons.Action.print_actions = 0 + # Create an instance of object derived class to allow setattrb + class Node(object) : + class Attrs(object): + pass + def __init__(self): + self.attributes = self.Attrs() + target = [Node()] + cmd = t(target, None, env, 0) + # ...and restoring its setting. + SCons.Action.print_actions = old_actions + assert cmd != defined_cmd, cmd + assert cmd == getattr(target[0].attributes, 'tempfile_cmdlist', None) + if __name__ == "__main__": suite = unittest.TestSuite() diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 679191e..7c1b9d5 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -20,7 +20,7 @@ their own platform definition. """ # -# Copyright (c) 2001 - 2014 The SCons Foundation +# Copyright (c) 2001 - 2015 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -42,7 +42,7 @@ their own platform definition. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/__init__.py 2014/09/27 12:51:43 garyo" +__revision__ = "src/engine/SCons/Platform/__init__.py pchdll:3325:cd517fae59a4 2015/06/18 06:53:27 bdbaddog" import SCons.compat @@ -139,7 +139,7 @@ class TempFileMunge(object): Example usage: env["TEMPFILE"] = TempFileMunge - env["LINKCOM"] = "${TEMPFILE('$LINK $TARGET $SOURCES')}" + env["LINKCOM"] = "${TEMPFILE('$LINK $TARGET $SOURCES','$LINKCOMSTR')}" By default, the name of the temporary file used begins with a prefix of '@'. This may be configred for other tool chains by @@ -148,8 +148,9 @@ class TempFileMunge(object): env["TEMPFILEPREFIX"] = '-@' # diab compiler env["TEMPFILEPREFIX"] = '-via' # arm tool chain """ - def __init__(self, cmd): + def __init__(self, cmd, cmdstr = None): self.cmd = cmd + self.cmdstr = cmdstr def __call__(self, target, source, env, for_signature): if for_signature: @@ -177,6 +178,14 @@ class TempFileMunge(object): if length <= maxline: return self.cmd + # Check if we already created the temporary file for this target + # It should have been previously done by Action.strfunction() call + node = target[0] if SCons.Util.is_List(target) else target + cmdlist = getattr(node.attributes, 'tempfile_cmdlist', None) \ + if node is not None else None + if cmdlist is not None : + return cmdlist + # We do a normpath because mktemp() has what appears to be # a bug in Windows that will use a forward slash as a path # delimiter. Windows's link mistakes that for a command line @@ -224,9 +233,22 @@ class TempFileMunge(object): # 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]) + " " + " ".join(args)) - return [ cmd[0], prefix + native_tmp + '\n' + rm, native_tmp ] + cmdstr = env.subst(self.cmdstr, SCons.Subst.SUBST_RAW, target, + source) if self.cmdstr is not None else '' + # Print our message only if XXXCOMSTR returns an empty string + if len(cmdstr) == 0 : + print("Using tempfile "+native_tmp+" for command line:\n"+ + str(cmd[0]) + " " + " ".join(args)) + + # Store the temporary file command list into the target Node.attributes + # to avoid creating two temporary files one for print and one for execute. + cmdlist = [ cmd[0], prefix + native_tmp + '\n' + rm, native_tmp ] + if node is not None: + try : + setattr(node.attributes, 'tempfile_cmdlist', cmdlist) + except AttributeError: + pass + return cmdlist def Platform(name = platform_default()): """Select a canned Platform specification. diff --git a/src/engine/SCons/Platform/__init__.xml b/src/engine/SCons/Platform/__init__.xml index d3cce6c..e6cecaf 100644 --- a/src/engine/SCons/Platform/__init__.xml +++ b/src/engine/SCons/Platform/__init__.xml @@ -1,6 +1,6 @@