Add .S, .spp and .SPP to the list of files scanned for C preprocessor dependencies...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 4 Oct 2003 13:37:54 +0000 (13:37 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 4 Oct 2003 13:37:54 +0000 (13:37 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@810 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Scanner/C.py
src/engine/SCons/Scanner/CTests.py
test/AS.py

index 6101191578d0e725f9936b537ee940fd7bca8457..432d6247aa9a33ec7002d144134393725d8487a3 100644 (file)
@@ -15,6 +15,8 @@ RELEASE X.XX - XXX
   - On POSIX, execute commands with the more modern os.spawnvpe()
     function, if it's available.
 
+  - Scan .S, .spp and .SPP files for C preprocessor dependencies.
+
   From Charles Crain:
 
   - Add support for a JARCHDIR variable to control changing to a
index c78fa4b598bbd32a9f6eaf887fcbc9e28487cbef..4fcf327cdfb5bf059431f2e1a63dda8485f8473d 100644 (file)
@@ -38,7 +38,8 @@ def CScan(fs = SCons.Node.FS.default_fs):
     cs = SCons.Scanner.ClassicCPP("CScan",
                                   [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
                                    ".h", ".H", ".hxx", ".hpp", ".hh",
-                                   ".F", ".fpp", ".FPP"],
+                                   ".F", ".fpp", ".FPP",
+                                   ".S", ".spp", ".SPP"],
                                   "CPPPATH",
                                   '^[ \t]*#[ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")',
                                   fs = fs)
index 3a5d3082e7985ba52dc8f47d9cf2c3ef31ba5678..253af88543e97a0a4a0c11c207d7fb255704f72d 100644 (file)
@@ -194,13 +194,13 @@ class DummyEnvironment:
     def __delitem__(self,key):
         del self.Dictionary()[key]
 
-global my_normpath
-my_normpath = os.path.normpath
 if os.path.normcase('foo') == os.path.normcase('FOO'):
-    global my_normpath
     my_normpath = os.path.normcase
+else:
+    my_normpath = os.path.normpath
 
 def deps_match(self, deps, headers):
+    global my_normpath
     scanned = map(my_normpath, map(str, deps))
     expect = map(my_normpath, headers)
     self.failUnless(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
@@ -393,7 +393,19 @@ class CScannerTestCase14(unittest.TestCase):
         deps = s(make_node('f5.c'), env, path)
         headers = ['f5a.h', 'f5b.h']
         deps_match(self, deps, map(test.workpath, headers))
-        
+
+class CScannerTestCase15(unittest.TestCase):
+    def runTest(self):
+        env = DummyEnvironment([])
+        s = SCons.Scanner.C.CScan()
+        suffixes = [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
+                    ".h", ".H", ".hxx", ".hpp", ".hh",
+                    ".F", ".fpp", ".FPP",
+                    ".S", ".spp", ".SPP"]
+        for suffix in suffixes:
+            assert suffix in s.skeys, "%s not in skeys" % suffix
+
+
 
 def suite():
     suite = unittest.TestSuite()
@@ -410,6 +422,7 @@ def suite():
     suite.addTest(CScannerTestCase12())
     suite.addTest(CScannerTestCase13())
     suite.addTest(CScannerTestCase14())
+    suite.addTest(CScannerTestCase15())
     return suite
 
 if __name__ == "__main__":
index 1fdb964acf1742a10c7c11d56fc3bd1e966ea65c..b841154047f3dd1a3b3180f22045c7ba07cbaef7 100644 (file)
@@ -172,19 +172,22 @@ x86 = (sys.platform == 'win32' or string.find(sys.platform, 'linux') != -1)
 
 if as and x86:
 
-    test.write("wrapper.py",
-"""import os
+    test.write("wrapper.py", """\
+import os
 import string
 import sys
-open('%s', 'wb').write("wrapper.py\\n")
-os.system(string.join(sys.argv[1:], " "))
+open('%s', 'wb').write("wrapper.py: %%s\\n" %% sys.argv[-1])
+cmd = string.join(sys.argv[1:])
+os.system(cmd)
 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
 
-    test.write('SConstruct', """
+    test.write('SConstruct', """\
 aaa = Environment()
 bbb = aaa.Copy(AS = r'%s wrapper.py ' + WhereIs('as'))
+ccc = aaa.Copy(CPPPATH=['.'])
 aaa.Program(target = 'aaa', source = ['aaa.s', 'aaa_main.c'])
 bbb.Program(target = 'bbb', source = ['bbb.s', 'bbb_main.c'])
+ccc.Program(target = 'ccc', source = ['ccc.S', 'ccc_main.c'])
 """ % python)
 
     test.write('aaa.s', 
@@ -197,8 +200,8 @@ name:
        .byte   0
 """)
 
-    test.write('bbb.s', 
-"""        .file   "bbb.s"
+    test.write('bbb.s', """\
+.file   "bbb.s"
 .data
 .align 4
 .globl name
@@ -207,6 +210,21 @@ name:
        .byte   0
 """)
 
+    test.write('ccc.h', """\
+#define STRING  "ccc.S"
+""")
+
+    test.write('ccc.S', """\
+#include <ccc.h>
+.file   STRING
+.data
+.align 4
+.globl name
+name:
+        .ascii STRING
+       .byte   0
+""")
+
     test.write('aaa_main.c', r"""
 extern char name[];
 
@@ -231,17 +249,44 @@ main(int argc, char *argv[])
 }
 """)
 
-    test.run(arguments = 'aaa' + _exe, stderr = None)
+    test.write('ccc_main.c', r"""
+extern char name[];
 
-    test.run(program = test.workpath('aaa'), stdout =  "aaa_main.c aaa.s\n")
+int
+main(int argc, char *argv[])
+{
+        argv[argc++] = "--";
+        printf("ccc_main.c %s\n", name);
+        exit (0);
+}
+""")
 
-    test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+    test.write('ddd_main.c', r"""
+extern char name[];
 
-    test.run(arguments = 'bbb' + _exe)
+int
+main(int argc, char *argv[])
+{
+        argv[argc++] = "--";
+        printf("ddd_main.c %s\n", name);
+        exit (0);
+}
+""")
+
+    test.run()
 
+    test.run(program = test.workpath('aaa'), stdout =  "aaa_main.c aaa.s\n")
     test.run(program = test.workpath('bbb'), stdout =  "bbb_main.c bbb.s\n")
+    test.run(program = test.workpath('ccc'), stdout =  "ccc_main.c ccc.S\n")
 
-    test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
+    test.fail_test(test.read('wrapper.out') != "wrapper.py: bbb.s\n")
+
+    test.write("ccc.h", """\
+#define STRING  "ccc.S 2"
+""")
+
+    test.run()
+    test.run(program = test.workpath('ccc'), stdout =  "ccc_main.c ccc.S 2\n")
 
     test.unlink('wrapper.out')