Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64292 - trunk/tools/build/v2/build
From: ghost_at_[hidden]
Date: 2010-07-23 07:31:32


Author: vladimir_prus
Date: 2010-07-23 07:31:31 EDT (Fri, 23 Jul 2010)
New Revision: 64292
URL: http://svn.boost.org/trac/boost/changeset/64292

Log:
Handle bjam_signature in all cases where were import a callable into bjam.

Text files modified:
   trunk/tools/build/v2/build/project.py | 34 +++++++++++++++++++++-------------
   1 files changed, 21 insertions(+), 13 deletions(-)

Modified: trunk/tools/build/v2/build/project.py
==============================================================================
--- trunk/tools/build/v2/build/project.py (original)
+++ trunk/tools/build/v2/build/project.py 2010-07-23 07:31:31 EDT (Fri, 23 Jul 2010)
@@ -797,6 +797,13 @@
                                          "error_reporting_wrapper", "add_rule_for_type"]]
         self.all_names_ = [x for x in self.local_names]
 
+ def _import_rule(self, bjam_module, name, callable):
+ if hasattr(callable, "bjam_signature"):
+ bjam.import_rule(bjam_module, name, self.make_wrapper(callable), callable.bjam_signature)
+ else:
+ bjam.import_rule(bjam_module, name, self.make_wrapper(callable))
+
+
     def add_rule_for_type(self, type):
         rule_name = type.lower();
 
@@ -811,14 +818,20 @@
         self.rules[name] = callable
         self.all_names_.append(name)
 
+ # Add new rule at global bjam scope. This might not be ideal,
+ # added because if a jamroot does 'import foo' where foo calls
+ # add_rule, we need to import new rule to jamroot scope, and
+ # I'm lazy to do this now.
+ self._import_rule("", name, callable)
+
     def all_names(self):
         return self.all_names_
 
- def call_and_report_errors(self, callable, *args):
+ def call_and_report_errors(self, callable, *args, **kw):
         result = None
         try:
             self.manager_.errors().push_jamfile_context()
- result = callable(*args)
+ result = callable(*args, **kw)
         except ExceptionWithUserContext, e:
             e.report()
         except Exception, e:
@@ -835,8 +848,8 @@
         """Given a free-standing function 'callable', return a new
         callable that will call 'callable' and report all exceptins,
         using 'call_and_report_errors'."""
- def wrapper(*args):
- self.call_and_report_errors(callable, *args)
+ def wrapper(*args, **kw):
+ self.call_and_report_errors(callable, *args, **kw)
         return wrapper
 
     def init_project(self, project_module):
@@ -851,12 +864,10 @@
                 else:
                     n = string.replace(n, "_", "-")
                     
- bjam.import_rule(project_module, n,
- self.make_wrapper(v))
+ self._import_rule(project_module, n, v)
 
         for n in self.rules:
- bjam.import_rule(project_module, n,
- self.make_wrapper(self.rules[n]))
+ self._import_rule(project_module, n, self.rules[n])
 
     def project(self, *args):
 
@@ -990,10 +1001,7 @@
         for f in m.__dict__:
             v = m.__dict__[f]
             if callable(v):
- if hasattr(v, "bjam_signature"):
- bjam.import_rule(jamfile_module, name + "." + f, v, v.bjam_signature)
- else:
- bjam.import_rule(jamfile_module, name + "." + f, v)
+ self._import_rule(jamfile_module, name + "." + f, v)
 
         if names_to_import:
             if not local_names:
@@ -1004,7 +1012,7 @@
 """The number of names to import and local names do not match.""")
 
             for n, l in zip(names_to_import, local_names):
- bjam.import_rule(jamfile_module, l, m.__dict__[n])
+ self._import_rule(jamfile_module, l, m.__dict__[n])
         
     def conditional(self, condition, requirements):
         """Calculates conditional requirements for multiple requirements


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