From 8de5ae79c1f6096683ee125b38b2e2d7525b7f07 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Mon, 10 Nov 2003 16:13:15 +0000 Subject: Use sys.stdout.write() instead of print so line feeds in -j output will stay (more) consistent. Fix suffix-handling on case-insensitive Cygwin systems. Test fixes for Cygwin portability. (Chad Austin) --- etc/TestSCons.py | 16 ++++++++++++---- src/CHANGES.txt | 10 ++++++++++ src/engine/SCons/Action.py | 3 ++- src/engine/SCons/Tool/as.py | 6 +++--- src/engine/SCons/Tool/c++.py | 2 +- src/engine/SCons/Tool/cc.py | 2 +- src/engine/SCons/Tool/f77.py | 6 +++--- src/engine/SCons/Tool/gcc.py | 2 +- src/engine/SCons/Tool/masm.py | 6 +++--- src/engine/SCons/Tool/msvc.py | 2 +- src/engine/SCons/Tool/msvs.py | 18 +++++++++--------- src/engine/SCons/Tool/nasm.py | 6 +++--- src/engine/SCons/Tool/qt.py | 7 ++++++- src/engine/SCons/Util.py | 12 +++++++++++- test/Configure.py | 2 +- test/LIBPATH.py | 4 ++-- test/QT.py | 8 +++++--- test/SHLIBSUFFIX.py | 4 ++-- test/SHLINK.py | 6 +++--- test/SHLINKFLAGS.py | 2 +- test/gnutools.py | 22 ++++++++++++++-------- 21 files changed, 94 insertions(+), 52 deletions(-) diff --git a/etc/TestSCons.py b/etc/TestSCons.py index e0139f9..1ce60e4 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -50,29 +50,37 @@ if sys.platform == 'win32': _exe = '.exe' _obj = '.obj' _shobj = '.obj' - _dll = '.dll' lib_ = '' + _lib = '.lib' + dll_ = '' + _dll = '.dll' fortran_lib = gccFortranLibs() elif sys.platform == 'cygwin': _exe = '.exe' _obj = '.o' _shobj = '.os' + lib_ = 'lib' + _lib = '.a' + dll_ = '' _dll = '.dll' - lib_ = '' fortran_lib = gccFortranLibs() elif string.find(sys.platform, 'irix') != -1: _exe = '' _obj = '.o' _shobj = '.o' - _dll = '.so' lib_ = 'lib' + _lib = '.a' + dll_ = 'lib' + _dll = '.so' fortran_lib = ['ftn'] else: _exe = '' _obj = '.o' _shobj = '.os' - _dll = '.so' lib_ = 'lib' + _lib = '.a' + dll_ = 'lib' + _dll = '.so' fortran_lib = gccFortranLibs() diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 504fadf..f48c587 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,16 @@ RELEASE 0.95 - XXX + From Chad Austin: + + - Replace print statements with calls to sys.stdout.write() so output + lines stay together when -j is used. + + - Add portability fixes for a number of tests. + + - Accomodate the fact that Cygwin's os.path.normcase() lies about + the underlying system being case-sensitive. + From Steven Knight: - Fix EnsureSConsVersion() so it checks against the SCons version, diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 13409aa..93580cc 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -33,6 +33,7 @@ import os import os.path import re import string +import sys import SCons.Errors import SCons.Util @@ -144,7 +145,7 @@ class ActionBase: def show(self, string): if print_actions: - print string + sys.stdout.write(string + '\n') def get_actions(self): return [self] diff --git a/src/engine/SCons/Tool/as.py b/src/engine/SCons/Tool/as.py index 0686489..14a2d43 100644 --- a/src/engine/SCons/Tool/as.py +++ b/src/engine/SCons/Tool/as.py @@ -43,10 +43,10 @@ assemblers = ['as'] ASSuffixes = ['.s', '.asm', '.ASM'] ASPPSuffixes = ['.spp', '.SPP'] -if os.path.normcase('.s') == os.path.normcase('.S'): - ASSuffixes.extend(['.S']) -else: +if SCons.Util.case_sensitive_suffixes('.s', '.S'): ASPPSuffixes.extend(['.S']) +else: + ASSuffixes.extend(['.S']) def generate(env): """Add Builders and construction variables for as to an Environment.""" diff --git a/src/engine/SCons/Tool/c++.py b/src/engine/SCons/Tool/c++.py index 9e8a9f9..2ed7d44 100644 --- a/src/engine/SCons/Tool/c++.py +++ b/src/engine/SCons/Tool/c++.py @@ -41,7 +41,7 @@ import SCons.Util compilers = ['CC', 'c++'] CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++'] -if os.path.normcase('.c') != os.path.normcase('.C'): +if SCons.Util.case_sensitive_suffixes('.c', '.C'): CXXSuffixes.append('.C') def iscplusplus(source): diff --git a/src/engine/SCons/Tool/cc.py b/src/engine/SCons/Tool/cc.py index ab51589..18b62d2 100644 --- a/src/engine/SCons/Tool/cc.py +++ b/src/engine/SCons/Tool/cc.py @@ -39,7 +39,7 @@ import SCons.Defaults import SCons.Util CSuffixes = ['.c'] -if os.path.normcase('.c') == os.path.normcase('.C'): +if not SCons.Util.case_sensitive_suffixes('.c', '.C'): CSuffixes.append('.C') def generate(env): diff --git a/src/engine/SCons/Tool/f77.py b/src/engine/SCons/Tool/f77.py index c99bd21..4267096 100644 --- a/src/engine/SCons/Tool/f77.py +++ b/src/engine/SCons/Tool/f77.py @@ -43,10 +43,10 @@ compilers = ['f77'] F77Suffixes = ['.f', '.for', '.FOR'] F77PPSuffixes = ['.fpp', '.FPP'] -if os.path.normcase('.f') == os.path.normcase('.F'): - F77Suffixes.append('.F') -else: +if SCons.Util.case_sensitive_suffixes('.f', '.F'): F77PPSuffixes.append('.F') +else: + F77Suffixes.append('.F') def generate(env): """Add Builders and construction variables for f77 to an Environment.""" diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py index a9f8ee1..acbe440 100644 --- a/src/engine/SCons/Tool/gcc.py +++ b/src/engine/SCons/Tool/gcc.py @@ -45,7 +45,7 @@ def generate(env): if env['PLATFORM'] == 'cygwin': env['SHCCFLAGS'] = '$CCFLAGS' else: - env['SHCCFLAGS'] = '$CCFLAGS -fPIC' + env['SHCCFLAGS'] = ['$CCFLAGS', '-fPIC'] def exists(env): return env.Detect(compilers) diff --git a/src/engine/SCons/Tool/masm.py b/src/engine/SCons/Tool/masm.py index 87570bd..92f4c35 100644 --- a/src/engine/SCons/Tool/masm.py +++ b/src/engine/SCons/Tool/masm.py @@ -40,10 +40,10 @@ import SCons.Tool ASSuffixes = ['.s', '.asm', '.ASM'] ASPPSuffixes = ['.spp', '.SPP'] -if os.path.normcase('.s') == os.path.normcase('.S'): - ASSuffixes.extend(['.S']) -else: +if SCons.Util.case_sensitive_suffixes('.s', '.S'): ASPPSuffixes.extend(['.S']) +else: + ASSuffixes.extend(['.S']) def generate(env): """Add Builders and construction variables for masm to an Environment.""" diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 4b15568..2a067b9 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -384,7 +384,7 @@ def generate(env): env['SHCCFLAGS'] = '$CCFLAGS' env['SHCCCOM'] = '$SHCC $SHCCFLAGS $CCCOMFLAGS' env['CXX'] = '$CC' - env['CXXFLAGS'] = '$CCFLAGS $( /TP $)' + env['CXXFLAGS'] = ['$CCFLAGS', '$(', '/TP', '$)'] env['CXXCOM'] = '$CXX $CXXFLAGS $CCCOMFLAGS' env['SHCXX'] = '$CXX' env['SHCXXFLAGS'] = '$CXXFLAGS' diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 68e8fda..949793a 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -297,7 +297,7 @@ class _GenerateV6DSP(_DSPGenerator): def Parse(self): try: - dspfile = file(self.dspfile,'r') + dspfile = open(self.dspfile,'r') except IOError: return # doesn't exist yet, so can't add anything to configs. @@ -345,7 +345,7 @@ class _GenerateV6DSP(_DSPGenerator): def Build(self): try: - self.file = file(self.dspfile,'w') + self.file = open(self.dspfile,'w') except IOError, detail: raise SCons.Errors.InternalError, 'Unable to open "' + self.dspfile + '" for writing:' + str(detail) else: @@ -458,7 +458,7 @@ class _GenerateV7DSP(_DSPGenerator): def Parse(self): try: - dspfile = file(self.dspfile,'r') + dspfile = open(self.dspfile,'r') except IOError: return # doesn't exist yet, so can't add anything to configs. @@ -505,7 +505,7 @@ class _GenerateV7DSP(_DSPGenerator): def Build(self): try: - self.file = file(self.dspfile,'w') + self.file = open(self.dspfile,'w') except IOError, detail: raise SCons.Errors.InternalError, 'Unable to open "' + self.dspfile + '" for writing:' + str(detail) else: @@ -555,7 +555,7 @@ class _GenerateV7DSW(_DSWGenerator): def Parse(self): try: - dswfile = file(self.dswfile,'r') + dswfile = open(self.dswfile,'r') except IOError: return # doesn't exist yet, so can't add anything to configs. @@ -617,7 +617,7 @@ class _GenerateV7DSW(_DSWGenerator): def Build(self): try: - self.file = file(self.dswfile,'w') + self.file = open(self.dswfile,'w') except IOError, detail: raise SCons.Errors.InternalError, 'Unable to open "' + self.dswfile + '" for writing:' + str(detail) else: @@ -661,7 +661,7 @@ class _GenerateV6DSW(_DSWGenerator): def Build(self): try: - self.file = file(self.dswfile,'w') + self.file = open(self.dswfile,'w') except IOError, detail: raise SCons.Errors.InternalError, 'Unable to open "' + self.dswfile + '" for writing:' + str(detail) else: @@ -946,7 +946,7 @@ def GenerateProject(target, source, env): if os.path.abspath(os.path.normcase(str(dspfile))) != \ os.path.abspath(os.path.normcase(str(builddspfile))): try: - bdsp = file(str(builddspfile), "w+") + bdsp = open(str(builddspfile), "w+") except IOError, detail: print 'Unable to open "' + str(dspfile) + '" for writing:',detail,'\n' raise @@ -954,7 +954,7 @@ def GenerateProject(target, source, env): bdsp.write("This is just a placeholder file.\nThe real project file is here:\n%s\n" % dspfile.get_abspath()) try: - bdsw = file(str(builddswfile), "w+") + bdsw = open(str(builddswfile), "w+") except IOError, detail: print 'Unable to open "' + str(dspfile) + '" for writing:',detail,'\n' raise diff --git a/src/engine/SCons/Tool/nasm.py b/src/engine/SCons/Tool/nasm.py index ed2feba..6a2fc36 100644 --- a/src/engine/SCons/Tool/nasm.py +++ b/src/engine/SCons/Tool/nasm.py @@ -40,10 +40,10 @@ import SCons.Tool ASSuffixes = ['.s', '.asm', '.ASM'] ASPPSuffixes = ['.spp', '.SPP'] -if os.path.normcase('.s') == os.path.normcase('.S'): - ASSuffixes.extend(['.S']) -else: +if SCons.Util.case_sensitive_suffixes('.s', '.S'): ASPPSuffixes.extend(['.S']) +else: + ASSuffixes.extend(['.S']) def generate(env): """Add Builders and construction variables for nasm to an Environment.""" diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index 12bf161..ffdff18 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -1,3 +1,4 @@ + """SCons.Tool.qt Tool-specific initialization for qt. @@ -33,6 +34,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import sys import os.path import re @@ -40,7 +42,10 @@ import SCons.Defaults import SCons.Tool import SCons.Util -header_extensions = (".h", ".H", ".hxx", ".hpp", ".hh") +header_extensions = [".h", ".hxx", ".hpp", ".hh"] + +if SCons.Util.case_sensitive_suffixes('.h', '.H'): + header_extensions.append('.H') class _Automoc: """ diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 41e3883..a558c2a 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -337,7 +337,7 @@ class DisplayEngine: self.__call__ = self.print_it def print_it(self, text): - print text + sys.stdout.write(text + '\n') def dont_print(self, text): pass @@ -972,3 +972,13 @@ class Selector(UserDict.UserDict): return self[None] except KeyError: return None + + +if sys.platform == 'cygwin': + # On Cygwin, os.path.normcase() lies, so just report back the + # fact that the underlying Win32 OS is case-insensitive. + def case_sensitive_suffixes(s1, s2): + return 0 +else: + def case_sensitive_suffixes(s1, s2): + return (os.path.normcase(s1) != os.path.normcase(s2)) diff --git a/test/Configure.py b/test/Configure.py index 2b134dc..9c5d14a 100644 --- a/test/Configure.py +++ b/test/Configure.py @@ -330,7 +330,7 @@ def CheckCustom(test): resOK = resOK and retActOK and int(outputActOK)==0 resFAIL = retCompileFAIL or retLinkFAIL or retRunFAIL or outputRunFAIL!="" resFAIL = resFAIL or retActFAIL or outputActFAIL!="" - test.Result( resOK and not resFAIL ) + test.Result( int(resOK and not resFAIL) ) return resOK and not resFAIL env = Environment() diff --git a/test/LIBPATH.py b/test/LIBPATH.py index 6e2a836..d691af2 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -31,14 +31,14 @@ import time _exe = TestSCons._exe _dll = TestSCons._dll -lib_ = TestSCons.lib_ +dll_ = TestSCons.dll_ test = TestSCons.TestSCons() test.subdir('lib1', 'lib2') prog1 = test.workpath('prog') + _exe -prog2 = test.workpath(lib_ + 'shlib') + _dll +prog2 = test.workpath(dll_ + 'shlib') + _dll test.write('SConstruct', """ env1 = Environment(LIBS = [ 'foo1' ], diff --git a/test/QT.py b/test/QT.py index ce6bff0..8b25553 100644 --- a/test/QT.py +++ b/test/QT.py @@ -34,8 +34,10 @@ import os.path python = TestSCons.python _exe = TestSCons._exe -_dll = TestSCons._dll lib_ = TestSCons.lib_ +_lib = TestSCons._lib +dll_ = TestSCons.dll_ +_dll = TestSCons._dll test = TestSCons.TestSCons() @@ -189,7 +191,7 @@ test.fail_test( not os.path.exists(test.workpath('work1', 'build', moc)) ) # 2. create .cpp, .h, moc_....cpp from .ui file -aaa_dll = lib_ + 'aaa' + _dll +aaa_dll = dll_ + 'aaa' + _dll moc = 'moc_aaa.cc' cpp = 'aaa.cc' h = 'aaa.h' @@ -241,7 +243,7 @@ test.fail_test(not os.path.exists(test.workpath('work2','build',moc)) or # 3. create a moc file from a cpp file -lib_aaa = lib_ + 'aaa.a' +lib_aaa = lib_ + 'aaa' + _lib moc = 'moc_aaa.cc' createSConstruct(test, ['work3', 'SConstruct']) diff --git a/test/SHLIBSUFFIX.py b/test/SHLIBSUFFIX.py index 4c2d7ac..aeea958 100644 --- a/test/SHLIBSUFFIX.py +++ b/test/SHLIBSUFFIX.py @@ -28,7 +28,7 @@ import os import sys import TestSCons -lib_ = TestSCons.lib_ +dll_ = TestSCons.dll_ test = TestSCons.TestSCons() @@ -47,6 +47,6 @@ foo(void) test.run(arguments = '.') -test.fail_test(not os.path.exists(test.workpath(lib_ + 'foo.shlib'))) +test.fail_test(not os.path.exists(test.workpath(dll_ + 'foo.shlib'))) test.pass_test() diff --git a/test/SHLINK.py b/test/SHLINK.py index 7f1c63d..ff24f0c 100644 --- a/test/SHLINK.py +++ b/test/SHLINK.py @@ -30,7 +30,7 @@ import sys import TestSCons python = TestSCons.python -lib_ = TestSCons.lib_ +dll_ = TestSCons.dll_ _shlib = TestSCons._dll test = TestSCons.TestSCons() @@ -73,11 +73,11 @@ test() } """) -test.run(arguments = lib_ + 'foo' + _shlib) +test.run(arguments = dll_ + 'foo' + _shlib) test.fail_test(os.path.exists(test.workpath('wrapper.out'))) -test.run(arguments = lib_ + 'bar' + _shlib) +test.run(arguments = dll_ + 'bar' + _shlib) test.fail_test(test.read('wrapper.out') != "wrapper.py\n") diff --git a/test/SHLINKFLAGS.py b/test/SHLINKFLAGS.py index 9a4a6cc..b7f18ca 100644 --- a/test/SHLINKFLAGS.py +++ b/test/SHLINKFLAGS.py @@ -30,7 +30,7 @@ import sys import TestSCons python = TestSCons.python -lib_ = TestSCons.lib_ +lib_ = TestSCons.dll_ _shlib = TestSCons._dll test = TestSCons.TestSCons() diff --git a/test/gnutools.py b/test/gnutools.py index ebc08c3..d5173ee 100644 --- a/test/gnutools.py +++ b/test/gnutools.py @@ -30,10 +30,11 @@ Testing the gnu tool chain, i.e. the tools 'gcc', 'g++' and 'gnulink'. import TestSCons import string +import sys python = TestSCons.python _exe = TestSCons._exe _dll = TestSCons._dll -lib_ = TestSCons.lib_ +dll_ = TestSCons.dll_ test = TestSCons.TestSCons() test.subdir('gnutools') @@ -124,19 +125,24 @@ def testObject(test, obj, command, flags): if not res: print "'"+obj+command+flags+"'"+"!='"+str(line1)+"'" return res +if sys.platform == 'cygwin': + fpic = '' +else: + fpic = '-fPIC ' + test.fail_test(not testObject(test, 'cfile1.o', 'gcc', '-c') or not testObject(test, 'cfile2.o', 'gcc', '-c') or not testObject(test, 'cppfile1.o', 'g++', '-c') or not testObject(test, 'cppfile2.o', 'g++', '-c') or - not testObject(test, 'cfile1.os', 'gcc', '-fPIC -c') or - not testObject(test, 'cfile2.os', 'gcc', '-fPIC -c') or - not testObject(test, 'cppfile1.os', 'g++', '-fPIC -c') or - not testObject(test, 'cppfile2.os', 'g++', '-fPIC -c') or + not testObject(test, 'cfile1.os', 'gcc', fpic + '-c') or + not testObject(test, 'cfile2.os', 'gcc', fpic + '-c') or + not testObject(test, 'cppfile1.os', 'g++', fpic + '-c') or + not testObject(test, 'cppfile2.os', 'g++', fpic + '-c') or not testObject(test, 'c-only' + _exe, 'gcc', '') or not testObject(test, 'cpp-only' + _exe, 'g++', '') or not testObject(test, 'c-and-cpp' + _exe, 'g++', '') or - not testObject(test, lib_ + 'c-only' + _dll, 'gcc', '-shared') or - not testObject(test, lib_ + 'cpp-only' + _dll, 'g++', '-shared') or - not testObject(test, lib_ + 'c-and-cpp' + _dll, 'g++', '-shared')) + not testObject(test, dll_ + 'c-only' + _dll, 'gcc', '-shared') or + not testObject(test, dll_ + 'cpp-only' + _dll, 'g++', '-shared') or + not testObject(test, dll_ + 'c-and-cpp' + _dll, 'g++', '-shared')) test.pass_test() -- cgit v0.12