|
Boost-Build : |
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-11-17 04:32:36
Vladimir Prus wrote:
> On Thursday 17 November 2005 00:33, Reece Dunn wrote:
> Try adding "bind PCH_FILE" right afet "actions compile". FWIW, in
> http://boost.org/boost-build2/doc/html/bbv2/extending/features.html, there's
> a complete example of adding an dependency feature, in that case, <def-file>.
>
>> 1. How do I resolve the "<p.>pch.hpp" to an actual path?
>> $(sources[2]).actualize doesn't work (problem with
>> foo.actualize.actualize).
>
> Hopefully explained above.
Yes. That has fixed the above problem.
>> 2. Is it possible to get the target name for the PCH target? I took a
>> look at generator.jam and the target calculation looks complex!
>
> Where do you want to get, and what exactly do you want to get? Jam's target
> name or a file name, or what?
I have attached what I have done so far. This allows:
pch mypch : pch.cpp pch.hpp ;
exe hello
:
main.cpp demo.cpp mypch
;
But I now get:
msvc.compile.pch ..\..\..\build\tools\pch\msvc-7.1\release\mypch.obj
..\..\..\build\tools\pch\msvc-7.1\release\mypch.pch
pch.hpp
msvc.compile.c++ ..\..\..\build\tools\pch\msvc-7.1\release\main.obj
main.cpp
main.cpp(1) : fatal error C1083: Cannot open precompiled header file:
'pch.pch':
No such file or directory
call "C:\Program Files\Microsoft Visual Studio .NET
2003\vc7\bin\vcvars32.bat" >nul
cl /Zm800 -nologo -TP /O2 /Ob2 /W4 /GR /MD /DWIN32 /DX86 /D_X86_
/Zc:forScope /Zc:wchar_t /Wp64 /Ogiy /Gs /Ot /GB /wd4675 /EHs
@"..\..\..\build\tools\pch\msvc-7.1\release\main.obj.rsp" -c
-Fo"..\..\..\build\tools\pch\msvc-7.1\release\main.obj" -Yu"pch.hpp"
...failed msvc.compile.c++
..\..\..\build\tools\pch\msvc-7.1\release\main.obj...
The problem is that you need to add
-Fp"..\..\..\build\tools\pch\msvc-7.1\release\mypch.pch"
to the compile action. This is what the:
flags msvc.compile PCH_FILE <pch>on : <use-pch-file> ;
is for. (The other one, I have renamed PCH_HEADER). So I need to add
<use-pch-file> to the list of properties when evaluating the pch rule.
Thus the commented out:
return
[ property-set.create
<use-pch-header>$(sources[2])
#<use-pch-file>$(targets[2]) # <== HERE
] $(r) ;
in the pch-generator.run rule.
- 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 09:20:01 -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,33 @@
flags msvc.compile UNDEFS <undef> ;
flags msvc.compile INCLUDES <include> ;
+flags msvc.compile PCH_HEADER <pch>on : <use-pch-header> ;
+flags msvc.compile PCH_FILE <pch>on : <use-pch-file> ;
+
+rule compile.c ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(PCH_HEADER) ] ;
+}
+
+rule compile.c++ ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(PCH_HEADER) ] ;
+}
+
# The actions differ only by explicit selection of input language
-actions compile.c bind
+actions compile.c bind PCH_HEADER
+{
+ $(.CC) /Zm800 -nologo -TC -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" -Yu"$(PCH_HEADER)" -Fp"$(PCH_FILE)"
+}
+
+actions compile.c++ bind PCH_HEADER
{
- $(.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)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" -Yu"$(PCH_HEADER)" -Fp"$(PCH_FILE)"
}
-actions compile.c++ bind
+actions compile.pch
{
- $(.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)"$(>[1])" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1])" -Yc"$(>[2])" -Fp"$(<[2])"
}
actions compile.rc
# Copyright (C) Reece H. Dunn 2005.
#
# 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 ;
# We have the ability to create, use and not use PCH files. That is:
# *.cpp/<pch>off -- don't use PCH
# *.cpp/<pch>on -- use PCH, if supported by the compiler
# pch pchdr : pch.hpp ; -- create PCH from pch.hpp
type.register PCH : pch ;
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 use-pch-header : : free dependency ; # mypch.hpp
feature use-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 run ( project name ? : property-set : sources * )
{
local r = [ generator.run $(project) $(name) : $(property-set) : $(sources) ] ;
return
[ property-set.create
<use-pch-header>$(sources[2])
#<use-pch-file>$(targets[2])
] $(r) ;
}
}
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