Move the canned Scanner objects out of Defaults.py and document how to add Scanners...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 14 Feb 2005 00:40:40 +0000 (00:40 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 14 Feb 2005 00:40:40 +0000 (00:40 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1228 fdb21ef1-2011-0410-befe-b5e4ea1792b1

19 files changed:
doc/man/scons.1
src/CHANGES.txt
src/RELEASE.txt
src/engine/SCons/Defaults.py
src/engine/SCons/Scanner/C.py
src/engine/SCons/Scanner/CTests.py
src/engine/SCons/Scanner/D.py
src/engine/SCons/Scanner/Prog.py
src/engine/SCons/Scanner/ProgTests.py
src/engine/SCons/Script/__init__.py
src/engine/SCons/Tool/__init__.py
src/engine/SCons/Tool/f77.py
src/engine/SCons/Tool/f90.py
src/engine/SCons/Tool/f95.py
src/engine/SCons/Tool/fortran.py
src/engine/SCons/Tool/ifl.py
src/engine/SCons/Tool/ifort.py
src/engine/SCons/Tool/mingw.py
src/engine/SCons/Tool/msvc.py

index be4f94498afefcbfc8ee0f39584fba153e749eab..db1da8c5f4a170cf52da78b92930fbfcc16a2972 100644 (file)
@@ -1999,6 +1999,13 @@ env.SharedObject(target = 'eee.o', source = 'eee.cpp')
 env.SharedObject(target = 'fff.obj', source = 'fff.for')
 .EE
 
+Note that the source files will be scanned
+according to the suffix mappings in
+.B SourceFileScanner
+object.
+See the section "Scanner Objects,"
+below, for a more information.
+
 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 .IP StaticLibrary()
 .IP env.StaticLibrary()
@@ -2080,6 +2087,13 @@ env.StaticObject(target = 'bbb.o', source = 'bbb.c++')
 env.StaticObject(target = 'ccc.obj', source = 'ccc.f')
 .EE
 
+Note that the source files will be scanned
+according to the suffix mappings in
+.B SourceFileScanner
+object.
+See the section "Scanner Objects,"
+below, for a more information.
+
 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 .IP Tar()
 .IP env.Tar()
@@ -2169,9 +2183,21 @@ env.Zip('stuff', ['subdir1', 'subdir2'])
 env.Zip('stuff', 'another')
 .EE
 
+All
+targets of builder methods automatically depend on their sources.
+An explicit dependency can
+be specified using the 
+.B Depends 
+method of a construction environment (see below).
+
+In addition,
 .B scons
 automatically scans
-C source files, C++ source files,
+source files for various programming languages,
+so the dependencies do not need to be specified explicitly.
+By default, SCons can
+C source files,
+C++ source files,
 Fortran source files with
 .B .F
 (POSIX systems only),
@@ -2186,14 +2212,26 @@ and assembly language files with
 or
 .B .SPP
 files extensions
-for C preprocessor dependencies,
-so the dependencies do not need to be specified explicitly.
-In addition, all
-targets of builder methods automatically depend on their sources.
-An explicit dependency can
-be specified using the 
-.B Depends 
-method of a construction environment (see below).
+for C preprocessor dependencies.
+SCons also has default support
+for scanning D source files,
+You can also write your own Scanners
+to add support for additional source file types.
+These can be added to the default
+Scanner object used by
+the
+.BR Object ()
+.BR StaticObject ()
+and
+.BR SharedObject ()
+Builders by adding them
+to the
+.B SourceFileScanner
+object as follows:
+
+See the section "Scanner Objects,"
+below, for a more information about
+defining your own Scanner objects.
 
 .SS Methods and Functions to Do Things
 In addition to Builder methods,
@@ -9185,6 +9223,41 @@ and not (for example) also on the files
 specified by the #include lines
 in the file being scanned.
 
+Note that
+.B scons
+has a global
+.B SourceFileScanner
+object that is used by
+the
+.BR Object (),
+.BR SharedObject (),
+and 
+.BR StaticObject ()
+builders to decide
+which scanner should be used
+for different file extensions.
+You can using the
+.BR SourceFileScanner.add_scanner ()
+method to add your own Scanner object
+to the
+.B scons
+infrastructure
+that builds target programs or
+libraries from a list of
+source files of different types:
+
+.ES
+def xyz_scan(node, env, path):
+    contents = node.get_contents()
+    # Scan the contents and return the included files.
+
+XYZScanner = Scanner(xyz_scan)
+
+SourceFileScanner.add_scanner('.xyx', XYZScanner)
+
+env.Program('my_prog', ['file1.c', 'file2.f', 'file3.xyz'])
+.EE
+
 .SH SYSTEM-SPECIFIC BEHAVIOR
 SCons and its configuration files are very portable,
 due largely to its implementation in Python.
index 8f198602a79399a6a9028477799dfa9891d72efc..dbd068537ec3cf1817430a6b727699fd882612dc 100644 (file)
@@ -193,6 +193,11 @@ RELEASE 0.97 - XXX
   - When scanning, don't create Nodes for include files that don't
     actually exist on disk.
 
+  - Make supported global variables CScanner, DScanner, ProgramScanner and
+    SourceFileScanner.  Make SourceFileScanner.add_scanner() a supported
+    part of the public interface.  Keep the old SCons.Defaults.*Scan names
+    around for a while longer since some people were already using them.
+
   From Wayne Lee:
 
   - Avoid "maximum recursion limit" errors when removing $(-$) pairs
index 2ace3c5d4dfae1795241b2919e75653db4eaa811..2592f5cd47aa5a9f1c07f9ca00083f34c1b5d47c 100644 (file)
@@ -164,6 +164,27 @@ RELEASE 0.97 - XXX
       changed.  This change *only* affects any cases where you explicitly
       use UserList objects to initialize or append to a variable.
 
+  Please note the following planned, future changes:
+
+    - Several internal variable names in SCons.Defaults for various
+      pre-made default Scanner objects have been deprecated and will
+      be removed in a future revision.  In their place are several new
+      global variable names that are now part of the publicly-supported
+      interface:
+
+          NEW NAME              DEPRECATED NAME
+          --------              ----------------------------
+          CScanner              SCons.Defaults.CScan
+          DSCanner              SCons.Defaults.DScan
+          SourceFileScanner     SCons.Defaults.ObjSourceScan
+          ProgramScanner        SCons.Defaults.ProgScan
+
+      Of these, only ObjSourceScan was probably used at all, to add
+      new mappings of file suffixes to other scanners for use by the
+      Object() Builder.  This should now be done as follows:
+
+          SourceFileScanner.add_scanner('.x', XScanner)
+
   SCons is developed with an extensive regression test suite, and a
   rigorous development methodology for continually improving that suite.
   Because of this, SCons is of sufficient quality that you can use it
index 26e22361d7bf23e85ff93d238fa32b85184f7074..032a067dc3a74b88be9e21407eb461f182ffa96b 100644 (file)
@@ -48,9 +48,7 @@ import sys
 import SCons.Action
 import SCons.Builder
 import SCons.Environment
-import SCons.Scanner.C
-import SCons.Scanner.D
-import SCons.Scanner.Prog
+import SCons.Tool
 import SCons.Sig
 
 # A placeholder for a default Environment (for fetching source files
@@ -95,30 +93,14 @@ def SharedFlagChecker(source, target, env):
 
 SharedCheck = SCons.Action.Action(SharedFlagChecker, None)
 
-# Scanners and suffixes for common languages.
-ObjSourceScan = SCons.Scanner.Scanner({}, name='ObjSrcScanner')
-
-CScan = SCons.Scanner.C.CScan()
-
-CSuffixes = [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
-             ".h", ".H", ".hxx", ".hpp", ".hh",
-             ".F", ".fpp", ".FPP",
-             ".S", ".spp", ".SPP"]
-
-for suffix in CSuffixes:
-    ObjSourceScan.add_scanner(suffix, CScan)
-
-DScan = SCons.Scanner.D.DScan()
-
-DSuffixes = ['.d']
-
-for suffix in DSuffixes:
-    ObjSourceScan.add_scanner(suffix, DScan)
-
-IDLSuffixes = [".idl", ".IDL"]
-
-# cleanup
-del suffix
+# Some people were using these variable name before we made
+# SourceFileScanner part of the public interface.  Don't break their
+# SConscript files until we've given them some fair warning and a
+# transition period.
+CScan = SCons.Tool.CScanner
+DScan = SCons.Tool.DScanner
+ObjSourceScan = SCons.Tool.SourceFileScanner
+ProgScan = SCons.Tool.ProgramScanner
 
 # Actions for common languages.
 CAction = SCons.Action.Action("$CCCOM", "$CCCOMSTR")
@@ -138,8 +120,6 @@ ArAction = SCons.Action.Action("$ARCOM", "$ARCOMSTR")
 LexAction = SCons.Action.Action("$LEXCOM", "$LEXCOMSTR")
 YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR")
 
-ProgScan = SCons.Scanner.Prog.ProgScan()
-
 def DVI():
     """Common function to generate a DVI file Builder."""
     return SCons.Builder.Builder(action = {},
@@ -364,9 +344,9 @@ class Variable_Method_Caller:
 ConstructionEnvironment = {
     'BUILDERS'      : {},
     'SCANNERS'      : [],
-    'CPPSUFFIXES'   : CSuffixes,
-    'DSUFFIXES'     : DSuffixes,
-    'IDLSUFFIXES'   : IDLSuffixes,
+    'CPPSUFFIXES'   : SCons.Tool.CSuffixes,
+    'DSUFFIXES'     : SCons.Tool.DSuffixes,
+    'IDLSUFFIXES'   : SCons.Tool.IDLSuffixes,
     'PDFPREFIX'     : '',
     'PDFSUFFIX'     : '.pdf',
     'PSPREFIX'      : '',
index a5c2331ea554e72a022d1db2fba58cfa30bad26f..62a6842e710f4120ad57f1cf25b5f7fb6e546e8c 100644 (file)
@@ -32,10 +32,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import SCons.Node.FS
 import SCons.Scanner
 
-def CScan(fs = SCons.Node.FS.default_fs):
+def CScanner(fs = SCons.Node.FS.default_fs):
     """Return a prototype Scanner instance for scanning source files
     that use the C pre-processor"""
-    cs = SCons.Scanner.ClassicCPP("CScan",
+    cs = SCons.Scanner.ClassicCPP("CScanner",
                                   "$CPPSUFFIXES",
                                   "CPPPATH",
                                   '^[ \t]*#[ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")',
index 4c21fe9e0db72ec632b2228f2a2d08c4eca1b1a9..fd17ee1e755c8604ebcc0de7e75c1d7a18629371 100644 (file)
@@ -215,7 +215,7 @@ def make_node(filename, fs=SCons.Node.FS.default_fs):
 class CScannerTestCase1(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(CPPPATH=[])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path = s.path(env)
         deps = s(make_node('f1.cpp'), env, path)
         headers = ['f1.h', 'f2.h']
@@ -224,7 +224,7 @@ class CScannerTestCase1(unittest.TestCase):
 class CScannerTestCase2(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(CPPPATH=[test.workpath("d1")])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path = s.path(env)
         deps = s(make_node('f1.cpp'), env, path)
         headers = ['f1.h', 'd1/f2.h']
@@ -233,7 +233,7 @@ class CScannerTestCase2(unittest.TestCase):
 class CScannerTestCase3(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(CPPPATH=[test.workpath("d1")])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path = s.path(env)
         deps = s(make_node('f2.cpp'), env, path)
         headers = ['d1/f1.h', 'f1.h', 'd1/d2/f1.h']
@@ -242,7 +242,7 @@ class CScannerTestCase3(unittest.TestCase):
 class CScannerTestCase4(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(CPPPATH=[test.workpath("d1"), test.workpath("d1/d2")])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path = s.path(env)
         deps = s(make_node('f2.cpp'), env, path)
         headers =  ['d1/f1.h', 'f1.h', 'd1/d2/f1.h', 'd1/d2/f4.h']
@@ -251,7 +251,7 @@ class CScannerTestCase4(unittest.TestCase):
 class CScannerTestCase5(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(CPPPATH=[])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path = s.path(env)
 
         n = make_node('f3.cpp')
@@ -275,7 +275,7 @@ class CScannerTestCase6(unittest.TestCase):
     def runTest(self):
         env1 = DummyEnvironment(CPPPATH=[test.workpath("d1")])
         env2 = DummyEnvironment(CPPPATH=[test.workpath("d1/d2")])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path1 = s.path(env1)
         path2 = s.path(env2)
         deps1 = s(make_node('f1.cpp'), env1, path1)
@@ -289,7 +289,7 @@ class CScannerTestCase8(unittest.TestCase):
     def runTest(self):
         fs = SCons.Node.FS.FS(test.workpath(''))
         env = DummyEnvironment(CPPPATH=["include"])
-        s = SCons.Scanner.C.CScan(fs = fs)
+        s = SCons.Scanner.C.CScanner(fs = fs)
         path = s.path(env)
         deps1 = s(fs.File('fa.cpp'), env, path)
         fs.chdir(fs.Dir('subdir'))
@@ -315,7 +315,7 @@ class CScannerTestCase9(unittest.TestCase):
         test.write('fa.h','\n')
         fs = SCons.Node.FS.FS(test.workpath(''))
         env = DummyEnvironment(CPPPATH=[])
-        s = SCons.Scanner.C.CScan(fs=fs)
+        s = SCons.Scanner.C.CScanner(fs=fs)
         path = s.path(env)
         deps = s(fs.File('fa.cpp'), env, path)
 
@@ -330,7 +330,7 @@ class CScannerTestCase10(unittest.TestCase):
         fs = SCons.Node.FS.FS(test.workpath(''))
         fs.chdir(fs.Dir('include'))
         env = DummyEnvironment(CPPPATH=[])
-        s = SCons.Scanner.C.CScan(fs=fs)
+        s = SCons.Scanner.C.CScanner(fs=fs)
         path = s.path(env)
         test.write('include/fa.cpp', test.read('fa.cpp'))
         fs.chdir(fs.Dir('..'))
@@ -349,7 +349,7 @@ class CScannerTestCase11(unittest.TestCase):
         f1=fs.File('include2/jjj.h')
         f1.builder=1
         env = DummyEnvironment(CPPPATH=['include', 'include2'])
-        s = SCons.Scanner.C.CScan(fs=fs)
+        s = SCons.Scanner.C.CScanner(fs=fs)
         path = s.path(env)
         deps = s(fs.File('src/fff.c'), env, path)
         deps_match(self, deps, [ test.workpath('repository/include/iii.h'), 'include2/jjj.h' ])
@@ -363,7 +363,7 @@ class CScannerTestCase12(unittest.TestCase):
         fs.BuildDir('build2', 'src', 0)
         fs.Repository(test.workpath('repository'))
         env = DummyEnvironment(CPPPATH=[])
-        s = SCons.Scanner.C.CScan(fs = fs)
+        s = SCons.Scanner.C.CScanner(fs = fs)
         path = s.path(env)
         deps1 = s(fs.File('build1/aaa.c'), env, path)
         deps_match(self, deps1, [ 'build1/bbb.h' ])
@@ -381,7 +381,7 @@ class CScannerTestCase13(unittest.TestCase):
             def subst(self, arg, test=test):
                 return test.workpath("d1")
         env = SubstEnvironment(CPPPATH=["blah"])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path = s.path(env)
         deps = s(make_node('f1.cpp'), env, path)
         headers = ['f1.h', 'd1/f2.h']
@@ -390,7 +390,7 @@ class CScannerTestCase13(unittest.TestCase):
 class CScannerTestCase14(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(CPPPATH=[])
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         path = s.path(env)
         deps = s(make_node('f5.c'), env, path)
         headers = ['f5a.h', 'f5b.h']
@@ -403,7 +403,7 @@ class CScannerTestCase15(unittest.TestCase):
                     ".F", ".fpp", ".FPP",
                     ".S", ".spp", ".SPP"]
         env = DummyEnvironment(CPPSUFFIXES = suffixes)
-        s = SCons.Scanner.C.CScan()
+        s = SCons.Scanner.C.CScanner()
         for suffix in suffixes:
             assert suffix in s.get_skeys(env), "%s not in skeys" % suffix
 
index fba973f10df26eb05b1ed8eabf7efc4568100002..b80912d19fa327a69ee5871de64d9778b21b5202 100644 (file)
@@ -36,16 +36,16 @@ import string
 
 import SCons.Scanner
 
-def DScan(fs = SCons.Node.FS.default_fs):
+def DScanner(fs = SCons.Node.FS.default_fs):
     """Return a prototype Scanner instance for scanning D source files"""
-    ds = DScanner(name = "DScan",
-                  suffixes = '$DSUFFIXES',
-                  path_variable = 'DPATH',
-                  regex = 'import\s+([^\;]*)\;',
-                  fs = fs)
+    ds = D(name = "DScanner",
+           suffixes = '$DSUFFIXES',
+           path_variable = 'DPATH',
+           regex = 'import\s+([^\;]*)\;',
+           fs = fs)
     return ds
 
-class DScanner(SCons.Scanner.Classic):
+class D(SCons.Scanner.Classic):
     def find_include(self, include, source_dir, path):
         if callable(path): path=path()
         # translate dots (package separators) to slashes
index d9b57b90b31005713e632cb586288c62ee2b72a6..f2f3bbf63863e3999a933d31b12195e5c17933ae 100644 (file)
@@ -33,11 +33,11 @@ import SCons.Util
 # global, set by --debug=findlibs
 print_find_libs = None
 
-def ProgScan(fs = SCons.Node.FS.default_fs, **kw):
+def ProgramScanner(fs = SCons.Node.FS.default_fs, **kw):
     """Return a prototype Scanner instance for scanning executable
     files for static-lib dependencies"""
     kw['path_function'] = SCons.Scanner.FindPathDirs('LIBPATH', fs)
-    ps = apply(SCons.Scanner.Base, [scan, "ProgScan"], kw)
+    ps = apply(SCons.Scanner.Base, [scan, "ProgramScanner"], kw)
     return ps
 
 def scan(node, env, libpath = (), fs = SCons.Node.FS.default_fs):
index c31b392231a52af01f50743aa5a9d18cbe5b766c..ec25f244f5e9c90ea1bd61ea2c5912ce23f7f065 100644 (file)
@@ -101,18 +101,18 @@ def deps_match(deps, libs):
 
 # define some tests:
 
-class ProgScanTestCase1(unittest.TestCase):
+class ProgramScannerTestCase1(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(LIBPATH=[ test.workpath("") ],
                                LIBS=[ 'l1', 'l2', 'l3' ])
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['l1.lib']), map(str, deps)
 
         env = DummyEnvironment(LIBPATH=[ test.workpath("") ],
                                LIBS='l1')
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['l1.lib']), map(str, deps)
@@ -120,7 +120,7 @@ class ProgScanTestCase1(unittest.TestCase):
         f1 = SCons.Node.FS.default_fs.File(test.workpath('f1'))
         env = DummyEnvironment(LIBPATH=[ test.workpath("") ],
                                LIBS=[f1])
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps[0] is f1, deps
@@ -128,33 +128,33 @@ class ProgScanTestCase1(unittest.TestCase):
         f2 = SCons.Node.FS.default_fs.File(test.workpath('f1'))
         env = DummyEnvironment(LIBPATH=[ test.workpath("") ],
                                LIBS=f2)
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps[0] is f2, deps
 
 
-class ProgScanTestCase2(unittest.TestCase):
+class ProgramScannerTestCase2(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(LIBPATH=map(test.workpath,
                                            ["", "d1", "d1/d2" ]),
                                LIBS=[ 'l1', 'l2', 'l3' ])
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['l1.lib', 'd1/l2.lib', 'd1/d2/l3.lib' ]), map(str, deps)
 
-class ProgScanTestCase3(unittest.TestCase):
+class ProgramScannerTestCase3(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(LIBPATH=[test.workpath("d1/d2"),
                                         test.workpath("d1")],
                                LIBS=string.split('l2 l3'))
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps)
 
-class ProgScanTestCase5(unittest.TestCase):
+class ProgramScannerTestCase5(unittest.TestCase):
     def runTest(self):
         class SubstEnvironment(DummyEnvironment):
             def subst(self, arg, path=test.workpath("d1")):
@@ -164,23 +164,23 @@ class ProgScanTestCase5(unittest.TestCase):
                     return arg
         env = SubstEnvironment(LIBPATH=[ "blah" ],
                                LIBS=string.split('l2 l3'))
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, [ 'd1/l2.lib' ]), map(str, deps)
 
-class ProgScanTestCase6(unittest.TestCase):
+class ProgramScannerTestCase6(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
                                LIBS=['foo', 'sub/libbar', 'xyz.other'],
                                LIBPREFIXES=['lib'],
                                LIBSUFFIXES=['.a'])
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), map(str, deps)
 
-class ProgScanTestCase7(unittest.TestCase):
+class ProgramScannerTestCase7(unittest.TestCase):
     def runTest(self):
         env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
                                LIBS=['foo', '$LIBBAR', '$XYZ'],
@@ -188,12 +188,12 @@ class ProgScanTestCase7(unittest.TestCase):
                                LIBSUFFIXES=['.a'],
                                LIBBAR='sub/libbar',
                                XYZ='xyz.other')
-        s = SCons.Scanner.Prog.ProgScan()
+        s = SCons.Scanner.Prog.ProgramScanner()
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), map(str, deps)
 
-class ProgScanTestCase8(unittest.TestCase):
+class ProgramScannerTestCase8(unittest.TestCase):
     def runTest(self):
         
         n1 = DummyNode('n1')
@@ -201,7 +201,7 @@ class ProgScanTestCase8(unittest.TestCase):
                                LIBS=[n1],
                                LIBPREFIXES=['p1-', 'p2-'],
                                LIBSUFFIXES=['.1', '2'])
-        s = SCons.Scanner.Prog.ProgScan(node_class = DummyNode)
+        s = SCons.Scanner.Prog.ProgramScanner(node_class = DummyNode)
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps == [n1], deps
@@ -211,32 +211,32 @@ class ProgScanTestCase8(unittest.TestCase):
                                LIBS=[n1, [n2]],
                                LIBPREFIXES=['p1-', 'p2-'],
                                LIBSUFFIXES=['.1', '2'])
-        s = SCons.Scanner.Prog.ProgScan(node_class = DummyNode)
+        s = SCons.Scanner.Prog.ProgramScanner(node_class = DummyNode)
         path = s.path(env)
         deps = s(DummyNode('dummy'), env, path)
         assert deps == [n1, n2], deps
 
 def suite():
     suite = unittest.TestSuite()
-    suite.addTest(ProgScanTestCase1())
-    suite.addTest(ProgScanTestCase2())
-    suite.addTest(ProgScanTestCase3())
-    suite.addTest(ProgScanTestCase5())
-    suite.addTest(ProgScanTestCase6())
-    suite.addTest(ProgScanTestCase7())
-    suite.addTest(ProgScanTestCase8())
+    suite.addTest(ProgramScannerTestCase1())
+    suite.addTest(ProgramScannerTestCase2())
+    suite.addTest(ProgramScannerTestCase3())
+    suite.addTest(ProgramScannerTestCase5())
+    suite.addTest(ProgramScannerTestCase6())
+    suite.addTest(ProgramScannerTestCase7())
+    suite.addTest(ProgramScannerTestCase8())
     if hasattr(types, 'UnicodeType'):
         code = """if 1:
-            class ProgScanTestCase4(unittest.TestCase):
+            class ProgramScannerTestCase4(unittest.TestCase):
                 def runTest(self):
                     env = DummyEnvironment(LIBPATH=[test.workpath("d1/d2"),
                                                     test.workpath("d1")],
                                            LIBS=string.split(u'l2 l3'))
-                    s = SCons.Scanner.Prog.ProgScan()
+                    s = SCons.Scanner.Prog.ProgramScanner()
                     path = s.path(env)
                     deps = s(DummyNode('dummy'), env, path)
                     assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps)
-            suite.addTest(ProgScanTestCase4())
+            suite.addTest(ProgramScannerTestCase4())
             \n"""
         exec code
     return suite
index 7368c8c85420c67fafb7f7387e192dc910dbc295..6e27ab43379e7b5ab9e6871de43a9def90d7f58a 100644 (file)
@@ -105,6 +105,12 @@ Mkdir                   = SCons.Defaults.Mkdir
 Move                    = SCons.Defaults.Move
 Touch                   = SCons.Defaults.Touch
 
+# Pre-made, public scanners.
+CScanner                = SCons.Tool.CScanner
+DScanner                = SCons.Tool.DScanner
+ProgramScanner          = SCons.Tool.ProgramScanner
+SourceFileScanner       = SCons.Tool.SourceFileScanner
+
 # Functions we might still convert to Environment methods.
 CScan                   = SCons.Defaults.CScan
 DefaultEnvironment      = SCons.Defaults.DefaultEnvironment
index 1cfe6eff5b08c55720b0b2bbf44f2a53690080ae..7ef2ea0c8513e872a316b50b3be5936d98d1f375 100644 (file)
@@ -42,7 +42,30 @@ import imp
 import sys
 
 import SCons.Errors
-import SCons.Defaults
+import SCons.Scanner
+import SCons.Scanner.C
+import SCons.Scanner.D
+import SCons.Scanner.Prog
+
+CScanner = SCons.Scanner.C.CScanner()
+DScanner = SCons.Scanner.D.DScanner()
+ProgramScanner = SCons.Scanner.Prog.ProgramScanner()
+SourceFileScanner = SCons.Scanner.Scanner({}, name='SourceFileScanner')
+
+CSuffixes = [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
+             ".h", ".H", ".hxx", ".hpp", ".hh",
+             ".F", ".fpp", ".FPP",
+             ".S", ".spp", ".SPP"]
+
+DSuffixes = ['.d']
+
+IDLSuffixes = [".idl", ".IDL"]
+
+for suffix in CSuffixes:
+    SourceFileScanner.add_scanner(suffix, CScanner)
+
+for suffix in DSuffixes:
+    SourceFileScanner.add_scanner(suffix, DScanner)
 
 class ToolSpec:
     def __init__(self, name, **kw):
@@ -116,13 +139,14 @@ def createProgBuilder(env):
     try:
         program = env['BUILDERS']['Program']
     except KeyError:
+        import SCons.Defaults
         program = SCons.Builder.Builder(action = SCons.Defaults.LinkAction,
                                         emitter = '$PROGEMITTER',
                                         prefix = '$PROGPREFIX',
                                         suffix = '$PROGSUFFIX',
                                         src_suffix = '$OBJSUFFIX',
                                         src_builder = 'Object',
-                                        target_scanner = SCons.Defaults.ProgScan)
+                                        target_scanner = ProgramScanner)
         env['BUILDERS']['Program'] = program
 
     return program
@@ -137,6 +161,7 @@ def createStaticLibBuilder(env):
     try:
         static_lib = env['BUILDERS']['StaticLibrary']
     except KeyError:
+        import SCons.Defaults
         static_lib = SCons.Builder.Builder(action = SCons.Defaults.ArAction,
                                            emitter = '$LIBEMITTER',
                                            prefix = '$LIBPREFIX',
@@ -158,13 +183,14 @@ def createSharedLibBuilder(env):
     try:
         shared_lib = env['BUILDERS']['SharedLibrary']
     except KeyError:
+        import SCons.Defaults
         action_list = [ SCons.Defaults.SharedCheck,
                         SCons.Defaults.ShLinkAction ]
         shared_lib = SCons.Builder.Builder(action = action_list,
                                            emitter = "$SHLIBEMITTER",
                                            prefix = '$SHLIBPREFIX',
                                            suffix = '$SHLIBSUFFIX',
-                                           target_scanner = SCons.Defaults.ProgScan,
+                                           target_scanner = ProgramScanner,
                                            src_suffix = '$SHOBJSUFFIX',
                                            src_builder = 'SharedObject')
         env['BUILDERS']['SharedLibrary'] = shared_lib
@@ -181,13 +207,14 @@ def createLoadableModuleBuilder(env):
     try:
         ld_module = env['BUILDERS']['LoadableModule']
     except KeyError:
+        import SCons.Defaults
         action_list = [ SCons.Defaults.SharedCheck,
                         SCons.Defaults.LdModuleLinkAction ]
         ld_module = SCons.Builder.Builder(action = action_list,
                                           emitter = "$SHLIBEMITTER",
                                           prefix = '$LDMODULEPREFIX',
                                           suffix = '$LDMODULESUFFIX',
-                                          target_scanner = SCons.Defaults.ProgScan,
+                                          target_scanner = ProgramScanner,
                                           src_suffix = '$SHOBJSUFFIX',
                                           src_builder = 'SharedObject')
         env['BUILDERS']['LoadableModule'] = ld_module
@@ -207,6 +234,7 @@ def createObjBuilders(env):
     The return is a 2-tuple of (StaticObject, SharedObject)
     """
 
+
     try:
         static_obj = env['BUILDERS']['StaticObject']
     except KeyError:
@@ -215,7 +243,8 @@ def createObjBuilders(env):
                                            prefix = '$OBJPREFIX',
                                            suffix = '$OBJSUFFIX',
                                            src_builder = ['CFile', 'CXXFile'],
-                                           source_scanner = SCons.Defaults.ObjSourceScan, single_source=1)
+                                           source_scanner = SourceFileScanner,
+                                           single_source = 1)
         env['BUILDERS']['StaticObject'] = static_obj
         env['BUILDERS']['Object'] = static_obj
 
@@ -227,7 +256,8 @@ def createObjBuilders(env):
                                            prefix = '$SHOBJPREFIX',
                                            suffix = '$SHOBJSUFFIX',
                                            src_builder = ['CFile', 'CXXFile'],
-                                           source_scanner = SCons.Defaults.ObjSourceScan, single_source=1)
+                                           source_scanner = SourceFileScanner,
+                                           single_source = 1)
         env['BUILDERS']['SharedObject'] = shared_obj
 
     return (static_obj, shared_obj)
index 5650e97b62e3787b149e1c821da12d52e9196eac..d5acbb3cb947c0a98b63486da3e856c7473cc4a2 100644 (file)
@@ -53,7 +53,7 @@ else:
 F77Scan = SCons.Scanner.Fortran.FortranScan("F77PATH")
 
 for suffix in F77Suffixes + F77PPSuffixes:
-    SCons.Defaults.ObjSourceScan.add_scanner(suffix, F77Scan)
+    SCons.Tool.SourceFileScanner.add_scanner(suffix, F77Scan)
 
 #
 fVLG = fortran.VariableListGenerator
index 9c3b0a3c105824cf0417add9daf8fa5103b3827a..447497f6098bdf6311d8b9f75c5510a64a73b13e 100644 (file)
@@ -53,7 +53,7 @@ else:
 F90Scan = SCons.Scanner.Fortran.FortranScan("F90PATH")
 
 for suffix in F90Suffixes + F90PPSuffixes:
-    SCons.Defaults.ObjSourceScan.add_scanner(suffix, F90Scan)
+    SCons.Tool.SourceFileScanner.add_scanner(suffix, F90Scan)
 
 #
 fVLG = fortran.VariableListGenerator
index 2d5a0b5ea6b8b2d75ee4e4a09cf554a73164dea2..bc3ece30a501c2713a3593e0ba2894182b1bb8f0 100644 (file)
@@ -52,7 +52,7 @@ else:
 F95Scan = SCons.Scanner.Fortran.FortranScan("F95PATH")
 
 for suffix in F95Suffixes + F95PPSuffixes:
-    SCons.Defaults.ObjSourceScan.add_scanner(suffix, F95Scan)
+    SCons.Tool.SourceFileScanner.add_scanner(suffix, F95Scan)
 
 #
 fVLG = fortran.VariableListGenerator
index 770a45eb6227c56792ce93e2250b1ab3bd986100..180c811196179f5b2df6f82636d0ac9db2717b37 100644 (file)
@@ -62,7 +62,7 @@ else:
 FortranScan = SCons.Scanner.Fortran.FortranScan("FORTRANPATH")
 
 for suffix in FortranSuffixes + FortranPPSuffixes:
-    SCons.Defaults.ObjSourceScan.add_scanner(suffix, FortranScan)
+    SCons.Tool.SourceFileScanner.add_scanner(suffix, FortranScan)
 
 #
 def _fortranEmitter(target, source, env):
index 923e5ef3ccff5ef24ae82bb92a9ad9ee0380a5e0..b8b20124b153d620368a2604d7ec4c06e6f72005 100644 (file)
@@ -39,7 +39,7 @@ import fortran
 
 def generate(env):
     """Add Builders and construction variables for ifl to an Environment."""
-    SCons.Defaults.ObjSourceScan.add_scanner('.i90', fortran.FortranScan)
+    SCons.Tool.SourceFileScanner.add_scanner('.i90', fortran.FortranScan)
     fortran.FortranSuffixes.extend(['.i90'])
     fortran.generate(env)
 
index 519f266ca62e41de2d3d23552c248263be5f4854..181078afa8fda7cab3b7d52fb282da6b93d36c92 100644 (file)
@@ -42,8 +42,8 @@ def generate(env):
     """Add Builders and construction variables for ifort to an Environment."""
     # ifort supports Fortran 90 and Fortran 95
     # Additionally, ifort recognizes more file extensions.
-    SCons.Defaults.ObjSourceScan.add_scanner('.i', fortran.FortranScan)
-    SCons.Defaults.ObjSourceScan.add_scanner('.i90', fortran.FortranScan)
+    SCons.Tool.SourceFileScanner.add_scanner('.i', fortran.FortranScan)
+    SCons.Tool.SourceFileScanner.add_scanner('.i90', fortran.FortranScan)
     fortran.FortranSuffixes.extend(['.i', '.i90'])
     fortran.generate(env)
 
index f1bc91ac20a80af5f19f6bba2407ef52d7923102..78cffde4e9b8991b34d7d96ee34ad3bb88bb94ef 100644 (file)
@@ -99,8 +99,8 @@ shlib_action = SCons.Action.CommandGenerator(shlib_generator)
 res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
 
 res_builder = SCons.Builder.Builder(action=res_action, suffix='.o',
-                                    source_scanner=SCons.Defaults.ObjSourceScan)
-SCons.Defaults.ObjSourceScan.add_scanner('.rc', SCons.Defaults.CScan)
+                                    source_scanner=SCons.Tool.SourceFileScanner)
+SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
 
 def generate(env):
     mingw = find(env)
index e0ed26d386f40fbe495b05902bfc524e1d015c0c..b47f331a61f0f0fcfe65c064ee91c31390589506 100644 (file)
@@ -400,11 +400,11 @@ def shared_object_emitter(target, source, env):
 pch_action = SCons.Action.Action('$PCHCOM', '$PCHCOMSTR')
 pch_builder = SCons.Builder.Builder(action=pch_action, suffix='.pch',
                                     emitter=pch_emitter,
-                                    source_scanner=SCons.Defaults.ObjSourceScan)
+                                    source_scanner=SCons.Tool.SourceFileScanner)
 res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
 res_builder = SCons.Builder.Builder(action=res_action, suffix='.res',
-                                    source_scanner=SCons.Defaults.ObjSourceScan)
-SCons.Defaults.ObjSourceScan.add_scanner('.rc', SCons.Defaults.CScan)
+                                    source_scanner=SCons.Tool.SourceFileScanner)
+SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
 
 def generate(env):
     """Add Builders and construction variables for MSVC++ to an Environment."""