Boost logo

Boost-Build :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-11-18 04:02:35


Alex Besogonov wrote:
> Reece Dunn wrote:
>> This is a minor revision to correctly use :W where it is needed
>> (including some places in the previous response file changeover).
> I've just found another problem (minimal project attached). The problem
> is that *stupid* MSVC compiler thinks that the name given in /Yc or /Yu
> directive must be _exactly_ the same as the first #include statement.

Yeah, working with either the VC command line or solution files is very
hard to get right and easy to make mistakes. That's why I like BBv2 :).

> For example, if I have /Yc"..\subproject\stdafx.hpp" then VC will expect
> '#include "..\subproject\stdafx.hpp"' statement in stdafx.cpp and other
> files.

I have updated the patch to fix this issue. Thanks!

- Reece

Index: msvc.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/msvc.jam,v
retrieving revision 1.64
diff -u -r1.64 msvc.jam
--- msvc.jam 14 Nov 2005 15:15:06 -0000 1.64
+++ msvc.jam 17 Nov 2005 21:38:37 -0000
@@ -18,6 +18,7 @@
 import common ;
 import "class" : new ;
 import rc ;
+import pch ;
 
 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
 {
@@ -487,6 +488,9 @@
 generators.override msvc.compile.rc : rc.resource-compile ;
 generators.register-standard msvc.compile.asm : ASM : OBJ : <toolset>msvc ;
 
+generators.register
+ [ new pch-generator msvc.compile.pch : HPP : OBJ PCH : <toolset>msvc ] ;
+
 #
 # Declare flags and action for compilation
 #
@@ -537,15 +541,41 @@
 flags msvc.compile UNDEFS <undef> ;
 flags msvc.compile INCLUDES <include> ;
 
+flags msvc.compile PCH_SOURCE <pch-source> ;
+flags msvc.compile PCH_HEADER <pch>on : <pch-header> ;
+flags msvc.compile PCH_FILE <pch>on : <pch-file> ;
+
+rule compile.c ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(PCH_HEADER) ] ;
+ DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
+}
+
+rule compile.c++ ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(PCH_HEADER) ] ;
+ DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
+}
+
+rule compile.pch ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(PCH_SOURCE) ] ;
+}
+
 # The actions differ only by explicit selection of input language
-actions compile.c bind
+actions compile.c bind PCH_HEADER PCH_FILE
+{
+ $(.CC) /Zm800 -nologo -TC -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>:W)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" -Yu"$(PCH_HEADER:D=)" -Fp"$(PCH_FILE:W)"
+}
+
+actions compile.c++ bind PCH_HEADER PCH_FILE
 {
- $(.CC) /Zm800 -nologo -TC -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)"
+ $(.CC) /Zm800 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>:W)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" -Yu"$(PCH_HEADER:D=)" -Fp"$(PCH_FILE:W)"
 }
 
-actions compile.c++ bind
+actions compile.pch bind PCH_SOURCE
 {
- $(.CC) /Zm800 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)"
+ $(.CC) /Zm800 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(PCH_SOURCE:W)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" /Yc"$(>[1]:D=)" -Fp"$(<[2]:W)"
 }
 
 actions compile.rc


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk