Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64691 - in trunk/tools/build/v2: build example/generate util
From: ghost_at_[hidden]
Date: 2010-08-09 06:31:01


Author: vladimir_prus
Date: 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
New Revision: 64691
URL: http://svn.boost.org/trac/boost/changeset/64691

Log:
Improve python-to-jam-to-python tunnelling of values, and 'generate' metatarget.

Text files modified:
   trunk/tools/build/v2/build/engine.py | 14 --------------
   trunk/tools/build/v2/build/project.py | 17 ++++++-----------
   trunk/tools/build/v2/build/property.py | 4 ++--
   trunk/tools/build/v2/build/targets.py | 4 ++--
   trunk/tools/build/v2/build/toolset.py | 4 ++--
   trunk/tools/build/v2/example/generate/jamroot.jam | 2 +-
   trunk/tools/build/v2/util/__init__.py | 20 ++++++++++++++++++--
   7 files changed, 31 insertions(+), 34 deletions(-)

Modified: trunk/tools/build/v2/build/engine.py
==============================================================================
--- trunk/tools/build/v2/build/engine.py (original)
+++ trunk/tools/build/v2/build/engine.py 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
@@ -12,8 +12,6 @@
 import b2.build.property_set as property_set
 import b2.util
 
-_indirect_rule = re.compile("^([^%]*)%([^%]+)$")
-
 class BjamAction:
     """Class representing bjam action defined from Python."""
     
@@ -138,18 +136,6 @@
 
         self.actions[action_name] = BjamAction(action_name, function)
 
- def qualify_bjam_action(self, action_name, context_module):
-
- if _indirect_rule.match(action_name):
- # Rule is already in indirect format
- return action_name
- else:
- ix = action_name.find('.')
- if ix != -1 and action_name[:ix] == context_module:
- return context_module + '%' + action_name[ix+1:]
-
- return context_module + '%' + action_name
-
     def register_bjam_action (self, action_name, function=None):
         """Informs self that 'action_name' is declared in bjam.
 

Modified: trunk/tools/build/v2/build/project.py
==============================================================================
--- trunk/tools/build/v2/build/project.py (original)
+++ trunk/tools/build/v2/build/project.py 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
@@ -53,6 +53,8 @@
 import traceback
 import b2.util.option as option
 
+from b2.util import record_jam_to_value_mapping, qualify_jam_action
+
 class ProjectRegistry:
 
     def __init__(self, manager, global_build_dir):
@@ -847,7 +849,6 @@
                             if x not in ["__init__", "init_project", "add_rule",
                                          "error_reporting_wrapper", "add_rule_for_type", "reverse"]]
         self.all_names_ = [x for x in self.local_names]
- self.reverse = {}
 
     def _import_rule(self, bjam_module, name, callable):
         if hasattr(callable, "bjam_signature"):
@@ -1080,8 +1081,10 @@
             v = m.__dict__[f]
             f = f.replace("_", "-")
             if callable(v):
- self._import_rule(jamfile_module, name + "." + f, v)
- self.reverse.setdefault(jamfile_module, {})[name + "." + f] = v
+ qn = name + "." + f
+ self._import_rule(jamfile_module, qn, v)
+ record_jam_to_value_mapping(qualify_jam_action(qn, jamfile_module), v)
+
 
         if names_to_import:
             if not local_names:
@@ -1111,14 +1114,6 @@
         else:
             return [c + ":" + r for r in requirements]
 
- def reverse_lookup(self, jamfile_module, name_in_jamfile_modue):
- """Return callable that we've previously imported to jam."""
-
- if self.reverse.has_key(jamfile_module):
- return self.reverse[jamfile_module].get(name_in_jamfile_modue, None)
-
- return None
-
     def option(self, name, value):
         name = name[0]
         if not name in ["site-config", "user-config", "project-config"]:

Modified: trunk/tools/build/v2/build/property.py
==============================================================================
--- trunk/tools/build/v2/build/property.py (original)
+++ trunk/tools/build/v2/build/property.py 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
@@ -10,7 +10,7 @@
 import re
 from b2.util.utility import *
 from b2.build import feature
-from b2.util import sequence
+from b2.util import sequence, qualify_jam_action
 import b2.util.set
 from b2.manager import get_manager
 
@@ -215,7 +215,7 @@
     result = []
     for p in properties:
         if p.value()[0] == '@':
- q = get_manager().engine().qualify_bjam_action(p.value()[1:], context_module)
+ q = qualify_jam_action(p.value()[1:], context_module)
             get_manager().engine().register_bjam_action(q)
             result.append(Property(p.feature(), '@' + q, p.condition()))
         else:

Modified: trunk/tools/build/v2/build/targets.py
==============================================================================
--- trunk/tools/build/v2/build/targets.py (original)
+++ trunk/tools/build/v2/build/targets.py 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
@@ -447,10 +447,10 @@
         
         # Record the name of the target, not instance, since this
         # rule is called before main target instaces are created.
- self.explicit_targets_.add(target_name)
+ self.explicit_targets_.update(target_names)
 
     def mark_targets_as_always(self, target_names):
- self.always_targets_.add(target_name)
+ self.always_targets_.update(target_names)
     
     def add_alternative (self, target_instance):
         """ Add new target alternative.

Modified: trunk/tools/build/v2/build/toolset.py
==============================================================================
--- trunk/tools/build/v2/build/toolset.py (original)
+++ trunk/tools/build/v2/build/toolset.py 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
@@ -12,7 +12,7 @@
 
 import feature, property, generators, property_set
 import b2.util.set
-from b2.util import cached
+from b2.util import cached, qualify_jam_action
 from b2.util.utility import *
 from b2.util import bjam_signature
 from b2.manager import get_manager
@@ -122,7 +122,7 @@
         # Jamfile module (this will be considered as rule), but who cares?
         # Probably, 'flags' rule should be split into 'flags' and
         # 'flags-on-module'.
- rule_or_module = get_manager().engine().qualify_bjam_action(rule_or_module, caller)
+ rule_or_module = qualify_jam_action(rule_or_module, caller)
     else:
         # FIXME: revive checking that we don't set flags for a different
         # module unintentionally

Modified: trunk/tools/build/v2/example/generate/jamroot.jam
==============================================================================
--- trunk/tools/build/v2/example/generate/jamroot.jam (original)
+++ trunk/tools/build/v2/example/generate/jamroot.jam 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
@@ -6,4 +6,4 @@
 
 import gen ;
 
-generate a2 : a.cpp : <generating-rule>@gen.generate_example ;
+generate a2 : a.cpp : <generating-rule>@gen.generate-example ;

Modified: trunk/tools/build/v2/util/__init__.py
==============================================================================
--- trunk/tools/build/v2/util/__init__.py (original)
+++ trunk/tools/build/v2/util/__init__.py 2010-08-09 06:30:54 EDT (Mon, 09 Aug 2010)
@@ -43,6 +43,19 @@
 
 _extract_jamfile_and_rule = re.compile("(Jamfile<.*>)%(.*)")
 
+def qualify_jam_action(action_name, context_module):
+
+ if _extract_jamfile_and_rule.match(action_name):
+ # Rule is already in indirect format
+ return action_name
+ else:
+ ix = action_name.find('.')
+ if ix != -1 and action_name[:ix] == context_module:
+ return context_module + '%' + action_name[ix+1:]
+
+ return context_module + '%' + action_name
+
+
 def set_jam_action(name, *args):
 
     m = _extract_jamfile_and_rule.match(name)
@@ -102,10 +115,13 @@
 
     return exported_name
 
+def record_jam_to_value_mapping(jam_value, python_value):
+ __jam_to_python[jam_value] = python_value
+
 def jam_to_value_maybe(jam_value):
 
- if type(jam_value) == type("") and jam_value.startswith("###"):
- return __jam_to_python[jam_value]
+ if type(jam_value) == type(""):
+ return __jam_to_python.get(jam_value, jam_value)
     else:
         return jam_value
 


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