Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64406 - in trunk/tools/build/v2: . build test/dependency-test tools
From: ghost_at_[hidden]
Date: 2010-07-28 08:04:34


Author: vladimir_prus
Date: 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
New Revision: 64406
URL: http://svn.boost.org/trac/boost/changeset/64406

Log:
More changes
Added:
   trunk/tools/build/v2/test/dependency-test/foo.py (contents, props changed)
Text files modified:
   trunk/tools/build/v2/build/engine.py | 5 ++
   trunk/tools/build/v2/build/generators.py | 4 +-
   trunk/tools/build/v2/build/property.py | 2
   trunk/tools/build/v2/build/property_set.py | 16 +++++-----
   trunk/tools/build/v2/build/targets.py | 61 ++++++++++++++++++++++++---------------
   trunk/tools/build/v2/build/virtual_target.py | 34 +++++++--------------
   trunk/tools/build/v2/build_system.py | 2
   trunk/tools/build/v2/tools/builtin.py | 10 ++---
   trunk/tools/build/v2/tools/common.py | 4 +-
   trunk/tools/build/v2/tools/unix.py | 6 +-
   10 files changed, 74 insertions(+), 70 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-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -8,6 +8,8 @@
 
 import operator
 
+import b2.build.property_set as property_set
+
 class BjamAction:
     """Class representing bjam action defined from Python."""
     
@@ -83,7 +85,7 @@
         for target in targets:
             self.do_set_target_variable (target, variable, value, append)
 
- def set_update_action (self, action_name, targets, sources, properties):
+ def set_update_action (self, action_name, targets, sources, properties=property_set.empty()):
         """ Binds a target to the corresponding update action.
             If target needs to be updated, the action registered
             with action_name will be used.
@@ -91,6 +93,7 @@
             either 'register_action' or 'register_bjam_action'
             method.
         """
+ assert(isinstance(properties, property_set.PropertySet))
         if isinstance (targets, str):
             targets = [targets]
         self.do_set_update_action (action_name, targets, sources, properties)

Modified: trunk/tools/build/v2/build/generators.py
==============================================================================
--- trunk/tools/build/v2/build/generators.py (original)
+++ trunk/tools/build/v2/build/generators.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -401,8 +401,8 @@
             name = self.determine_output_name(sources)
         
         # Assign an action for each target
- action = self.action_class()
- a = action (project.manager(), sources, self.id_, prop_set)
+ action = self.action_class()
+ a = action(project.manager(), sources, self.id_, prop_set)
                 
         # Create generated target for each target type.
         targets = []

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-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -44,7 +44,7 @@
         return self._condition
 
     def to_raw(self):
- result = "<" + self._feature.name() + ">" + self._value
+ result = "<" + self._feature.name() + ">" + str(self._value)
         if self._condition:
             result = ",".join(str(p) for p in self._condition) + ':' + result
         return result

Modified: trunk/tools/build/v2/build/property_set.py
==============================================================================
--- trunk/tools/build/v2/build/property_set.py (original)
+++ trunk/tools/build/v2/build/property_set.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -34,7 +34,7 @@
         x = raw_properties
     else:
         x = [property.create_from_string(ps) for ps in raw_properties]
- x.sort ()
+ x.sort()
     x = unique (x)
 
     # FIXME: can we do better, e.g. by directly computing
@@ -203,13 +203,7 @@
                 pass
             else:
                 self.base_raw_.append (p)
-
- if 'dependency' in att:
- self.dependency_.append (p)
- else:
- self.non_dependency_.append (p)
-
-
+
             if 'propagated' in att:
                 self.propagated_.append (p)
 
@@ -230,6 +224,12 @@
             else:
                 self.non_conditional_.append(p)
 
+ if p.feature().dependency():
+ self.dependency_.append (p)
+ else:
+ self.non_dependency_.append (p)
+
+
     def all(self):
         return self.all_
     

Modified: trunk/tools/build/v2/build/targets.py
==============================================================================
--- trunk/tools/build/v2/build/targets.py (original)
+++ trunk/tools/build/v2/build/targets.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -240,6 +240,7 @@
         
         self.__usage_requirements = ur
         self.__targets = targets
+ assert all(isinstance(t, virtual_target.VirtualTarget) for t in targets)
 
         if not self.__usage_requirements:
             self.__usage_requirements = property_set.empty ()
@@ -1018,31 +1019,41 @@
 
         else:
             return None
+
+
+ def generate_dependency_targets (self, target_ids, property_set):
+ targets = []
+ usage_requirements = []
+ for id in target_ids:
+
+ result = self.generate_from_reference(id, self.project_, property_set)
+ targets += result.targets()
+ usage_requirements += result.usage_requirements().all()
+
+ return (targets, usage_requirements)
     
- def generate_dependencies (self, dependencies, property_set):
+ def generate_dependency_properties(self, properties, ps):
         """ Takes a target reference, which might be either target id
             or a dependency property, and generates that target using
             'property_set' as build request.
 
             Returns a tuple (result, usage_requirements).
         """
- result_var = []
+ result_properties = []
         usage_requirements = []
- for dependency in dependencies:
- grist = get_grist (dependency)
- id = replace_grist (dependency, '')
-
- result = self.generate_from_reference (id, self.project_, property_set)
-
- # FIXME:
- # TODO: this is a problem: the grist must be kept and the value
- # is the object itself. This won't work in python.
- targets = [ self.manager_.register_object (x) for x in result.targets () ]
+ for p in properties:
+
+ result = self.generate_from_reference(p.value(), self.project_, ps)
+
+ for t in result.targets():
+ result_properties.append(property.Property(p.feature(), t))
             
- result_var += replace_grist(targets, grist)
             usage_requirements += result.usage_requirements().all()
 
- return (result_var, usage_requirements)
+ return (result_properties, usage_requirements)
+
+
+
 
     @user_error_checkpoint
     def generate (self, ps):
@@ -1083,19 +1094,20 @@
 
                 properties = rproperties.non_dependency ()
 
- (p, u) = self.generate_dependencies (rproperties.dependency (), rproperties)
+ (p, u) = self.generate_dependency_properties (rproperties.dependency (), rproperties)
                 properties += p
+ assert all(isinstance(p, property.Property) for p in properties)
                 usage_requirements = u
 
- (source_targets, u) = self.generate_dependencies (self.sources_, rproperties)
+ (source_targets, u) = self.generate_dependency_targets (self.sources_, rproperties)
                 usage_requirements += u
 
                 self.manager_.targets().log(
                     "Usage requirements for '%s' are '%s'" % (self.name_, usage_requirements))
 
                 # FIXME:
-
- rproperties = property_set.create(properties + [p.to_raw() for p in usage_requirements])
+
+ rproperties = property_set.create(properties + usage_requirements)
                 usage_requirements = property_set.create (usage_requirements)
 
                 self.manager_.targets().log(
@@ -1128,7 +1140,7 @@
 
                     self.manager_.targets().log (
                         "Usage requirements from '%s' are '%s'" %
- (self.name, str(rproperties.raw())))
+ (self.name(), str(rproperties)))
                     
                     self.generated_[ps] = GenerateResult (ur, result)
                 else:
@@ -1159,14 +1171,14 @@
             project: Project where the reference is made
             property_set: Properties of the main target that makes the reference
         """
- target, sproperties = self.resolve_reference (target_reference, project)
+ target, sproperties = self.resolve_reference(target_reference, project)
         
         # Take properties which should be propagated and refine them
         # with source-specific requirements.
- propagated = property_set.propagated ()
- rproperties = propagated.refine (sproperties)
+ propagated = property_set.propagated()
+ rproperties = propagated.refine(sproperties)
             
- return target.generate (rproperties)
+ return target.generate(rproperties)
     
     def compute_usage_requirements (self, subvariant):
         """ Given the set of generated targets, and refined build
@@ -1179,7 +1191,7 @@
         
         # We generate all dependency properties and add them,
         # as well as their usage requirements, to result.
- (r1, r2) = self.generate_dependencies (xusage_requirements.dependency (), rproperties)
+ (r1, r2) = self.generate_dependency_properties(xusage_requirements.dependency (), rproperties)
         extra = r1 + r2
                 
         result = property_set.create (xusage_requirements.non_dependency () + extra)
@@ -1249,6 +1261,7 @@
         return self.type_
             
     def construct (self, name, source_targets, prop_set):
+
         r = generators.construct (self.project_, name, self.type_,
                                   prop_set.add_raw(['<main-target-type>' + self.type_]),
             source_targets)

Modified: trunk/tools/build/v2/build/virtual_target.py
==============================================================================
--- trunk/tools/build/v2/build/virtual_target.py (original)
+++ trunk/tools/build/v2/build/virtual_target.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -71,6 +71,7 @@
 from b2.tools import common
 from b2.exceptions import *
 import b2.build.type
+import b2.build.property_set as property_set
 import type
 
 __re_starts_with_at = re.compile ('^@(.*)')
@@ -133,9 +134,6 @@
         # TODO: Don't append if we found pre-existing target?
         self.recent_targets_.append(result)
         self.all_targets_.append(result)
-
- result.set_id(self.next_id_)
- self.next_id_ = self.next_id_+1
     
         return result
 
@@ -159,10 +157,7 @@
         result = FileTarget (file, file_type, project,
                              None, file_location)
         self.files_ [path] = result
-
- result.set_id(self.next_id_)
- self.next_id_ = self.next_id_+1
-
+
         return result
 
     def recent_targets(self):
@@ -269,15 +264,6 @@
         """
         return self.project_
 
- def set_id(self, id):
- self.id_ = id
-
- def __hash__(self):
- return self.id_
-
- def __cmp__(self, other):
- return self.id_ - other.id_
-
     def depends (self, d):
         """ Adds additional instances of 'VirtualTarget' that this
             one depends on.
@@ -707,11 +693,15 @@
         not establish dependency relationship, but should do everything else.
     """
     def __init__ (self, manager, sources, action_name, prop_set):
+ assert(isinstance(prop_set, property_set.PropertySet))
         self.sources_ = sources
         self.action_name_ = action_name
         if not prop_set:
             prop_set = property_set.empty()
         self.properties_ = prop_set
+ if not all(isinstance(v, VirtualTarget) for v in prop_set.get('implicit-dependency')):
+ import pdb
+ pdb.set_trace()
 
         self.manager_ = manager
         self.engine_ = self.manager_.engine ()
@@ -750,6 +740,7 @@
         ps = self.properties ()
         properties = self.adjust_properties (ps)
 
+
         actual_targets = []
         
         for i in self.targets ():
@@ -767,14 +758,14 @@
         toolset.set_target_variables (self.manager_, self.action_name_, actual_targets, properties)
              
         engine = self.manager_.engine ()
-
+
         self.manager_.engine ().set_update_action (self.action_name_, actual_targets, self.actual_sources_,
                                                    properties)
         
         # Since we set up creating action here, we also set up
         # action for cleaning up
         self.manager_.engine ().set_update_action ('common.Clean', 'clean-all',
- actual_targets, None)
+ actual_targets)
 
         return actual_targets
 
@@ -826,6 +817,7 @@
         # if we're building just hello ("bjam hello"), 'a.h' won't be
         # actualized unless we do it here.
         implicit = self.properties_.get("<implicit-dependency>")
+
         for i in implicit:
             i.actualize()
 
@@ -957,13 +949,11 @@
         
         # Pre-compose the list of other dependency graphs, on which this one
         # depends
- deps = build_properties.get ('<implicit-dependency>')
+ deps = build_properties.get('<implicit-dependency>')
         
         self.other_dg_ = []
         for d in deps:
- # FIXME: the property must have the actual object here, not a string.
- value = replace_grist (d, '')
- self.other_dg_.append (value.creating_subvariant ())
+ self.other_dg_.append(d.creating_subvariant ())
 
         self.other_dg_ = unique (self.other_dg_)
 

Modified: trunk/tools/build/v2/build_system.py
==============================================================================
--- trunk/tools/build/v2/build_system.py (original)
+++ trunk/tools/build/v2/build_system.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -838,7 +838,7 @@
         bjam.call("UPDATE", "clean-all")
     elif clean:
         manager.engine().set_update_action("common.Clean", "clean",
- actual_clean_targets(targets), None)
+ actual_clean_targets(targets))
         bjam.call("UPDATE", "clean")
     else:
         # FIXME:

Added: trunk/tools/build/v2/test/dependency-test/foo.py
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/test/dependency-test/foo.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -0,0 +1,26 @@
+# Copyright 2003 Dave Abrahams
+# Copyright 2002, 2003, 2005, 2010 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)
+
+import bjam
+import b2.build.type as type
+import b2.build.generators as generators
+
+from b2.manager import get_manager
+
+type.register("FOO", ["foo"])
+generators.register_standard("foo.foo", ["FOO"], ["CPP", "H"])
+
+def prepare_foo(targets, sources, properties):
+
+ if properties.get('os') in ['windows', 'cygwin']:
+ bjam.call('set-target-variable', targets, "DECL",
+ "void __declspec(dllexport) foo(){}")
+
+ pass
+
+get_manager().engine().register_action("foo.foo",\
+"""echo $(DECL:E="//")\n > $(<[1])
+echo "#include <z.h>"\n > $(<[2])
+""", function=prepare_foo)

Modified: trunk/tools/build/v2/tools/builtin.py
==============================================================================
--- trunk/tools/build/v2/tools/builtin.py (original)
+++ trunk/tools/build/v2/tools/builtin.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -659,15 +659,12 @@
 
         # sources to pass to inherited rule
         sources2 = []
- # properties to pass to inherited rule
- properties2 = []
         # sources which are libraries
         libraries = []
         
         # Searched libraries are not passed as argument to linker
         # but via some option. So, we pass them to the action
         # via property.
- properties2 = prop_set.raw()
         fsa = []
         fst = []
         for s in sources:
@@ -682,12 +679,13 @@
             else:
                 sources2.append(s)
 
+ add = []
         if fsa:
- properties2 += [replace_grist('&&'.join(fsa), '<find-shared-library>')]
+ add.append("<find-shared-library>" + '&&'.join(fsa))
         if fst:
- properties2 += [replace_grist('&&'.join(fst), '<find-static-library>')]
+ add.append("<find-static-library>" + '&&'.join(fst))
                 
- spawn = generators.Generator.generated_targets(self, sources2, property_set.create(properties2), project, name)
+ spawn = generators.Generator.generated_targets(self, sources2,prop_set.add_raw(add), project, name)
         
         return spawn
 

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-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -535,9 +535,9 @@
 
         # Schedule the mkdir build action.
         if os_name() == 'NT':
- engine.set_update_action("common.MkDir1-quick-fix-for-windows", target, [], None)
+ engine.set_update_action("common.MkDir1-quick-fix-for-windows", target, [])
         else:
- engine.set_update_action("common.MkDir1-quick-fix-for-unix", target, [], None)
+ engine.set_update_action("common.MkDir1-quick-fix-for-unix", target, [])
 
         # Prepare a Jam 'dirs' target that can be used to make the build only
         # construct all the target directories.

Modified: trunk/tools/build/v2/tools/unix.py
==============================================================================
--- trunk/tools/build/v2/tools/unix.py (original)
+++ trunk/tools/build/v2/tools/unix.py 2010-07-28 08:04:31 EDT (Wed, 28 Jul 2010)
@@ -129,9 +129,9 @@
 def set_library_order (manager, sources, prop_set, result):
     used_libraries = []
     deps = prop_set.dependency ()
-
- [ sources.append (manager.get_object (get_value (x))) for x in deps ]
- sources = sequence.unique (sources)
+
+ sources.extend(d.value() for d in deps)
+ sources = sequence.unique(sources)
 
     for l in sources:
         if l.type () and type.is_derived (l.type (), 'LIB'):


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