diff options
author | Daniel <dmoody256@gmail.com> | 2019-01-12 21:51:31 -0600 |
---|---|---|
committer | Daniel <dmoody256@gmail.com> | 2019-01-12 21:51:31 -0600 |
commit | 36c170d87f89e6ea96c7c4bae1a04963d71d317f (patch) | |
tree | 276c6e364b519b6fe8e372857ff87741158ffbe5 | |
parent | 53c892c123ac9ea3d4f1cdb3e5e0e1887e8c73a4 (diff) | |
download | scons-git-36c170d87f89e6ea96c7c4bae1a04963d71d317f.tar.gz |
accidently reset changes, so recommiting
-rw-r--r-- | src/engine/SCons/Platform/__init__.py | 22 | ||||
-rw-r--r-- | test/TEMPFILEPREFIX.py | 49 |
2 files changed, 69 insertions, 2 deletions
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 8784d5eb6..8117e60b6 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -243,8 +243,9 @@ class TempFileMunge(object): 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)) + cmdstr = ("Using tempfile "+native_tmp+" for command line:\n"+ + str(cmd[0]) + " " + " ".join(args)) + self._print_cmd_str(target, source, env, cmdstr) # Store the temporary file command list into the target Node.attributes # to avoid creating two temporary files one for print and one for execute. @@ -256,6 +257,23 @@ class TempFileMunge(object): pass return cmdlist + def _print_cmd_str(self, target, source, env, cmdstr): + # check if the user has specified a cmd line print function + print_func = None + try: + get = env.get + except AttributeError: + pass + else: + print_func = get('PRINT_CMD_LINE_FUNC') + + # use the default action cmd line print if user did not supply one + if not print_func: + action = SCons.Action._ActionAction() + action.print_cmd_line(cmdstr, target, source, env) + else: + print_func(cmdstr, target, source, env) + def Platform(name = platform_default()): """Select a canned Platform specification. diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index c47ebc421..7f4322b2d 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -67,6 +67,55 @@ xxx.py foo.out foo.in xxx.py -via\\S+ """) +test.write('SConstruct', """ +import os + +def print_cmd_line(s, targets, sources, env): + pass + +env = Environment( + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILEPREFIX = '-via', + PRINT_CMD_LINE_FUNC=print_cmd_line +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.run(arguments = '-n -Q .', + stdout = """""") + +test.write('SConstruct', """ +import os +from SCons.Platform import TempFileMunge + +class TestTempFileMunge(TempFileMunge): + + def __init__(self, cmd, cmdstr = None): + super(TestTempFileMunge, self).__init__(cmd, cmdstr) + + def _print_cmd_str(self, target, source, env, cmdstr): + super(TestTempFileMunge, self)._print_cmd_str(target, source, None, cmdstr) + +env = Environment( + TEMPFILE = TestTempFileMunge, + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILEPREFIX = '-via', + +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.run(arguments = '-n -Q .', + stdout = """\ +Using tempfile \\S+ for command line: +xxx.py foo.out foo.in +xxx.py -via\\S+ +""") + test.pass_test() # Local Variables: |