From Chad Austin:
- - Use .dll (not .so) for shared libraries on Cygwin.
+ - Use .dll (not .so) for shared libraries on Cygwin; use -fPIC
+ when compiling them.
+
+ - Use 'rm' to remove files under Cygwin.
- Add a PLATFORM variable to construction environments.
return self.cmd
else:
import tempfile
+
+ # 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
# switch and barfs.
tmp = os.path.normpath(tempfile.mktemp())
+ 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':
+ native_tmp = string.replace(native_tmp, '\\', r'\\\\')
+
+
args = map(SCons.Util.quote_spaces, cmd[1:])
open(tmp, 'w').write(string.join(args, " ") + "\n")
- return [ cmd[0], '@' + tmp + '\ndel', tmp ]
+ return [ cmd[0], '@' + native_tmp + '\n' + rm, native_tmp ]
# The upshot of all this is that, if you are using Python 1.5.2,
# you had better have cmd or command.com in your PATH when you run
env = Environment()
env['BUILDERS'] = {}
env['ENV'] = {}
+ env['PLATFORM'] = 'test'
t = SCons.Tool.Tool('g++')
t(env)
assert (env['CXX'] == 'c++' or env['CXX'] == 'g++'), env['CXX']
env['CXXFLAGS'] = '$CCFLAGS'
env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
env['SHCXX'] = '$CXX'
- env['SHCXXFLAGS'] = '$CXXFLAGS -fPIC'
+ if env['PLATFORM'] == 'cygwin':
+ env['SHCXXFLAGS'] = '$CXXFLAGS'
+ else:
+ env['SHCXXFLAGS'] = '$CXXFLAGS -fPIC'
env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
env['INCPREFIX'] = '-I'
env['INCSUFFIX'] = ''
env['CCFLAGS'] = ''
env['CCCOM'] = '$CC $CCFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
env['SHCC'] = '$CC'
- env['SHCCFLAGS'] = '$CCFLAGS -fPIC'
+ if env['PLATFORM'] == 'cygwin':
+ env['SHCCFLAGS'] = '$CCFLAGS'
+ else:
+ env['SHCCFLAGS'] = '$CCFLAGS -fPIC'
env['SHCCCOM'] = '$SHCC $SHCCFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
env['SHOBJSUFFIX'] = '.os'
env['INCPREFIX'] = '-I'
except OSError, e:
print "scons: Could not remove '%s':" % str(path), e.strerror
+if sys.platform == 'cygwin':
+ def get_native_path(path):
+ """Transforms an absolute path into a native path for the system. In
+ Cygwin, this converts from a Cygwin path to a Win32 one."""
+ return string.replace(os.popen('cygpath -w ' + path).read(), '\n', '')
+else:
+ def get_native_path(path):
+ """Transforms an absolute path into a native path for the system.
+ Non-Cygwin version, just leave the path alone."""
+ return path
+
display = DisplayEngine()
test._dirlist = None
sys.stdout = old_stdout
+ def test_get_native_path(self):
+ """Test the get_native_path() function."""
+ import tempfile
+ filename = tempfile.mktemp()
+ str = '1234567890 ' + filename
+ open(filename, 'w').write(str)
+ assert open(SCons.Util.get_native_path(filename)).read() == str
+
def test_subst_dict(self):
"""Test substituting dictionary values in an Action
"""
test = TestSCons.TestSCons()
-if sys.platform == 'win32':
+if sys.platform in ['win32', 'cygwin']:
lib_static_lib = 'static.lib'
lib_shared_dll ='shared.dll'
arflag_init = '/LIBPATH:' + test.workpath()