Miscellaneous fixes: portability and version fixes, missing , better CXXCOM tests...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 21 Nov 2004 00:41:12 +0000 (00:41 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 21 Nov 2004 00:41:12 +0000 (00:41 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1171 fdb21ef1-2011-0410-befe-b5e4ea1792b1

15 files changed:
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Tool/386asm.py
src/engine/SCons/Tool/intelc.py
src/engine/SCons/Tool/masm.py
src/engine/SCons/Tool/nasm.py
test/CXX/CXXCOM.py
test/CXX/CXXCOMSTR.py
test/CXX/SHCXXCOM.py
test/CXX/SHCXXCOMSTR.py
test/M4.py
test/builddir-reflect.py
test/builder-wrappers.py
test/import.py
test/midl.py
test/pre-post-actions.py

index e0956e10530343cb12fc8a3081db819a5fec8c71..d85be8bbb556ff1e1b83b1057c63591bd2c36233 100644 (file)
@@ -1155,7 +1155,7 @@ class NodeListTestCase(unittest.TestCase):
             assert s == "['n3', 'n2', 'n1']", s
 
         r = repr(nl)
-        r = re.sub('at (0x)?[0-9a-z]+', 'at 0x', repr(nl))
+        r = re.sub('at (0x)?[0-9A-Fa-f]+', 'at 0x', repr(nl))
         l = string.join(["<__main__.MyNode instance at 0x>"]*3, ", ")
         assert r == '[%s]' % l, r
 
index bb8b7800afee1b06449bd964a3b251698548046d..f2a221b455514d3c34c8b313229d0ddd91c822b9 100644 (file)
@@ -45,8 +45,9 @@ def generate(env):
 
     env['AS']        = '386asm'
     env['ASFLAGS']   = SCons.Util.CLVar('')
+    env['ASPPFLAGS'] = '$ASFLAGS'
     env['ASCOM']     = '$AS $ASFLAGS $SOURCES -o $TARGET'
-    env['ASPPCOM']   = '$CC $ASFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS $SOURCES -o $TARGET'
+    env['ASPPCOM']   = '$CC $ASPPFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS $SOURCES -o $TARGET'
 
     addPharLapPaths(env)
 
index f979700f82f9526ead020ad963d3ea8def848ec6..ded33e90ad8657c671258d05f1fd47347fb25c7c 100644 (file)
@@ -80,8 +80,11 @@ def get_all_compiler_versions():
     versions=[]
     if is_win32:
         keyname = 'Software\\Intel\\Compilers\\C++'
-        k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
-                                    keyname)
+        try:
+            k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
+                                        keyname)
+        except WindowsError:
+            return []
         i = 0
         versions = []
         try:
@@ -158,7 +161,7 @@ def generate(env, version=None, abi=None, topdir=None, verbose=1):
     if abi is None:
         abi = "ia32"                    # or ia64, I believe
 
-    if topdir is None:
+    if topdir is None and version:
         try:
             topdir = get_intel_compiler_top(version, abi)
         except (SCons.Util.RegError, SCons.Errors.InternalError):
index 6841815e16f853e51b59183d6a8d2e62d6e28b9e..a0c03d9cb5cd522cd74861c1ae94ef495d51439b 100644 (file)
@@ -62,8 +62,9 @@ def generate(env):
 
     env['AS']        = 'ml'
     env['ASFLAGS']   = SCons.Util.CLVar('/nologo')
+    env['ASPPFLAGS'] = '$ASFLAGS'
     env['ASCOM']     = '$AS $ASFLAGS /c /Fo$TARGET $SOURCES'
-    env['ASPPCOM']   = '$CC $ASFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c /Fo$TARGET $SOURCES'
+    env['ASPPCOM']   = '$CC $ASPPFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c /Fo$TARGET $SOURCES'
     env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
 
 def exists(env):
index 7dd3b63b8586d1d04409691a293fdc336b4f7912..6d0f078f5369e0d248a64f2f5b6746c83d5bd9ef 100644 (file)
@@ -58,8 +58,9 @@ def generate(env):
 
     env['AS']        = 'nasm'
     env['ASFLAGS']   = SCons.Util.CLVar('')
+    env['ASPPFLAGS'] = '$ASFLAGS'
     env['ASCOM']     = '$AS $ASFLAGS -o $TARGET $SOURCES'
-    env['ASPPCOM']   = '$CC $ASFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+    env['ASPPCOM']   = '$CC $ASPPFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
 
 def exists(env):
     return env.Detect('nasm')
index 4641473cf917b8a978201aa92edcd1c7b1b97fe9..c4c419d6846c3c324ef132007c0572c4f583de6b 100644 (file)
@@ -50,31 +50,36 @@ sys.exit(0)
 """)
 
 if os.path.normcase('.c') == os.path.normcase('.C'):
-    alt_cc_suffix = '.CC'
+    alt_cpp_suffix = '.cpp'
 else:
-    alt_cc_suffix = '.cc'
+    alt_cpp_suffix = '.C'
 
 test.write('SConstruct', """
 env = Environment(CXXCOM = r'%(python)s mycc.py $TARGET $SOURCE',
                   OBJSUFFIX='.obj')
-env.Object(target = 'test1', source = 'test1.cc')
-env.Object(target = 'test2', source = 'test2%(alt_cc_suffix)s')
+env.Object(target = 'test1', source = 'test1.cpp')
+env.Object(target = 'test2', source = 'test2.cc')
+env.Object(target = 'test3', source = 'test3.cxx')
+env.Object(target = 'test4', source = 'test4.c++')
+env.Object(target = 'test5', source = 'test5.C++')
+env.Object(target = 'test6', source = 'test6%(alt_cpp_suffix)s')
 """ % locals())
 
-test.write('test1.cc', """\
-test1.cc
-/*c++*/
-""")
-
-test.write('test2'+alt_cc_suffix, """\
-test2.CC
-/*c++*/
-""")
+test.write('test1.cpp', "test1.cpp\n/*c++*/\n")
+test.write('test2.cc',  "test2.cc\n/*c++*/\n")
+test.write('test3.cxx', "test3.cxx\n/*c++*/\n")
+test.write('test4.c++', "test4.c++\n/*c++*/\n")
+test.write('test5.C++', "test5.C++\n/*c++*/\n")
+test.write('test6'+alt_cpp_suffix, "test6.C\n/*c++*/\n")
 
 test.run()
 
-test.must_match('test1.obj', "test1.cc\n")
-test.must_match('test2.obj', "test2.CC\n")
+test.must_match('test1.obj', "test1.cpp\n")
+test.must_match('test2.obj', "test2.cc\n")
+test.must_match('test3.obj', "test3.cxx\n")
+test.must_match('test4.obj', "test4.c++\n")
+test.must_match('test5.obj', "test5.C++\n")
+test.must_match('test6.obj', "test6.C\n")
 
 
 
index 0a2dce6a54bc1bc88fa2172217741be4298b622f..82f7ace666f58082b067e7a1b5856ec3aac9be4c 100644 (file)
@@ -45,41 +45,50 @@ test.write('mycc.py', r"""
 import sys
 outfile = open(sys.argv[1], 'wb')
 infile = open(sys.argv[2], 'rb')
-for l in filter(lambda l: l[:6] != '/*cc*/', infile.readlines()):
+for l in filter(lambda l: l != '/*c++*/\n', infile.readlines()):
     outfile.write(l)
 sys.exit(0)
 """)
 
 if os.path.normcase('.c') == os.path.normcase('.C'):
-    alt_cc_suffix = '.CC'
+    alt_cpp_suffix = '.cpp'
 else:
-    alt_cc_suffix = '.cc'
+    alt_cpp_suffix = '.C'
 
 test.write('SConstruct', """
 env = Environment(CXXCOM = r'%(python)s mycc.py $TARGET $SOURCE',
                   CXXCOMSTR = 'Building $TARGET from $SOURCE',
                   OBJSUFFIX='.obj')
-env.Object(target = 'test1', source = 'test1.cc')
-env.Object(target = 'test2', source = 'test2%(alt_cc_suffix)s')
+env.Object(target = 'test1', source = 'test1.cpp')
+env.Object(target = 'test2', source = 'test2.cc')
+env.Object(target = 'test3', source = 'test3.cxx')
+env.Object(target = 'test4', source = 'test4.c++')
+env.Object(target = 'test5', source = 'test5.C++')
+env.Object(target = 'test6', source = 'test6%(alt_cpp_suffix)s')
 """ % locals())
 
-test.write('test1.cc', """\
-test1.cc
-/*cc*/
-""")
-
-test.write('test2'+alt_cc_suffix, """\
-test2.CC
-/*cc*/
-""")
+test.write('test1.cpp', "test1.cpp\n/*c++*/\n")
+test.write('test2.cc',  "test2.cc\n/*c++*/\n")
+test.write('test3.cxx', "test3.cxx\n/*c++*/\n")
+test.write('test4.c++', "test4.c++\n/*c++*/\n")
+test.write('test5.C++', "test5.C++\n/*c++*/\n")
+test.write('test6'+alt_cpp_suffix, "test6.C\n/*c++*/\n")
 
 test.run(stdout = test.wrap_stdout("""\
-Building test1.obj from test1.cc
-Building test2.obj from test2%(alt_cc_suffix)s
+Building test1.obj from test1.cpp
+Building test2.obj from test2.cc
+Building test3.obj from test3.cxx
+Building test4.obj from test4.c++
+Building test5.obj from test5.C++
+Building test6.obj from test6%(alt_cpp_suffix)s
 """ % locals()))
 
-test.must_match('test1.obj', "test1.cc\n")
-test.must_match('test2.obj', "test2.CC\n")
+test.must_match('test1.obj', "test1.cpp\n")
+test.must_match('test2.obj', "test2.cc\n")
+test.must_match('test3.obj', "test3.cxx\n")
+test.must_match('test4.obj', "test4.c++\n")
+test.must_match('test5.obj', "test5.C++\n")
+test.must_match('test6.obj', "test6.C\n")
 
 
 
index 1a38d71061048526fccffad734d3847e76d0f0a1..54ef0d5377ccf3e1a9e9789eefec34dfc28b2a6a 100644 (file)
@@ -50,32 +50,36 @@ sys.exit(0)
 """)
 
 if os.path.normcase('.c') == os.path.normcase('.C'):
-    alt_cc_suffix = '.CC'
+    alt_cpp_suffix = '.cpp'
 else:
-    alt_cc_suffix = '.cc'
+    alt_cpp_suffix = '.C'
 
 test.write('SConstruct', """
 env = Environment(SHCXXCOM = r'%(python)s mycc.py $TARGET $SOURCE',
                   SHOBJSUFFIX='.obj')
-env.SharedObject(target = 'test1', source = 'test1.cc')
-env.SharedObject(target = 'test2', source = 'test2%(alt_cc_suffix)s')
+env.SharedObject(target = 'test1', source = 'test1.cpp')
+env.SharedObject(target = 'test2', source = 'test2.cc')
+env.SharedObject(target = 'test3', source = 'test3.cxx')
+env.SharedObject(target = 'test4', source = 'test4.c++')
+env.SharedObject(target = 'test5', source = 'test5.C++')
+env.SharedObject(target = 'test6', source = 'test6%(alt_cpp_suffix)s')
 """ % locals())
 
-test.write('test1.cc', """\
-test1.cc
-/*c++*/
-""")
-
-test.write('test2'+alt_cc_suffix, """\
-test2.CC
-/*c++*/
-""")
+test.write('test1.cpp', "test1.cpp\n/*c++*/\n")
+test.write('test2.cc',  "test2.cc\n/*c++*/\n")
+test.write('test3.cxx', "test3.cxx\n/*c++*/\n")
+test.write('test4.c++', "test4.c++\n/*c++*/\n")
+test.write('test5.C++', "test5.C++\n/*c++*/\n")
+test.write('test6'+alt_cpp_suffix, "test6.C\n/*c++*/\n")
 
 test.run()
 
-test.must_match('test1.obj', "test1.cc\n")
-test.must_match('test2.obj', "test2.CC\n")
-
+test.must_match('test1.obj', "test1.cpp\n")
+test.must_match('test2.obj', "test2.cc\n")
+test.must_match('test3.obj', "test3.cxx\n")
+test.must_match('test4.obj', "test4.c++\n")
+test.must_match('test5.obj', "test5.C++\n")
+test.must_match('test6.obj', "test6.C\n")
 
 
 test.pass_test()
index 2c4339371cf2e98589e1d1dec492dbd3dadeae9b..ad3a90740f9d9f94100df3fb9bcc8dd708472e23 100644 (file)
@@ -45,41 +45,50 @@ test.write('mycc.py', r"""
 import sys
 outfile = open(sys.argv[1], 'wb')
 infile = open(sys.argv[2], 'rb')
-for l in filter(lambda l: l[:6] != '/*cc*/', infile.readlines()):
+for l in filter(lambda l: l != '/*c++*/\n', infile.readlines()):
     outfile.write(l)
 sys.exit(0)
 """)
 
 if os.path.normcase('.c') == os.path.normcase('.C'):
-    alt_cc_suffix = '.CC'
+    alt_cpp_suffix = '.cpp'
 else:
-    alt_cc_suffix = '.cc'
+    alt_cpp_suffix = '.C'
 
 test.write('SConstruct', """
 env = Environment(SHCXXCOM = r'%(python)s mycc.py $TARGET $SOURCE',
                   SHCXXCOMSTR = 'Building shared object $TARGET from $SOURCE',
                   SHOBJSUFFIX='.obj')
-env.SharedObject(target = 'test1', source = 'test1.cc')
-env.SharedObject(target = 'test2', source = 'test2%(alt_cc_suffix)s')
+env.SharedObject(target = 'test1', source = 'test1.cpp')
+env.SharedObject(target = 'test2', source = 'test2.cc')
+env.SharedObject(target = 'test3', source = 'test3.cxx')
+env.SharedObject(target = 'test4', source = 'test4.c++')
+env.SharedObject(target = 'test5', source = 'test5.C++')
+env.SharedObject(target = 'test6', source = 'test6%(alt_cpp_suffix)s')
 """ % locals())
 
-test.write('test1.cc', """\
-test1.cc
-/*cc*/
-""")
-
-test.write('test2'+alt_cc_suffix, """\
-test2.CC
-/*cc*/
-""")
+test.write('test1.cpp', "test1.cpp\n/*c++*/\n")
+test.write('test2.cc',  "test2.cc\n/*c++*/\n")
+test.write('test3.cxx', "test3.cxx\n/*c++*/\n")
+test.write('test4.c++', "test4.c++\n/*c++*/\n")
+test.write('test5.C++', "test5.C++\n/*c++*/\n")
+test.write('test6'+alt_cpp_suffix, "test6.C\n/*c++*/\n")
 
 test.run(stdout = test.wrap_stdout("""\
-Building shared object test1.obj from test1.cc
-Building shared object test2.obj from test2%(alt_cc_suffix)s
+Building shared object test1.obj from test1.cpp
+Building shared object test2.obj from test2.cc
+Building shared object test3.obj from test3.cxx
+Building shared object test4.obj from test4.c++
+Building shared object test5.obj from test5.C++
+Building shared object test6.obj from test6%(alt_cpp_suffix)s
 """ % locals()))
 
-test.must_match('test1.obj', "test1.cc\n")
-test.must_match('test2.obj', "test2.CC\n")
+test.must_match('test1.obj', "test1.cpp\n")
+test.must_match('test2.obj', "test2.cc\n")
+test.must_match('test3.obj', "test3.cxx\n")
+test.must_match('test4.obj', "test4.c++\n")
+test.must_match('test5.obj', "test5.C++\n")
+test.must_match('test6.obj', "test6.C\n")
 
 
 
index cc3554084f7f825f6b3fb06d19b810c39cf20ea2..bf56e7406d198be65d556218c0ee1c9351a74d5c 100644 (file)
@@ -78,12 +78,12 @@ os.system(string.join(sys.argv[1:], " "))
 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
 
     test.write('SConstruct', """
-foo = Environment(M4FLAGS='-DFFF=fff')
+foo = Environment(M4=r'%(m4)s', M4FLAGS='-DFFF=fff')
 m4 = foo.Dictionary('M4')
-bar = Environment(M4 = r'%s wrapper.py ' + m4, M4FLAGS='-DBBB=bbb')
+bar = Environment(M4 = r'%(python)s wrapper.py ' + m4, M4FLAGS='-DBBB=bbb')
 foo.M4(target = 'foo.x', source = 'foo.x.m4')
 bar.M4(target = 'bar', source = 'bar.m4')
-""" % python)
+""" % locals())
 
     test.write('foo.x.m4', "line 1\n"
                            "FFF\n"
index 0adc45e5a166c2b70750e615c186ff09b93e766b..7ce2a5b80e2ba846983f6dad3d1e613ae826c4e2 100644 (file)
@@ -33,10 +33,14 @@ in the build_dir as sources for that same build dir.
 Test based on bug #1055521 filed by Gary Oberbrunner.
 """
 
+import os.path
+import re
+
 import TestSCons
 
 test = TestSCons.TestSCons()
 python = TestSCons.python
+re_python = re.escape(python)
 
 test.write("mycc.py", """
 print 'Compile'
@@ -79,12 +83,16 @@ main() { printf(HI_STR);}
 cpppath = 'dir1/dir2'   # note, no leading '#'
 test.write('SConstruct', sconstruct % locals() )
 
+targets = re.escape(os.path.join('dir1', 'dir2'))
+INC_CNI = re.escape(os.path.join('INC_dir1', 'dir2', 'dir1', 'dir2_CNI'))
+
+# The .* after mycc\\.py below handles /nologo flags from Visual C/C++.
 test.run(arguments = '',
          stdout=test.wrap_stdout("""\
-scons: building associated BuildDir targets: dir1/dir2
-%(python)s mycc.py INC_dir1/dir2/dir1/dir2_CNI .+
+scons: building associated BuildDir targets: %(targets)s
+%(re_python)s mycc\\.py.* %(INC_CNI)s .+
 Compile
-%(python)s mylink.py .+
+%(re_python)s mylink\\.py .+
 Link
 """ % locals()),
          match=TestSCons.match_re,
@@ -103,12 +111,15 @@ test.must_not_exist('dir1')
 cpppath = '#dir1/dir2'   # note leading '#'
 test.write('SConstruct', sconstruct % locals() )
 
+INC_CNI = re.escape(os.path.join('INC_dir1', 'dir2_CNI'))
+
+# The .* after mycc\\.py below handles /nologo flags from Visual C/C++.
 test.run(arguments = '',
          stdout=test.wrap_stdout("""\
-scons: building associated BuildDir targets: dir1/dir2
-%(python)s mycc.py INC_dir1/dir2_CNI .+
+scons: building associated BuildDir targets: %(targets)s
+%(re_python)s mycc\\.py.* %(INC_CNI)s .+
 Compile
-%(python)s mylink.py .+
+%(re_python)s mylink\\.py .+
 Link
 """ % locals()),
          match=TestSCons.match_re,
index dbde30242e8aa81f1dbe86dbd2f37eecfbf35099..d463cce544be7d9e87d2be5092e68f8dac70db93 100644 (file)
@@ -37,9 +37,9 @@ test.write('SConstruct', """
 import os.path
 import string
 def cat(target, source, env):
-    fp = open(str(target[0]), 'w')
+    fp = open(str(target[0]), 'wb')
     for s in map(str, source):
-        fp.write(open(s).read())
+        fp.write(open(s, 'rb').read())
 Cat = Builder(action=cat)
 def Wrapper(env, target, source):
     if not target:
index cfe72e6a214a5dc3e6d59d3241c965ca4c97820d..a8a86bf7f79e435c53de6a92ecc32c5b0e6b0391 100644 (file)
@@ -134,11 +134,14 @@ tools = [
     'zip',
 ]
 
-error_output = {
-    'icl' : """
+intel_license_warning = """
 scons: warning: Intel license dir was not found.  Tried using the INTEL_LICENSE_FILE environment variable (), the registry () and the default path (C:\Program Files\Common Files\Intel\Licenses).  Using the default path as a last resort.
 File "SConstruct", line 1, in ?
-""",
+"""
+
+error_output = {
+    'icl' : intel_license_warning,
+    'intelc' : intel_license_warning,
     'qt' : """
 scons: warning: Could not detect qt, using empty QTDIR
 File "SConstruct", line 1, in ?
index cf800449c528ea933bd469ca12c77a02adb10a8f..a41ac0136b61b761db9b408ce91b45b5dda857a6 100644 (file)
@@ -43,7 +43,9 @@ test.write('SConstruct',"""
 import os.path
 import os
 
-env = Environment(CCFLAGS = ' -nologo ', CPPPATH='${TARGET.dir}')
+env = Environment(CCFLAGS = ' -nologo ',
+                  CPPPATH = '${TARGET.dir}',
+                  MSVS_USE_MFC_DIRS = 1)
 Export('env')
 
 BuildDir('build', 'src')
index db5d5befcaa7c4386a7e724ba59b3cdb573b3aa6..d0e8084a5902083e0c037790a4f3d2734cf906a4 100644 (file)
@@ -56,7 +56,7 @@ def before(env, target, source):
 
 def after(env, target, source):
     t = str(target[0])
-    a = "after_" + os.path.splitext(t)[0]
+    a = "after_" + t
     fin = open(t, "rb")
     fout = open(a, "wb")
     fout.write(fin.read())
@@ -111,7 +111,7 @@ test.run(program=after_bar_exe, stdout="bar.c\n")
 
 test.write(['work2', 'SConstruct'], """\
 def b(target, source, env):
-    open(str(target[0]), 'w').write(env['X'] + '\\n')
+    open(str(target[0]), 'wb').write(env['X'] + '\\n')
 env1 = Environment(X='111')
 env2 = Environment(X='222')
 B = Builder(action = b, env = env1, multi=1)