$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64432 - in trunk/tools/build/v2: build engine/src tools
From: ghost_at_[hidden]
Date: 2010-07-29 07:37:09
Author: vladimir_prus
Date: 2010-07-29 07:37:07 EDT (Thu, 29 Jul 2010)
New Revision: 64432
URL: http://svn.boost.org/trac/boost/changeset/64432
Log:
Redo naming of actions again. Return values from Python to Jamfiles.
Text files modified: 
   trunk/tools/build/v2/build/engine.py      |    14 +++++++++++---                          
   trunk/tools/build/v2/build/project.py     |     5 +++--                                   
   trunk/tools/build/v2/build/property.py    |    32 +++-----------------------------        
   trunk/tools/build/v2/build/toolset.py     |     4 ++--                                    
   trunk/tools/build/v2/engine/src/compile.c |    34 +++++-----------------------------      
   trunk/tools/build/v2/tools/common.py      |     4 ++--                                    
   6 files changed, 26 insertions(+), 67 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-07-29 07:37:07 EDT (Thu, 29 Jul 2010)
@@ -11,7 +11,8 @@
 
 import b2.build.property_set as property_set
 
-_extract_jamfile_and_rule = re.compile("@(Jamfile<.*>)%(.*)")
+_indirect_rule = re.compile("^([^%]*)%([^%]+)$")
+_extract_jamfile_and_rule = re.compile("(Jamfile<.*>)%(.*)")
 
 class BjamAction:
     """Class representing bjam action defined from Python."""
@@ -41,8 +42,7 @@
         if property_set:
             p = property_set.raw()
 
-        # FIXME: whazzup?
-        m = None #_extract_jamfile_and_rule.match(self.action_name)
+        m = _extract_jamfile_and_rule.match(self.action_name)
         if m:
             bjam_interface.call("set-update-action-in-module",
                                 m.group(1), m.group(2),
@@ -137,6 +137,14 @@
 
         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:
+            return context_module + '%' + action_name        
+
     def register_bjam_action (self, action_name):
         """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-07-29 07:37:07 EDT (Thu, 29 Jul 2010)
@@ -849,7 +849,7 @@
                 e.report()
         finally:                
             self.manager_.errors().pop_jamfile_context()
-                                        
+
         return result
 
     def make_wrapper(self, callable):
@@ -857,7 +857,7 @@
         callable that will call 'callable' and report all exceptins,
         using 'call_and_report_errors'."""
         def wrapper(*args, **kw):
-            self.call_and_report_errors(callable, *args, **kw)
+            return self.call_and_report_errors(callable, *args, **kw)
         return wrapper
 
     def init_project(self, project_module):
@@ -1011,6 +1011,7 @@
 
         for f in m.__dict__:
             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
Modified: trunk/tools/build/v2/build/property.py
==============================================================================
--- trunk/tools/build/v2/build/property.py	(original)
+++ trunk/tools/build/v2/build/property.py	2010-07-29 07:37:07 EDT (Thu, 29 Jul 2010)
@@ -21,7 +21,6 @@
 __re_colon = re.compile (':')
 __re_has_condition = re.compile (r':<')
 __re_separate_condition_and_property = re.compile (r'(.*):(<.*)')
-__re_indirect_rule = re.compile("^([^%]*)%([^%]+)$")
 
 class Property(object):
 
@@ -213,34 +212,9 @@
     result = []
     for p in properties:
         if p.value()[0] == '@':
-            v = None
-            m = p.value()[1:]
-            if __re_indirect_rule.match(m):
-                # Rule is already in indirect format
-                # FIXME: it's not clear if this is necessary.
-                v = m
-            else:
-
-                if not '.' in m:
-                    # This is unqualified rule name. The user might want
-                    # to set flags on this rule name, and toolset.flag
-                    # auto-qualifies the rule name. Need to do the same
-                    # here so set flag setting work.
-                    # We can arrange for toolset.flag to *not* auto-qualify
-                    # the argument, but then two rules defined in two Jamfiles
-                    # will conflict.
-                    m = context_module + "." + m
-
-                # FIXME: now sure if we should register name with '@'
-                # or without.
-                #v = '@' + context_module + '%' + m
-                #print "REGISTER", 
-                get_manager().engine().register_bjam_action(m)
-                ## FIXME: whatsup?
-                #get_manager().engine().register_bjam_action(v)
-                v = '@' + m
-            
-            result.append(Property(p.feature(), v, p.condition()))
+            q = get_manager().engine().qualify_bjam_action(p.value()[1:], context_module)
+            get_manager().engine().register_bjam_action(q)
+            result.append(Property(p.feature(), '@' + q, p.condition()))
         else:
             result.append(p)
 
Modified: trunk/tools/build/v2/build/toolset.py
==============================================================================
--- trunk/tools/build/v2/build/toolset.py	(original)
+++ trunk/tools/build/v2/build/toolset.py	2010-07-29 07:37:07 EDT (Thu, 29 Jul 2010)
@@ -115,14 +115,14 @@
                           is specified, then the value of 'feature' 
                           will be added.
     """
-    caller = bjam.caller()
+    caller = bjam.caller()[:-1]
     if not '.' in rule_or_module and caller.startswith("Jamfile"):
         # Unqualified rule name, used inside Jamfile. Most likely used with
         # 'make' or 'notfile' rules. This prevents setting flags on the entire
         # 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 = caller + rule_or_module
+        rule_or_module = get_manager().engine().qualify_bjam_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/engine/src/compile.c
==============================================================================
--- trunk/tools/build/v2/engine/src/compile.c	(original)
+++ trunk/tools/build/v2/engine/src/compile.c	2010-07-29 07:37:07 EDT (Thu, 29 Jul 2010)
@@ -846,35 +846,9 @@
                 }
             }
         }
-        else if ( PyInstance_Check( py_result ) )
+        else if (PyString_Check(py_result))
         {
-            static char instance_name[1000];
-            static char imported_method_name[1000];
-            module_t * m;
-            PyObject * method;
-            PyObject * method_name = PyString_FromString("foo");
-            RULE * r;
-
-            fprintf(stderr, "Got instance!\n");
-
-            snprintf(instance_name, 1000,
-                     "pyinstance%d", python_instance_number);
-            snprintf(imported_method_name, 1000,
-                     "pyinstance%d.foo", python_instance_number);
-            ++python_instance_number;
-
-            m = bindmodule(instance_name);
-
-            /* This is expected to get bound method. */
-            method = PyObject_GetAttr(py_result, method_name);
-
-            r = bindrule( imported_method_name, root_module() );
-
-            r->python_function = method;
-
-            result = list_new(0, newstr(instance_name));
-
-            Py_DECREF( method_name );
+            result = list_new (0, newstr (PyString_AsString(py_result)));
         }
         else if ( py_result == Py_None )
         {
@@ -882,7 +856,9 @@
         }
         else
         {
-            fprintf(stderr, "Non-list object returned by Python call\n");
+            /* Do nothing.  There are cases, e.g. feature.feature function that
+               should return value for the benefit of Python code and which
+               also can be called by Jam code.  */
         }
 
         Py_DECREF( py_result );
Modified: trunk/tools/build/v2/tools/common.py
==============================================================================
--- trunk/tools/build/v2/tools/common.py	(original)
+++ trunk/tools/build/v2/tools/common.py	2010-07-29 07:37:07 EDT (Thu, 29 Jul 2010)
@@ -513,9 +513,9 @@
         already exists is unspecified.
     """
     if os_name() == 'NT':
-        return "echo. > "
+        return ["echo. > "]
     else:
-        return "touch "
+        return ["touch "]
 
 #FIXME: global variable
 __mkdir_set = set()