Use sys.stdout.write() instead of print so line feeds in -j output will stay (more...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 10 Nov 2003 16:13:15 +0000 (16:13 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 10 Nov 2003 16:13:15 +0000 (16:13 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@844 fdb21ef1-2011-0410-befe-b5e4ea1792b1

21 files changed:
etc/TestSCons.py
src/CHANGES.txt
src/engine/SCons/Action.py
src/engine/SCons/Tool/as.py
src/engine/SCons/Tool/c++.py
src/engine/SCons/Tool/cc.py
src/engine/SCons/Tool/f77.py
src/engine/SCons/Tool/gcc.py
src/engine/SCons/Tool/masm.py
src/engine/SCons/Tool/msvc.py
src/engine/SCons/Tool/msvs.py
src/engine/SCons/Tool/nasm.py
src/engine/SCons/Tool/qt.py
src/engine/SCons/Util.py
test/Configure.py
test/LIBPATH.py
test/QT.py
test/SHLIBSUFFIX.py
test/SHLINK.py
test/SHLINKFLAGS.py
test/gnutools.py

index e0139f9471fec0fde4be848abd90d074f9bb37b7..1ce60e48b60173bdca52f3d053d11de6a5dc7fb8 100644 (file)
@@ -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()
 
 
index 504fadfdc1a32899d7ea15d28728f2856eb8eec6..f48c58767878107f36d72e74479a884e37152b34 100644 (file)
 
 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,
index 13409aa314152fae9f40a67b6ce70dc10a1ab987..93580cc14a1c1c030173558839620b8671931456 100644 (file)
@@ -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]
index 068648982487a9f0f379b45083d23bd5b45e26db..14a2d43d42256e68575e0e4b58783c0438b5d19c 100644 (file)
@@ -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."""
index 9e8a9f962eb362777d1e3580712526d02e421f06..2ed7d44f27c634c3380b790a8447ef2ff1f32788 100644 (file)
@@ -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):
index ab515892fedb490a73226ed030fbfcf2dc34f8e9..18b62d2b7c1900b9afab4a03c536cae30a500868 100644 (file)
@@ -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):
index c99bd219d0b6abe5a344a6873193597a46b0739c..42670962fc582d34d267f3dd542ce3b8bb7bc0d8 100644 (file)
@@ -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."""
index a9f8ee107dd2b79fc3b9ff8f2fe5d06d7a6202a9..acbe4406a8ccbb719070d517e02294867f184924 100644 (file)
@@ -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)
index 87570bd4e7044a5300cc6c020202d7f3813c816f..92f4c35a7c7b959632f06540be93be7c48e95403 100644 (file)
@@ -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."""
index 4b155686b03395023c2270ea806889a26c0d35ee..2a067b955b2a22f06e2928ae4a050d57875bc123 100644 (file)
@@ -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'
index 68e8fda7437e8b5832a4b0abcdbaf0e56cb9ca9d..949793a0a38453a6e0390ac93bb7120948ab3d2f 100644 (file)
@@ -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
index ed2feba9f44838cdaa1787defb56977a6942d60a..6a2fc365e9d3bff0411813824299c31884b6930b 100644 (file)
@@ -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."""
index 12bf1615493bc71f0a0a35e9d2ffb4832a4ab0b3..ffdff18c3037d7e39236946eb235cbe8c0c919a5 100644 (file)
@@ -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:
     """
index 41e3883ade1e28e45e3b3e1ccba9afa59c5535c5..a558c2a36ba8888a08507b889261a6590a6d4b59 100644 (file)
@@ -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))
index 2b134dc2a37cf3e608bd88d91a90df4e90b49562..9c5d14a376d71561125aca8c91f6ff7d89f03fd4 100644 (file)
@@ -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()
index 6e2a8368ce500d6395f1863160f77263ad2c6865..d691af20582bf699f38b70647387a60bd542803f 100644 (file)
@@ -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' ],
index ce6bff0c24c2eeb12fc67a16e6a4ce05f9551b36..8b255532e9107dddb723a82d24b353547b7a8dc9 100644 (file)
@@ -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'])
index 4c2d7ac6f097c74e1501cd66bfefe1c8531e62d6..aeea9589192acc42c13996864022d496216cc3a5 100644 (file)
@@ -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()
index 7f1c63dee04a707b8987299cdd9c4c40ee8b2685..ff24f0cdc5c8ebdef419d09f13f5ff5464dd261a 100644 (file)
@@ -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")
 
index 9a4a6ccb2632e6925de17a0639372162b9b7d659..b7f18ca9bf0ad67d14cbd1d150a550e98948ac61 100644 (file)
@@ -30,7 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-lib_   = TestSCons.lib_
+lib_   = TestSCons.dll_
 _shlib = TestSCons._dll
 
 test = TestSCons.TestSCons()
index ebc08c32bd8fc1652cbb0a6905f51c5b808a23bc..d5173ee29f143e7cfd04c7ec2ea74aff7b6dc265 100644 (file)
@@ -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()