Boost logo

Boost-Commit :

From: ghost_at_[hidden]
Date: 2008-05-18 11:57:18


Author: vladimir_prus
Date: 2008-05-18 11:57:18 EDT (Sun, 18 May 2008)
New Revision: 45490
URL: http://svn.boost.org/trac/boost/changeset/45490

Log:
Finish scanner.py
Text files modified:
   branches/build/python_port/python/boost/build/build/scanner.py | 136 ++++++++++++++++++---------------------
   1 files changed, 62 insertions(+), 74 deletions(-)

Modified: branches/build/python_port/python/boost/build/build/scanner.py
==============================================================================
--- branches/build/python_port/python/boost/build/build/scanner.py (original)
+++ branches/build/python_port/python/boost/build/build/scanner.py 2008-05-18 11:57:18 EDT (Sun, 18 May 2008)
@@ -1,16 +1,43 @@
-# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and
-# distribute this software is granted provided this copyright notice appears in
-# all copies. This software is provided "as is" without express or implied
-# warranty, and with no claim as to its suitability for any purpose.
+# Status: ported.
+# Base revision: 45462
+#
+# Copyright 2003 Dave Abrahams
+# Copyright 2002, 2003, 2004, 2005 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+# Implements scanners: objects that compute implicit dependencies for
+# files, such as includes in C++.
+#
+# Scanner has a regular expression used to find dependencies, some
+# data needed to interpret those dependencies (for example, include
+# paths), and a code which actually established needed relationship
+# between actual jam targets.
+#
+# Scanner objects are created by actions, when they try to actualize
+# virtual targets, passed to 'virtual-target.actualize' method and are
+# then associated with actual targets. It is possible to use
+# several scanners for a virtual-target. For example, a single source
+# might be used by to compile actions, with different include paths.
+# In this case, two different actual targets will be created, each
+# having scanner of its own.
+#
+# Typically, scanners are created from target type and action's
+# properties, using the rule 'get' in this module. Directly creating
+# scanners is not recommended, because it might create many equvivalent
+# but different instances, and lead in unneeded duplication of
+# actual targets. However, actions can also create scanners in a special
+# way, instead of relying on just target type.
 
 import property
 import bjam
 from boost.build.exceptions import *
+from boost.build.manager import get_manager
 
 def reset ():
     """ Clear the module state. This is mainly for testing purposes.
     """
- global __scanners, __scanner_cache
+ global __scanners, __rv_cache, __scanner_cache
 
     # Maps registered scanner classes to relevant properties
     __scanners = {}
@@ -23,37 +50,36 @@
 reset ()
 
 
-def register (scanner_class, relevant_properties):
+def register(scanner_class, relevant_properties):
     """ Registers a new generator class, specifying a set of
         properties relevant to this scanner. Ctor for that class
         should have one parameter: list of properties.
     """
- __scanners [str (scanner_class)] = relevant_properties
+ __scanners[str(scanner_class)] = relevant_properties
 
-def registered (scanner_class):
+def registered(scanner_class):
     """ Returns true iff a scanner of that class is registered
     """
- return __scanners.has_key (str (scanner_class))
+ return __scanners.has_key(str(scanner_class))
     
-def get (scanner_class, properties):
+def get(scanner_class, properties):
     """ Returns an instance of previously registered scanner
         with the specified properties.
     """
- scanner_name = str (scanner_class)
+ scanner_name = str(scanner_class)
     
- if not registered (scanner_name):
+ if not registered(scanner_name):
         raise BaseException ("attempt to get unregisted scanner: %s" % scanner_name)
 
- relevant_properties = __scanners [scanner_name]
- r = property.select (relevant_properties, properties)
+ relevant_properties = __scanners[scanner_name]
+ r = property.select(relevant_properties, properties)
 
- scanner_id = scanner_name + '.' + '-'.join (r)
+ scanner_id = scanner_name + '.' + '-'.join(r)
     
- if not __scanner_cache.has_key (scanner_name):
- __scanner_cache [scanner_name] = scanner_class (r)
+ if not __scanner_cache.has_key(scanner_name):
+ __scanner_cache[scanner_name] = scanner_class(r)
 
- return __scanner_cache [scanner_name]
-
+ return __scanner_cache[scanner_name]
 
 class Scanner:
     """ Base scanner class.
@@ -74,61 +100,23 @@
         raise BaseException ("method must be overriden")
 
 
-###################################################################
-# Still to port.
-# Original lines are prefixed with "# "
-#
-# # Implements scanners: objects that compute implicit dependencies for
-# # files, such as includes in C++.
-# #
-# # Scanner has a regular expression used to find dependencies, some
-# # data needed to interpret those dependencies (for example, include
-# # paths), and a code which actually established needed relationship
-# # between actual jam targets.
-# #
-# # Scanner objects are created by actions, when they try to actualize
-# # virtual targets, passed to 'virtual-target.actualize' method and are
-# # then associated with actual targets. It is possible to use
-# # several scanners for a virtual-target. For example, a single source
-# # might be used by to compile actions, with different include paths.
-# # In this case, two different actual targets will be created, each
-# # having scanner of its own.
-# #
-# # Typically, scanners are created from target type and action's
-# # properties, using the rule 'get' in this module. Directly creating
-# # scanners is not recommended, because it might create many equvivalent
-# # but different instances, and lead in unneeded duplication of
-# # actual targets. However, actions can also create scanners in a special
-# # way, instead of relying on just target type.
-#
-# import "class" : new ;
-# import property virtual-target ;
-#
-# # Common scanner class, which can be used when there's only one
-# # kind of includes (unlike C, where "" and <> includes have different
-# # search paths).
-# class common-scanner : scanner
-# {
-# import scanner ;
-# rule __init__ ( includes * )
-# {
-# scanner.__init__ ;
-# self.includes = $(includes) ;
-# }
-#
-# rule process ( target : matches * : binding )
-# {
-# local target_path = [ NORMALIZE_PATH $(binding:D) ] ;
-#
-# NOCARE $(matches) ;
-# INCLUDES $(target) : $(matches) ;
-# SEARCH on $(matches) = $(target_path) $(self.includes:G=) ;
-#
-# scanner.propagate $(__name__) : $(matches) : $(target) ;
-# }
-# }
-
-
+# Common scanner class, which can be used when there's only one
+# kind of includes (unlike C, where "" and <> includes have different
+# search paths).
+def CommonScanner(Scanner):
+
+ def __init__ (self, includes):
+ Scanner.__init__(self)
+ self.includes = includes
+
+ def process(self, target, matches, binding):
+
+ target_path = os.path.normpath(os.path.dirname(binding[0]))
+ bjam.call("mark-included", target, matches)
+
+ engine.set_target_variable(matches, "SEARCH",
+ [target_path] + self.includes_)
+ get_manager().scanners().propagate(self, matches)
 
 class ScannerRegistry:
     


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk