# Copyright (c) 2005 Reece H. Dunn. # # Use, modification and distribution is subject to the Boost Software # License Version 1.0. (See accompanying file LICENSE_1_0.txt or # http://www.boost.org/LICENSE_1_0.txt) import type ; import feature : feature ; import generators ; ##### Using Pre-compiled Headers (Quick Guide) ##### # # Make mypch.hpp a pre-compiled header (PCH) using mypch.cpp as the source file: # import cast ; # pch mypch : [ cast _ pcheader : pch.hpp ] pch.cpp ; # # Enable PCHs in a target: # exe hello : mypch main.cpp hello.cpp ; # ^^^^^ -- mypch.hpp is a PCH # # Don't use PCHs for a specific source: # obj nopch : nopch.cpp : off ; # type.register PCH : pch ; type.register PCHEADER : pcheader ; feature pch : # control precompiled header (PCH) generation on # this file has support for using PCHs (if available) off # this file doesn't use PCHs ; feature pch-source : : free dependency ; # mypch.cpp feature pch-header : : free dependency ; # mypch.h[pp] feature pch-file : : free dependency ; # mypch.pch class pch-generator : generator { import property-set ; rule __init__ ( * : * ) { generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; } rule action-class ( ) { return compile-action ; } rule run ( project name ? : property-set : sources * ) { # The two sources are cpp file and PCHEADER, but they # can be passed in any order. Figure out which source # is what. local cpp = $(sources[2]) ; local h = $(sources[1]) ; if [ $(sources[2]).type ] = PCHEADER { cpp = $(sources[1]) ; h = $(sources[2]) ; } local r = [ generator.run $(project) $(name) : [ property-set.create $(cpp) # mypch.cpp [ $(property-set).raw ] ] : $(sources) ] ; return [ property-set.create $(h) # mypch.h[pp] $(r[2]) # mypch.pch ] $(r) ; } }