Index: tools/gcc.py =================================================================== --- tools/gcc.py (revision 75206) +++ tools/gcc.py (working copy) @@ -23,13 +23,15 @@ 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(): @@ -215,19 +217,18 @@ # GCC-specific pch generator. class GccPchGenerator(pch.PchGenerator): - + # Inherit the __init__ method - - def run_pch(self, project, name, prop_set, sources): + def run_pch(self, project, name, prop_set, sources): # 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 +240,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[0], '-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) Index: tools/pch.py =================================================================== --- tools/pch.py (revision 75206) +++ tools/pch.py (working copy) @@ -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,9 +49,11 @@ 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): + def run(self, project, name, prop_set, sources): +# import pdb +# pdb.set_trace() if not name: # Unless this generator is invoked as the top-most generator for a # main target, fail. This allows using 'H' type as input type for @@ -65,7 +68,7 @@ pass else: r = self.run_pch(project, name, - prop_set.add_raw('BOOST_BUILD_PCH_ENABLED'), + prop_set.add_raw(['BOOST_BUILD_PCH_ENABLED']), sources) return generators.add_usage_requirements( r, ['BOOST_BUILD_PCH_ENABLED']) @@ -74,10 +77,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'], [])) Index: tools/builtin.py =================================================================== --- tools/builtin.py (revision 75206) +++ tools/builtin.py (working copy) @@ -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 Index: build/targets.py =================================================================== --- build/targets.py (revision 75206) +++ build/targets.py (working copy) @@ -1290,7 +1288,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(['' + self.type_]), source_targets, True) Index: build/generators.py =================================================================== --- build/generators.py (revision 75206) +++ build/generators.py (working copy) @@ -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,14 +474,11 @@ 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:] post = post[1:] - + targets.append(virtual_target.FileTarget(generated_name, t, project, a)) return [ project.manager().virtual_targets().register(t) for t in targets ] @@ -1080,4 +1081,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) ; + #}