From 0eb972bc750cb0493a75a400408c914889a8cb8b Mon Sep 17 00:00:00 2001 From: stevenknight Date: Tue, 7 Oct 2003 06:08:46 +0000 Subject: [PATCH] Don't remove temporary files on win32 with rm when cygwin is not in use. (Anthony Roach) Win32 portability fixes. git-svn-id: http://scons.tigris.org/svn/scons/trunk@814 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 5 +++++ src/engine/SCons/EnvironmentTests.py | 2 +- src/engine/SCons/Platform/win32.py | 16 ++++++++++------ test/SharedLibrary.py | 4 +++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a5d2b3da..fd9fca6c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -128,6 +128,11 @@ RELEASE X.XX - XXX - Have the closing message say "...terminated because of errors" if there were any. + From Anthony Roach: + + - On Win32 systems, only use "rm" to delete files if Cygwin is being + used. ("rm" doesn't understand Win32-format path names.) + From Christoph Wiedemann: - Fix test/SWIG.py to find the Python include directory in all cases. diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 3c8438f3..f46df737 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1568,7 +1568,7 @@ class EnvironmentTestCase(unittest.TestCase): import SCons.Sig class MyFS: - SConstruct_dir = '/dir' + SConstruct_dir = os.sep + 'dir' env = Environment(FOO = 'SConsign', BAR = os.path.join(os.sep, 'File')) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 161da908..08fb2966 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -68,10 +68,6 @@ class TempFileMunge: 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, - # because del does not exist in the sh shell. - rm = env.Detect('rm') or 'del' - # 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 @@ -83,10 +79,18 @@ class TempFileMunge: tmp = os.path.normpath(tempfile.mktemp('.lnk')) native_tmp = SCons.Util.get_native_path(tmp) - # The sh shell will try to escape the backslashes in the - # path, so unescape them. if env['SHELL'] and env['SHELL'] == 'sh': + # The sh shell will try to escape the backslashes in the + # path, so unescape them. native_tmp = string.replace(native_tmp, '\\', r'\\\\') + # In Cygwin, we want to use rm to delete the temporary + # file, because del does not exist in the sh shell. + rm = env.Detect('rm') or 'del' + else: + # Don't use 'rm' if the shell is not sh, because rm won't + # work with the win32 shells (cmd.exe or command.com) or + # win32 path names. + rm = 'del' args = map(SCons.Util.quote_spaces, cmd[1:]) open(tmp, 'w').write(string.join(args, " ") + "\n") diff --git a/test/SharedLibrary.py b/test/SharedLibrary.py index 680cf79b..7eb714cd 100644 --- a/test/SharedLibrary.py +++ b/test/SharedLibrary.py @@ -43,7 +43,9 @@ if sys.platform == 'win32': env.StaticLibrary(target = 'foo1-static', source = 'f1.c') else: env.StaticLibrary(target = 'foo1', source = 'f1.c') -SharedLibrary(target = 'foo2', source = Split('f2a.c f2b.c f2c.c')) +SharedLibrary(target = 'foo2', + source = Split('f2a.c f2b.c f2c.c'), + WIN32_INSERT_DEF = 1) env.SharedLibrary(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) env2.Program(target = 'prog', source = 'prog.c') """) -- 2.26.2