Index: tools/build/v2/tools/gcc.jam =================================================================== RCS file: /cvsroot/boost/boost/tools/build/v2/tools/gcc.jam,v retrieving revision 1.57 diff -u -r1.57 gcc.jam --- tools/build/v2/tools/gcc.jam 21 Sep 2005 13:44:06 -0000 1.57 +++ tools/build/v2/tools/gcc.jam 20 Nov 2005 18:29:57 -0000 @@ -15,7 +15,9 @@ import "class" : new ; import set ; import common ; + import errors ; +import pch ; feature.extend toolset : gcc ; @@ -68,6 +70,8 @@ generators.register-c-compiler gcc.compile.c : C : OBJ : gcc ; generators.register-c-compiler gcc.compile.asm : ASM : OBJ : gcc ; +generators.register + [ new pch-generator gcc.compile.pch : HPP : PCH : gcc ] ; # Declare flags and action for compilation flags gcc.compile OPTIONS off : -O0 ; @@ -124,7 +128,11 @@ flags gcc.compile DEFINES ; flags gcc.compile INCLUDES ; -rule compile.c++ +flags gcc.compile PCH_SOURCE ; +flags gcc.compile PCH_HEADER on : ; +flags gcc.compile PCH_FILE on : ; + +rule compile.c++ ( targets + : sources * : properties * ) { # Some extensions are compiled as C++ by default. For others, we need # to pass -x c++. @@ -132,16 +140,37 @@ if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C { LANG on $(<) = "-x c++" ; - } + } + DEPENDS $(<) : [ on $(<) return $(PCH_HEADER) ] ; + DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ; } -actions compile.c++ +actions compile.c++ bind PCH_HEADER PCH_FILE { - "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" + "$(CONFIG_COMMAND)" $(LANG) -include"$(PCH_FILE:W)" -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" } -rule compile.c +rule compile.pch ( targets + : sources * : properties * ) +{ + # Some extensions are compiled as C++ by default. For others, we need + # to pass -x c++. + # We could always pass -x c++ but distcc does not work with it. + if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C + { + LANG on $(<) = "-x c++" ; + } + + DEPENDS $(<) : [ on $(<) return $(PCH_HEADER) ] ; +} + +actions compile.pch bind PCH_SOURCE +{ + "$(CONFIG_COMMAND)" $(LANG) -x c++-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + + +rule compile.c ( targets + : sources * : properties * ) { # If we use the name g++ then default file suffix -> language mapping # does not work. So have to pass -x option. Maybe, we can work around this @@ -150,6 +179,10 @@ #{ LANG on $(<) = "-x c" ; #} + + DEPENDS $(<) : [ on $(<) return $(PCH_HEADER) ] ; + DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ; + }