Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75401 - in trunk/tools/build/v2: build tools
From: ghost_at_[hidden]
Date: 2011-11-08 04:06:56


Author: vladimir_prus
Date: 2011-11-08 04:06:53 EST (Tue, 08 Nov 2011)
New Revision: 75401
URL: http://svn.boost.org/trac/boost/changeset/75401

Log:
Fix PCH support in general and on gcc.

Patch from Georgy Gritsenko.

Text files modified:
   trunk/tools/build/v2/build/generators.py | 22 ++++++++++++++++++----
   trunk/tools/build/v2/build/targets.py | 3 ++-
   trunk/tools/build/v2/tools/builtin.py | 8 ++++++++
   trunk/tools/build/v2/tools/gcc.py | 14 +++++++++-----
   trunk/tools/build/v2/tools/pch.py | 14 +++++++-------
   5 files changed, 44 insertions(+), 17 deletions(-)

Modified: trunk/tools/build/v2/build/generators.py
==============================================================================
--- trunk/tools/build/v2/build/generators.py (original)
+++ trunk/tools/build/v2/build/generators.py 2011-11-08 04:06:53 EST (Tue, 08 Nov 2011)
@@ -400,6 +400,9 @@
 
         dir = os.path.dirname(fullname)
         name = os.path.basename(fullname)
+ idx = name.find(".")
+ if idx != -1:
+ name = name[:idx]
 
         if dir and not ".." in dir and not os.path.isabs(dir):
             # Relative path is always relative to the source
@@ -470,9 +473,6 @@
         post = self.name_postfix_
         for t in self.target_types_:
             basename = os.path.basename(name)
- idx = basename.find(".")
- if idx != -1:
- basename = basename[:idx]
             generated_name = pre[0] + basename + post[0]
             generated_name = os.path.join(os.path.dirname(name), generated_name)
             pre = pre[1:]
@@ -1080,4 +1080,18 @@
         __active_generators = saved_active
 
     return result
-
+
+def add_usage_requirements (result, raw_properties):
+ if result:
+ if isinstance (result[0], property_set.PropertySet):
+ return (result[0].add_raw(raw_properties), result[1])
+ else:
+ return (propery_set.create(raw-properties), result)
+ #if [ class.is-a $(result[1]) : property-set ]
+ #{
+ # return [ $(result[1]).add-raw $(raw-properties) ] $(result[2-]) ;
+ #}
+ #else
+ #{
+ # return [ property-set.create $(raw-properties) ] $(result) ;
+ #}

Modified: trunk/tools/build/v2/build/targets.py
==============================================================================
--- trunk/tools/build/v2/build/targets.py (original)
+++ trunk/tools/build/v2/build/targets.py 2011-11-08 04:06:53 EST (Tue, 08 Nov 2011)
@@ -1290,7 +1290,8 @@
             
     def construct (self, name, source_targets, prop_set):
 
- r = generators.construct (self.project_, name, self.type_,
+ r = generators.construct (self.project_, os.path.splitext(name)[0],
+ self.type_,
                                   prop_set.add_raw(['<main-target-type>' + self.type_]),
                                   source_targets, True)
 

Modified: trunk/tools/build/v2/tools/builtin.py
==============================================================================
--- trunk/tools/build/v2/tools/builtin.py (original)
+++ trunk/tools/build/v2/tools/builtin.py 2011-11-08 04:06:53 EST (Tue, 08 Nov 2011)
@@ -715,6 +715,14 @@
 ###
 ###
 
+class DummyGenerator(generators.Generator):
+ """Generator that accepts everything and produces nothing. Useful as a general
+ fallback for toolset-specific actions like PCH generation.
+ """
+ def run (self, project, name, prop_set, sources):
+ return (property_set.empty(), [])
+
+
 get_manager().projects().add_rule("variant", variant)
 
 import stage

Modified: trunk/tools/build/v2/tools/gcc.py
==============================================================================
--- trunk/tools/build/v2/tools/gcc.py (original)
+++ trunk/tools/build/v2/tools/gcc.py 2011-11-08 04:06:53 EST (Tue, 08 Nov 2011)
@@ -23,13 +23,16 @@
 import bjam
 
 from b2.tools import unix, common, rc, pch, builtin
-from b2.build import feature, type, toolset, generators
+from b2.build import feature, type, toolset, generators, property_set
+from b2.build.property import Property
 from b2.util.utility import os_name, on_windows
 from b2.manager import get_manager
 from b2.build.generators import Generator
 from b2.build.toolset import flags
 from b2.util.utility import to_seq
 
+
+
 __debug = None
 
 def debug():
@@ -222,12 +225,12 @@
         # Find the header in sources. Ignore any CPP sources.
         header = None
         for s in sources:
- if type.is_derived(s.type, 'H'):
+ if type.is_derived(s.type(), 'H'):
                 header = s
 
         # Error handling: Base header file name should be the same as the base
         # precompiled header name.
- header_name = header.name
+ header_name = header.name()
         header_basename = os.path.basename(header_name).rsplit('.', 1)[0]
         if header_basename != name:
             location = project.project_module
@@ -239,14 +242,15 @@
 
         # return result of base class and pch-file property as usage-requirements
         # FIXME: what about multiple results from generator.run?
- return (property_set.create('<pch-file>' + pch_file[0], '<cflags>-Winvalid-pch'),
+ return (property_set.create([Property('pch-file', pch_file[0]),
+ Property('cflags', '-Winvalid-pch')]),
                 pch_file)
 
     # Calls the base version specifying source's name as the name of the created
     # target. As result, the PCH will be named whatever.hpp.gch, and not
     # whatever.gch.
     def generated_targets(self, sources, prop_set, project, name = None):
- name = sources[0].name
+ name = sources[0].name()
         return Generator.generated_targets(self, sources,
             prop_set, project, name)
 

Modified: trunk/tools/build/v2/tools/pch.py
==============================================================================
--- trunk/tools/build/v2/tools/pch.py (original)
+++ trunk/tools/build/v2/tools/pch.py 2011-11-08 04:06:53 EST (Tue, 08 Nov 2011)
@@ -29,6 +29,7 @@
 # ;
 
 from b2.build import type, feature, generators
+from b2.tools import builtin
 
 type.register('PCH', ['pch'])
 type.register('C_PCH', [], 'PCH')
@@ -48,7 +49,7 @@
         from being run unless it's being used for a top-level PCH target.
     """
     def action_class(self):
- return 'compile-action'
+ return builtin.CompileAction
 
     def run(self, project, name, prop_set, sources):
         if not name:
@@ -65,7 +66,7 @@
             pass
         else:
             r = self.run_pch(project, name,
- prop_set.add_raw('<define>BOOST_BUILD_PCH_ENABLED'),
+ prop_set.add_raw(['<define>BOOST_BUILD_PCH_ENABLED']),
                  sources)
             return generators.add_usage_requirements(
                 r, ['<define>BOOST_BUILD_PCH_ENABLED'])
@@ -74,10 +75,9 @@
     def run_pch(self, project, name, prop_set, sources):
         pass
 
-#FIXME: dummy-generator in builtins.jam needs to be ported.
 # NOTE: requirements are empty, default pch generator can be applied when
 # pch=off.
-###generators.register(
-### [ new dummy-generator pch.default-c-pch-generator : : C_PCH ] ;
-###generators.register
-### [ new dummy-generator pch.default-cpp-pch-generator : : CPP_PCH ] ;
+generators.register(builtin.DummyGenerator(
+ "pch.default-c-pch-generator", False, [], ['C_PCH'], []))
+generators.register(builtin.DummyGenerator(
+ "pch.default-cpp-pch-generator", False, [], ['CPP_PCH'], []))


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