$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: ghost_at_[hidden]
Date: 2008-05-18 11:12:49
Author: vladimir_prus
Date: 2008-05-18 11:12:48 EDT (Sun, 18 May 2008)
New Revision: 45488
URL: http://svn.boost.org/trac/boost/changeset/45488
Log:
Make header scanning work
Text files modified: 
   branches/build/python_port/python/boost/build/build/scanner.py        |    49 +++++++++++++----------------           
   branches/build/python_port/python/boost/build/build/virtual_target.py |     4 +-                                      
   branches/build/python_port/python/boost/build/tools/builtin.py        |    66 ++++++++++++++++++++------------------- 
   branches/build/python_port/python/boost/build/util/regex.py           |     2 +                                       
   4 files changed, 60 insertions(+), 61 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:12:48 EDT (Sun, 18 May 2008)
@@ -4,6 +4,7 @@
 #  warranty, and with no claim as to its suitability for any purpose.
 
 import property
+import bjam
 from boost.build.exceptions import *
 
 def reset ():
@@ -133,42 +134,36 @@
     
     def __init__ (self, manager):
         self.manager_ = manager
+        self.count_ = 0
+        self.exported_scanners_ = {}
 
     def install (self, scanner, target, vtarget):
         """ Installs the specified scanner on actual target 'target'. 
             vtarget: virtual target from which 'target' was actualized.
         """
-        # TODO: actaully implement this
-#        HDRSCAN on $(target) = [ $(scanner).pattern ] ;
-#        SCANNER on $(target) = $(scanner) ;
-#        HDRRULE on $(target) = scanner.hdrrule ;
+        engine = self.manager_.engine()
+        engine.set_target_variable(target, "HDRSCAN", scanner.pattern())
+        if not self.exported_scanners_.has_key(scanner):
+            exported_name = "scanner_" + str(self.count_)
+            self.count_ = self.count_ + 1
+            self.exported_scanners_[scanner] = exported_name
+            bjam.import_rule("", exported_name, scanner.process)
+        else:
+            exported_name = self.exported_scanners_[scanner]
+
+        engine.set_target_variable(target, "HDRRULE", exported_name)
         
         # scanner reflects difference in properties affecting    
         # binding of 'target', which will be known when processing
         # includes for it, will give information on how to
         # interpret quoted includes.
-#        HDRGRIST on $(target) = $(scanner) ;
+        engine.set_target_variable(target, "HDRGRIST", str(id(scanner)))
         pass
 
-#   # Propagate scanner setting from 'including-target' to 'targets'.
-#   rule propagate ( scanner : targets * : including-target )
-#   {
-#       HDRSCAN on $(targets) = [ on $(including-target) return $(HDRSCAN) ] ;
-#       SCANNER on $(targets) = $(scanner) ;
-#       HDRRULE on $(targets) = scanner.hdrrule ;
-#       HDRGRIST on $(targets) = [ on $(including-target) return $(HDRGRIST) ] ;
-#   }
-#   
-#   
-#   rule hdrrule ( target : matches * : binding )
-#   {
-#       local scanner = [ on $(target) return $(SCANNER) ] ;
-#       $(scanner).process $(target) : $(matches) : $(binding) ;
-#   }
-#   # hdrrule must be available at global scope so that it can be invoked
-#   # by header scanning
-#   IMPORT scanner : hdrrule : : scanner.hdrrule ;
-#   
-#   
-#   
-#   
+    def propagate(self, scanner, targets):
+        engine = self.manager_.engine()
+        engine.set_target_variable(targets, "HDRSCAN", scanner.pattern())
+        engine.set_target_variable(targets, "HDRRULE",
+                                   self.exported_scanners_[scanner])
+        engine.set_target_variable(targets, "HDRGRIST", str(id(scanner)))
+
Modified: branches/build/python_port/python/boost/build/build/virtual_target.py
==============================================================================
--- branches/build/python_port/python/boost/build/build/virtual_target.py	(original)
+++ branches/build/python_port/python/boost/build/build/virtual_target.py	2008-05-18 11:12:48 EDT (Sun, 18 May 2008)
@@ -306,7 +306,7 @@
 
         else:
             # Add the scanner instance to the grist for name.
-            g = '-'.join ([ungrist (get_grist (actual_name)), str (scanner)])
+            g = '-'.join ([ungrist(get_grist(actual_name)), str(id(scanner))])
 
             name = replace_grist (actual_name, '<' + g + '>')
 
@@ -548,7 +548,7 @@
 
         # Do anything only on the first invocation
         if not self.made_:
-            self.made_ = 1
+            self.made_[name] = True
 
             if self.action_:  
                 # For non-derived target, we don't care if there
Modified: branches/build/python_port/python/boost/build/tools/builtin.py
==============================================================================
--- branches/build/python_port/python/boost/build/tools/builtin.py	(original)
+++ branches/build/python_port/python/boost/build/tools/builtin.py	2008-05-18 11:12:48 EDT (Sun, 18 May 2008)
@@ -10,7 +10,8 @@
 from boost.build.build import feature, property, virtual_target, generators, type, property_set, scanner
 from boost.build.util.utility import *
 from boost.build.util import path, regex
-import boost.build.tools.types 
+import boost.build.tools.types
+from boost.build.manager import get_manager
 
 # Records explicit properties for a variant.
 # The key is the variant name.
@@ -223,40 +224,41 @@
         return r'#[ \t]*include[ ]*(<(.*)>|"(.*)")'
 
     def process (self, target, matches, binding):
+       
         angle = regex.transform (matches, "<(.*)>")
         quoted = regex.transform (matches, '"(.*)"')
 
-###         # CONSIDER: the new scoping rule seem to defeat "on target" variables.
-###         local g = [ on $(target) return $(HDRGRIST) ] ;  
-###         local b = [ NORMALIZE_PATH $(binding:D) ] ;
-### 
-###         # Attach binding of including file to included targets.
-###         # When target is directly created from virtual target
-###         # this extra information is unnecessary. But in other
-###         # cases, it allows to distinguish between two headers of the 
-###         # same name included from different places.      
-###         # We don't need this extra information for angle includes,
-###         # since they should not depend on including file (we can't
-###         # get literal "." in include path).
-###         local g2 = $(g)"#"$(b) ;
-###        
-###         angle = $(angle:G=$(g)) ;
-###         quoted = $(quoted:G=$(g2)) ;
-###         
-###         local all = $(angle) $(quoted) ;
-### 
-###         INCLUDES $(target) : $(all) ;
-###         NOCARE $(all) ;
-###         SEARCH on $(angle) = $(self.includes:G=) ;
-###         SEARCH on $(quoted) = $(b) $(self.includes:G=) ;
-### 
-###         # Just propagate current scanner to includes, in a hope
-###         # that includes do not change scanners. 
-###         scanner.propagate $(__name__) : $(angle) $(quoted) : $(target) ;
-### 
-### scanner.register (CScanner, 'include')
-### 
-### type.set_scanner ('CPP', CScanner)
+        g = str(id(self))
+        b = os.path.normpath(os.path.dirname(binding[0]))
+        
+        # Attach binding of including file to included targets.
+        # When target is directly created from virtual target
+        # this extra information is unnecessary. But in other
+        # cases, it allows to distinguish between two headers of the 
+        # same name included from different places.      
+        # We don't need this extra information for angle includes,
+        # since they should not depend on including file (we can't
+        # get literal "." in include path).
+        g2 = g + "#" + b
+
+        g = "<" + g + ">"
+        g2 = "<" + g2 + ">"
+        angle = [g + x for x in angle]
+        quoted = [g2 + x for x in quoted]
+
+        all = angle + quoted
+        bjam.call("mark-included", target, all)
+
+        engine = get_manager().engine()
+        engine.set_target_variable(angle, "SEARCH", self.includes_)
+        engine.set_target_variable(quoted, "SEARCH", self.includes_)
+        
+        # Just propagate current scanner to includes, in a hope
+        # that includes do not change scanners. 
+        get_manager().scanners().propagate(self, angle + quoted)
+        
+scanner.register (CScanner, 'include')
+type.set_scanner ('CPP', CScanner)
 
 class LibGenerator (generators.Generator):
     """ The generator class for libraries (target type LIB). Depending on properties it will
Modified: branches/build/python_port/python/boost/build/util/regex.py
==============================================================================
--- branches/build/python_port/python/boost/build/util/regex.py	(original)
+++ branches/build/python_port/python/boost/build/util/regex.py	2008-05-18 11:12:48 EDT (Sun, 18 May 2008)
@@ -3,6 +3,8 @@
 #  all copies. This software is provided "as is" without express or implied
 #  warranty, and with no claim as to its suitability for any purpose.
 
+import re
+
 def transform (list, pattern, indices = [1]):
     """ Matches all elements of 'list' agains the 'pattern' 
         and returns a list of the elements indicated by indices of