1 # Copyright (c) 2005 Reece H. Dunn.
2 # Copyright 2006 Ilya Sokolov
4 # Use, modification and distribution is subject to the Boost Software
5 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
6 # http://www.boost.org/LICENSE_1_0.txt)
8 ##### Using Precompiled Headers (Quick Guide) #####
10 # Make precompiled mypch.hpp:
18 # <toolset>msvc:<source>mypch.cpp
21 # Add cpp-pch to sources:
24 # : main.cpp hello.cpp mypch
27 import "class" : new ;
32 type.register PCH : pch ;
34 type.register C_PCH : : PCH ;
35 type.register CPP_PCH : : PCH ;
37 # Control precompiled header (PCH) generation.
44 feature.feature pch-header : : free dependency ;
45 feature.feature pch-file : : free dependency ;
47 # Base PCH generator. The 'run' method has the logic to prevent this generator
48 # from being run unless it's being used for a top-level PCH target.
49 class pch-generator : generator
55 return compile-action ;
58 rule run ( project name ? : property-set : sources + )
62 # Unless this generator is invoked as the top-most generator for a
63 # main target, fail. This allows using 'H' type as input type for
64 # this generator, while preventing Boost.Build to try this generator
65 # when not explicitly asked for.
67 # One bad example is msvc, where pch generator produces both PCH
68 # target and OBJ target, so if there's any header generated (like by
69 # bison, or by msidl), we'd try to use pch generator to get OBJ from
70 # that H, which is completely wrong. By restricting this generator
71 # only to pch main target, such problem is solved.
75 local r = [ run-pch $(project) $(name)
76 : [ $(property-set).add-raw <define>BOOST_BUILD_PCH_ENABLED ]
78 return [ generators.add-usage-requirements $(r)
79 : <define>BOOST_BUILD_PCH_ENABLED ] ;
83 # This rule must be overridden by the derived classes.
84 rule run-pch ( project name ? : property-set : sources + )
90 # NOTE: requirements are empty, default pch generator can be applied when
93 [ new dummy-generator pch.default-c-pch-generator : : C_PCH ] ;
95 [ new dummy-generator pch.default-cpp-pch-generator : : CPP_PCH ] ;