From 4e19786eafaae943526891a5e5507cdbfc642fd7 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 14 Jun 2002 06:00:43 +0000 Subject: [PATCH] Accomodate '-' (and other characters) in #include files in the C Scanner. git-svn-id: http://scons.tigris.org/svn/scons/trunk@389 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 +++ src/engine/SCons/Scanner/C.py | 2 +- src/engine/SCons/Scanner/CTests.py | 25 +++++++++++++++---------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 82627e3d..e65a5ce9 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -44,6 +44,9 @@ RELEASE 0.08 - - Add a dependency Scanner for native Fortran "include" statements, using a new "F77PATH" construction variable. + - Fix C #include scanning to detect file names with characters like + '-' in them. + From Jeff Petkau: - Fix --implicit-cache if the scanner returns an empty list. diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index 77b9525b..b54c8511 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -40,7 +40,7 @@ import SCons.Scanner import SCons.Util import SCons.Warnings -include_re = re.compile('^[ \t]*#[ \t]*include[ \t]+(<|")([\\w./\\\\]+)(>|")', re.M) +include_re = re.compile('^[ \t]*#[ \t]*include[ \t]+(<|")([^>"]+)(>|")', re.M) def CScan(fs = SCons.Node.FS.default_fs): """Return a prototype Scanner instance for scanning source files diff --git a/src/engine/SCons/Scanner/CTests.py b/src/engine/SCons/Scanner/CTests.py index cc9e1162..faa4cdd3 100644 --- a/src/engine/SCons/Scanner/CTests.py +++ b/src/engine/SCons/Scanner/CTests.py @@ -63,11 +63,11 @@ int main() test.write('f3.cpp',""" #include \t "f1.h" \t #include "f2.h" -# \t include "f3.h" +# \t include "f3-test.h" #include \t \t #include -# \t include +# \t include // #include "never.h" @@ -84,9 +84,9 @@ int main() test.subdir('d1', ['d1', 'd2']) -headers = ['f1.h','f2.h', 'f3.h', 'fi.h', 'fj.h', 'never.h', - 'd1/f1.h', 'd1/f2.h', 'd1/f3.h', 'd1/fi.h', 'd1/fj.h', - 'd1/d2/f1.h', 'd1/d2/f2.h', 'd1/d2/f3.h', +headers = ['f1.h','f2.h', 'f3-test.h', 'fi.h', 'fj.h', 'never.h', + 'd1/f1.h', 'd1/f2.h', 'd1/f3-test.h', 'd1/fi.h', 'd1/fj.h', + 'd1/d2/f1.h', 'd1/d2/f2.h', 'd1/d2/f3-test.h', 'd1/d2/f4.h', 'd1/d2/fi.h', 'd1/d2/fj.h'] for h in headers: @@ -96,7 +96,7 @@ test.write('f2.h',""" #include "fi.h" """) -test.write('f3.h',""" +test.write('f3-test.h',""" #include """) @@ -145,9 +145,14 @@ class DummyEnvironment: def __delitem__(self,key): del self.Dictionary()[key] +my_normpath = os.path.normpath +if os.path.normcase('foo') == os.path.normcase('FOO'): + global my_normpath + my_normpath = os.path.normcase + def deps_match(self, deps, headers): - scanned = map(os.path.normpath, map(str, deps)) - expect = map(os.path.normpath, headers) + scanned = map(my_normpath, map(str, deps)) + expect = map(my_normpath, headers) self.failUnless(scanned == expect, "expect %s != scanned %s" % (expect, scanned)) def make_node(filename, fs=SCons.Node.FS.default_fs): @@ -197,8 +202,8 @@ class CScannerTestCase5(unittest.TestCase): # scanned, essential for cooperation with BuildDir functionality. assert SCons.Node.FS.default_fs.File(test.workpath('f3.cpp')).created - headers = ['d1/f1.h', 'd1/f2.h', 'd1/f3.h', - 'f1.h', 'f2.h', 'f3.h', 'fi.h', 'fj.h'] + headers = ['d1/f1.h', 'd1/f2.h', 'd1/f3-test.h', + 'f1.h', 'f2.h', 'f3-test.h', 'fi.h', 'fj.h'] deps_match(self, deps, map(test.workpath, headers)) class CScannerTestCase6(unittest.TestCase): -- 2.26.2