Board index » cppbuilder » improved PCH support - WAS: parallel bcc32 build tool
Andreas Hausladen
CBuilder Developer |
improved PCH support - WAS: parallel bcc32 build tool2005-08-28 04:34:30 AM cppbuilder0 While adding bcc32 support to Qt 4.0.1 I developed a little tool that makes PCH usage a lot easier and more powerfull. msvc can "force include" a header file. This is used by Qt4 to include a precompiled header set. bcc32 does not offer such a command line switch so you always have to add lines like #include <my_pch.h> #pragma hdrstop" to every file. The bcc32pch tool now injects this PCH code into every file during compilation and recompiled the PCH if change something in one of the included headers. See borland.public.attachment How to use bcc32pch: 1. Create a new header file "myproject_pch.h" and include in that file every header you want to have precompiled (be carefull with "code in header", "initialized data found"). 2. Export your project to a makefile (bpr2mak) 3. Replace the "BCC32 = bcc32" by "BCC32 = bcc32pch -pch=myproject_pch.h" 4. Start make and see the compilation boost. How it works: bcc32pch uses the specified PCH file (-pch=filename_pch.h) to generate a precompiled header file. First it create a new .cpp that contains the PCH inclusion code #include "filename_pch.h" #pragma hdrstop #line 1 "filename.cpp" and compiles it with "create precompiled headers". This file is deleted after the compilation. Now it preprocesses all specified files by renaming them to filename.cpp_original.cpp and writing a new filename.cpp file with the injected PCH inclusion code. After that the compiler is started with "use precompiled headers". After all files are compiled or an error occured the original files are restored. The generated PCH is stored to the directory that is specified by the -nDirectory or -oPath\Filename.obj command line switch. If neight -n nor -o is available it puts the file to the PCH header file. Because the regeneration of the PCH is time consuming the bcc32pch tool reads the dependency information of the PCH generated .obj file. This allows bcc32pch to recompile the PCH if one header file has changed. (also headers which are included be included headers, ...) If you specify the -H="filename.csm" parameter bcc32pch will use this filename for it's PCH file. -- Regards, Andreas Hausladen (andy.jgknet.de/blog) |