diff options
author | Steven Knight <knight@baldmt.com> | 2003-04-30 19:38:19 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-04-30 19:38:19 (GMT) |
commit | 3387eab42442c7fe7ed0064de5b939497cc6df1b (patch) | |
tree | 3c34e3c08fe379c147c7166067d05a0a87fccaa6 | |
parent | 212d77d88aa4374ef13f2e6bc7edf3395ac9736c (diff) | |
download | SCons-3387eab42442c7fe7ed0064de5b939497cc6df1b.zip SCons-3387eab42442c7fe7ed0064de5b939497cc6df1b.tar.gz SCons-3387eab42442c7fe7ed0064de5b939497cc6df1b.tar.bz2 |
Test portability fixes for Cygwin. (Chad Austin)
36 files changed, 134 insertions, 158 deletions
diff --git a/etc/TestSCons.py b/etc/TestSCons.py index f9c4edf..4fe8b5b 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -24,9 +24,33 @@ import TestCmd python = TestCmd.python_executable -if string.find(sys.platform, 'irix') != -1: +if sys.platform == 'win32': + _exe = '.exe' + _obj = '.obj' + _shobj = '.obj' + _dll = '.dll' + lib_ = '' + fortran_lib = 'g2c' +elif sys.platform == 'cygwin': + _exe = '.exe' + _obj = '.o' + _shobj = '.os' + _dll = '.dll' + lib_ = '' + fortran_lib = 'g2c' +elif string.find(sys.platform, 'irix') != -1: + _exe = '' + _obj = '.o' + _shobj = '.o' + _dll = '.so' + lib_ = 'lib' fortran_lib = 'ftn' else: + _exe = '' + _obj = '.o' + _shobj = '.os' + _dll = '.so' + lib_ = 'lib' fortran_lib = 'g2c' class TestFailed(Exception): diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 1260850..d7be127 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -346,6 +346,9 @@ class LazyCmdGenerator: # The variable reference substitutes to nothing. return '' + def __cmp__(self, other): + return cmp(self.__dict__, other.__dict__) + class FunctionAction(ActionBase): """Class for Python function actions.""" diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 9189b4c..4aee748 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -412,11 +412,24 @@ class CommandActionTestCase(unittest.TestCase): assert c == "act.py: 'three' 'four'\n", c cmd5 = r'%s %s %s $TARGET XYZZY' % (python, act_py, outfile) + + act = SCons.Action.CommandAction(cmd5) + env5 = Environment() + if scons_env.has_key('ENV'): + env5['ENV'] = scons_env['ENV'] + PATH = scons_env['ENV'].get('PATH', '') + else: + env5['ENV'] = {} + PATH = '' + + env5['ENV']['XYZZY'] = 'xyzzy' + r = act(target = 'out5', source = [], env = env5) act = SCons.Action.CommandAction(cmd5) r = act(target = 'out5', source = [], - env = env.Copy(ENV = {'XYZZY' : 'xyzzy'})) + env = env.Copy(ENV = {'XYZZY' : 'xyzzy', + 'PATH' : PATH})) assert r == 0 c = test.read(outfile, 'r') assert c == "act.py: 'out5' 'XYZZY'\nact.py: 'xyzzy'\n", c @@ -460,6 +473,9 @@ class CommandActionTestCase(unittest.TestCase): # as "file not found" errors expect_nonexistent = 1 expect_nonexecutable = 1 + elif sys.platform == 'cygwin': + expect_nonexistent = 127 + expect_nonexecutable = 127 else: expect_nonexistent = 127 expect_nonexecutable = 126 diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index c041755..e99ea0d 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -54,6 +54,28 @@ def diff_env(env1, env2): s2 = s2 + "}\n" return s1 + s2 +def diff_dict(d1, d2): + s1 = "d1 = {\n" + s2 = "d2 = {\n" + d = {} + for k in d1.keys() + d2.keys(): + d[k] = None + keys = d.keys() + keys.sort() + for k in keys: + if d1.has_key(k): + if d2.has_key(k): + if d1[k] != d2[k]: + s1 = s1 + " " + repr(k) + " : " + repr(d1[k]) + "\n" + s2 = s2 + " " + repr(k) + " : " + repr(d2[k]) + "\n" + else: + s1 = s1 + " " + repr(k) + " : " + repr(d1[k]) + "\n" + elif env2.has_key(k): + s2 = s2 + " " + repr(k) + " : " + repr(d2[k]) + "\n" + s1 = s1 + "}\n" + s2 = s2 + "}\n" + return s1 + s2 + called_it = {} built_it = {} @@ -372,6 +394,11 @@ class EnvironmentTestCase(unittest.TestCase): def test_Append(self): """Test appending to construction variables in an Environment """ + + b1 = Environment()['BUILDERS'] + b2 = Environment()['BUILDERS'] + assert b1 == b2, diff_dict(b1, b2) + import UserList UL = UserList.UserList env1 = Environment(AAA = 'a', BBB = 'b', CCC = 'c', DDD = 'd', diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py index 5aa83d5..79d50e4 100644 --- a/src/engine/SCons/Tool/gs.py +++ b/src/engine/SCons/Tool/gs.py @@ -41,7 +41,7 @@ platform = SCons.Platform.platform_default() if platform == 'os2': gs = 'gsos2' -elif platform == 'cygwin' or platform == 'win32': +elif platform == 'win32': gs = 'gswin32c' else: gs = 'gs' @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/ARFLAGS.py b/test/ARFLAGS.py index 4936721..54cb463 100644 --- a/test/ARFLAGS.py +++ b/test/ARFLAGS.py @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() @@ -67,11 +63,14 @@ inf = None while args: a = args[0] args = args[1:] - if a[0] != '/': + if not a[0] in "/-": if not inf: inf = a continue if a[:3] == '/Fo': out = a[3:] + if a == '-o': + out = args[0] + args = args[1:] infile = open(inf, 'rb') outfile = open(out, 'wb') for l in infile.readlines(): diff --git a/test/ASFLAGS.py b/test/ASFLAGS.py index 0331aed..d750a6a 100644 --- a/test/ASFLAGS.py +++ b/test/ASFLAGS.py @@ -32,12 +32,11 @@ import TestSCons python = TestSCons.python test = TestSCons.TestSCons() +_exe = TestSCons._exe if sys.platform == 'win32': - _exe = '.exe' - o = ' -x' o_c = ' -x' @@ -89,8 +88,6 @@ sys.exit(0) else: - _exe = '' - o = ' -x' o_c = ' -x -c' @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/CPPFLAGS.py b/test/CPPFLAGS.py index d8587c6..87f5603 100644 --- a/test/CPPFLAGS.py +++ b/test/CPPFLAGS.py @@ -30,18 +30,9 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' - _obj = '.obj' - _shobj = '.obj' -else: - _exe = '' - _obj = '.o' - if string.find(sys.platform, 'irix') > -1: - _shobj = '.o' - else: - _shobj = '.os' +_exe = TestSCons._exe +_obj = TestSCons._obj +_shobj = TestSCons._shobj test = TestSCons.TestSCons() diff --git a/test/CPPPATH.py b/test/CPPPATH.py index cb650fa..1f93bf5 100644 --- a/test/CPPPATH.py +++ b/test/CPPPATH.py @@ -28,10 +28,7 @@ import os import sys import TestSCons -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe prog = 'prog' + _exe subdir_prog = os.path.join('subdir', 'prog' + _exe) diff --git a/test/CXX.py b/test/CXX.py index cd2c7a9..bff7708 100644 --- a/test/CXX.py +++ b/test/CXX.py @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/ENV.py b/test/ENV.py index f92a2d8..31ad970 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -37,8 +37,10 @@ bin2_build_py = test.workpath('bin2', 'build.py') test.write('SConstruct', """ import os Bld = Builder(action = r"%s build.py $TARGET $SOURCES") -env1 = Environment(ENV = {'X' : 'env1'}, BUILDERS = { 'Bld' : Bld }) -env2 = Environment(ENV = {'X' : 'env2'}, BUILDERS = { 'Bld' : Bld }) +env1 = Environment(BUILDERS = { 'Bld' : Bld }) +env2 = Environment(BUILDERS = { 'Bld' : Bld }) +env1['ENV']['X'] = 'env1' +env2['ENV']['X'] = 'env2' env1.Bld(target = 'env1.out', source = 'input') env2.Bld(target = 'env2.out', source = 'input') """ % python) diff --git a/test/F77.py b/test/F77.py index f95dee9..0346765 100644 --- a/test/F77.py +++ b/test/F77.py @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/F77FLAGS.py b/test/F77FLAGS.py index b914701..b72c618 100644 --- a/test/F77FLAGS.py +++ b/test/F77FLAGS.py @@ -32,12 +32,10 @@ import TestSCons python = TestSCons.python test = TestSCons.TestSCons() - +_exe = TestSCons._exe if sys.platform == 'win32': - _exe = '.exe' - test.write('mylink.py', r""" import string import sys @@ -58,8 +56,6 @@ sys.exit(0) else: - _exe = '' - test.write('mylink.py', r""" import getopt import sys diff --git a/test/LEX.py b/test/LEX.py index 38d73fb..90549bd 100644 --- a/test/LEX.py +++ b/test/LEX.py @@ -31,11 +31,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/LEXFLAGS.py b/test/LEXFLAGS.py index c3ae182..ba440da 100644 --- a/test/LEXFLAGS.py +++ b/test/LEXFLAGS.py @@ -31,11 +31,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/LIBPATH.py b/test/LIBPATH.py index 2730be3..6e2a836 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -29,14 +29,9 @@ import sys import os.path import time -if sys.platform == 'win32': - _exe = '.exe' - _dll = '.dll' - lib_ = '' -else: - _exe = '' - _dll = '.so' - lib_ = 'lib' +_exe = TestSCons._exe +_dll = TestSCons._dll +lib_ = TestSCons.lib_ test = TestSCons.TestSCons() diff --git a/test/LINK.py b/test/LINK.py index 982cc88..e3c21bc 100644 --- a/test/LINK.py +++ b/test/LINK.py @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/LINKFLAGS.py b/test/LINKFLAGS.py index d5a1e40..58efcf3 100644 --- a/test/LINKFLAGS.py +++ b/test/LINKFLAGS.py @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/Program-j.py b/test/Program-j.py index 3e29040..fe778b3 100644 --- a/test/Program-j.py +++ b/test/Program-j.py @@ -27,10 +27,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys import TestSCons -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe f1 = 'f1' + _exe f2 = 'f2' + _exe diff --git a/test/Program.py b/test/Program.py index b05a73a..3030172 100644 --- a/test/Program.py +++ b/test/Program.py @@ -29,10 +29,7 @@ import sys import time import TestSCons -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/RANLIB.py b/test/RANLIB.py index 4879a83..cb8f1db 100644 --- a/test/RANLIB.py +++ b/test/RANLIB.py @@ -32,10 +32,7 @@ import TestSCons python = TestSCons.python -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/RANLIBFLAGS.py b/test/RANLIBFLAGS.py index 0554d4c..fec606d 100644 --- a/test/RANLIBFLAGS.py +++ b/test/RANLIBFLAGS.py @@ -30,11 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/SHF77.py b/test/SHF77.py index 23e9bf3..d78ef82 100644 --- a/test/SHF77.py +++ b/test/SHF77.py @@ -30,14 +30,7 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - _obj = '.obj' -else: - if string.find(sys.platform, 'irix') > -1: - _obj = '.o' - else: - _obj = '.os' +_obj = TestSCons._shobj test = TestSCons.TestSCons() diff --git a/test/SHLIBPREFIX.py b/test/SHLIBPREFIX.py index f830b68..25bca5f 100644 --- a/test/SHLIBPREFIX.py +++ b/test/SHLIBPREFIX.py @@ -28,10 +28,7 @@ import os import sys import TestSCons -if sys.platform == 'win32': - _lib = '.dll' -else: - _lib = '.so' +_lib = TestSCons._dll test = TestSCons.TestSCons() diff --git a/test/SHLIBSUFFIX.py b/test/SHLIBSUFFIX.py index 734f6c6..4c2d7ac 100644 --- a/test/SHLIBSUFFIX.py +++ b/test/SHLIBSUFFIX.py @@ -28,10 +28,7 @@ import os import sys import TestSCons -if sys.platform == 'win32': - lib_ = '' -else: - lib_ = 'lib' +lib_ = TestSCons.lib_ test = TestSCons.TestSCons() diff --git a/test/SHLINK.py b/test/SHLINK.py index 3fd8e75..7f1c63d 100644 --- a/test/SHLINK.py +++ b/test/SHLINK.py @@ -30,14 +30,9 @@ import sys import TestSCons python = TestSCons.python +lib_ = TestSCons.lib_ +_shlib = TestSCons._dll -if sys.platform == 'win32': - lib_ = '' - _shlib='.dll' -else: - lib_ = 'lib' - _shlib='.so' - test = TestSCons.TestSCons() test.write("wrapper.py", diff --git a/test/SHLINKFLAGS.py b/test/SHLINKFLAGS.py index 85ad6a3..9a4a6cc 100644 --- a/test/SHLINKFLAGS.py +++ b/test/SHLINKFLAGS.py @@ -30,13 +30,8 @@ import sys import TestSCons python = TestSCons.python - -if sys.platform == 'win32': - lib_ = '' - _shlib = '.dll' -else: - lib_ = 'lib' - _shlib = '.so' +lib_ = TestSCons.lib_ +_shlib = TestSCons._dll test = TestSCons.TestSCons() diff --git a/test/YACC.py b/test/YACC.py index 4854905..b44add1 100644 --- a/test/YACC.py +++ b/test/YACC.py @@ -31,13 +31,12 @@ import sys import TestSCons python = TestSCons.python +_exe = TestSCons._exe if sys.platform == 'win32': - _exe = '.exe' compiler = 'msvc' linker = 'mslink' else: - _exe = '' compiler = 'gcc' linker = 'gnulink' diff --git a/test/YACCFLAGS.py b/test/YACCFLAGS.py index 987025f..3ed6b6b 100644 --- a/test/YACCFLAGS.py +++ b/test/YACCFLAGS.py @@ -31,13 +31,12 @@ import sys import TestSCons python = TestSCons.python +_exe = TestSCons._exe if sys.platform == 'win32': - _exe = '.exe' compiler = 'msvc' linker = 'mslink' else: - _exe = '' compiler = 'gcc' linker = 'gnulink' diff --git a/test/long-lines.py b/test/long-lines.py index 3999f62..9d38504 100644 --- a/test/long-lines.py +++ b/test/long-lines.py @@ -32,13 +32,20 @@ import TestSCons test = TestSCons.TestSCons() -if sys.platform in ['win32', 'cygwin']: +if sys.platform == 'win32': lib_static_lib = 'static.lib' lib_shared_dll ='shared.dll' arflag_init = '/LIBPATH:' + test.workpath() arflag = ' /LIBPATH:' + test.workpath() linkflag_init = '/LIBPATH:' + test.workpath() linkflag = ' /LIBPATH:' + test.workpath() +elif sys.platform == 'cygwin': + lib_static_lib = 'libstatic.a' + lib_shared_dll ='shared.dll' + arflag_init = 'r' + arflag = 'o' + linkflag_init = '-L' + test.workpath() + linkflag = ' -L' + test.workpath() else: lib_shared_dll = 'libshared.so' lib_static_lib = 'libstatic.a' diff --git a/test/option--implicit-cache.py b/test/option--implicit-cache.py index e959856..ac11b2a 100644 --- a/test/option--implicit-cache.py +++ b/test/option--implicit-cache.py @@ -29,12 +29,8 @@ import sys import TestSCons import string -if sys.platform == 'win32': - _exe = '.exe' - _obj = '.obj' -else: - _exe = '' - _obj = '.o' +_exe = TestSCons._exe +_obj = TestSCons._obj prog = 'prog' + _exe subdir_prog = os.path.join('subdir', 'prog' + _exe) diff --git a/test/pre-post-actions.py b/test/pre-post-actions.py index d3139bb..91fcb3b 100644 --- a/test/pre-post-actions.py +++ b/test/pre-post-actions.py @@ -32,10 +32,7 @@ import stat import sys import TestSCons -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' +_exe = TestSCons._exe test = TestSCons.TestSCons() diff --git a/test/special-filenames.py b/test/special-filenames.py index d152e52..2002b37 100644 --- a/test/special-filenames.py +++ b/test/special-filenames.py @@ -32,7 +32,7 @@ import TestSCons test = TestSCons.TestSCons() -file_names = [ +attempt_file_names = [ 'File with spaces', 'File"with"double"quotes', "File'with'single'quotes", @@ -49,17 +49,20 @@ file_names = [ "Combination '\"\n\\;<>?|*\t&" ] -if os.name == 'nt': - # Windows only supports spaces. - file_names = file_names[0:1] - test.write("cat.py", """\ import sys open(sys.argv[1], 'wb').write(open(sys.argv[2], 'rb').read()) """) -for fn in file_names: - test.write(fn + '.in', fn + '\n') +file_names = [] +for fn in attempt_file_names: + try: + test.write(fn + '.in', fn + '\n') + file_names.append(fn) + except IOError: + # if the Python interpreter can't handle it, don't bother + # testing to see if SCons can + pass def buildFileStr(fn): return "env.Build(source=r\"\"\"%s.in\"\"\", target=r\"\"\"%s.out\"\"\")" % ( fn, fn ) |