2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 00:52:16 +00:00
Files
build/src/tools/pch.jam
Vladimir Prus 76d041d7c1 Implement precompiled headers on gcc and improve same on msvc.
Notable changes:
1. There's no need to cast header to the PCHHEADER type.
2. There are two separate type "C_PCH" and "CPP_PCH", that
use C and C++ compilation respectively.

Most of the patch sumbitted by Ilya Sokolov.

	tools/
	* builtin.jam (class dummy-generator): New.
	* gcc.jam: Override extension of the PCH type.
	(class gcc-pch-generator): New.
	Register generators for C_PCH and CPP_PCH.
	(compile.c++.pch, compile.c.pch): New.
	* msvc.jam (class msvc-pch-generator): New.
	Register generators for C_PCH and CPP_PCH.
	* pch.jam: Remove 'PCHHEADER' type.
	(pch-generator): Fail unlress it's used at top-level
	generator.
	Register catch-all produce-nothing generators for PCH-less
	toolsets.


[SVN r35508]
2006-10-07 09:31:19 +00:00

95 lines
2.6 KiB
Plaintext

# Copyright (c) 2005 Reece H. Dunn.
# Copyright 2006 Ilya Sokolov
#
# 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)
##### Using Precompiled Headers (Quick Guide) #####
#
# Make precompiled mypch.hpp:
#
# import pch ;
#
# cpp-pch mypch
# : # sources
# mypch.hpp
# : # requiremnts
# <toolset>msvc:<source>mypch.cpp
# ;
#
# Add cpp-pch to sources:
#
# exe hello
# : main.cpp hello.cpp mypch
# ;
import "class" : new ;
import type ;
import feature ;
import generators ;
type.register PCH : pch ;
type.register C_PCH : : PCH ;
type.register CPP_PCH : : PCH ;
# control precompiled header (PCH) generation
feature.feature pch :
on
off
;
feature.feature pch-header : : free dependency ;
feature.feature pch-file : : free dependency ;
# Base PCH generator. The 'run' method has the logic to
# prevent this generator from being run unless it's used
# in top-level PCH target.
class pch-generator : generator
{
import property-set ;
rule action-class ( )
{
return compile-action ;
}
rule run ( project name ? : property-set : sources + )
{
if ! $(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 this generator, while
# preventing Boost.Build to try this generator when not
# explicitly asked for.
#
# One bad example is msvc, where pch generator produces
# both PCH target and OBJ target, so if there's any
# header generated (like by bison, or by msidl), we'd
# try to use pch generator to get OBJ from that H, which
# is completely wrong. By restricting this generator
# only to pch main target, such problem is solved.
return [ property-set.empty ] ;
}
else
{
return [ run-pch $(project) $(name) : $(property-set)
: $(sources) ] ;
}
}
# This rule must be overridden by the derived classes.
rule run-pch ( project name ? : property-set : sources + )
{
}
}
# NOTE: requiremetns 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 ] ;