Hope someone think it is useful.
I build CodeBlocks_wx30.cbp with GCC 4.7.x from MinGW-Build. It should be faster than the default NON-PCH build.
From 58489f50025bdca99d848facce0a849a2ae592ee Mon Sep 17 00:00:00 2001
From: asmwarrior <>
Date: Mon, 20 Jan 2014 14:16:02 +0800
Subject: [PATCH] * build against wx 3.0 with PCH enabled.
---
src/CodeBlocks_wx30.cbp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/CodeBlocks_wx30.cbp b/src/CodeBlocks_wx30.cbp
index 3443619..b5265fe 100644
--- a/src/CodeBlocks_wx30.cbp
+++ b/src/CodeBlocks_wx30.cbp
@@ -727,11 +727,13 @@
<Add option="-mthreads" />
<Add option="-fmessage-length=0" />
<Add option="-fexceptions" />
+ <Add option="-Winvalid-pch" />
<Add option="-DHAVE_W32API_H" />
<Add option="-D__WXMSW__" />
<Add option="-DWXUSINGDLL" />
<Add option="-DcbDEBUG" />
- <Add option="-DNOPCH" />
+ <Add option="-DCB_PRECOMP" />
+ <Add option="-DWX_PRECOMP" />
<Add option="-DwxUSE_UNICODE" />
<Add directory="$(#WX30.include)" />
<Add directory="$(#WX30.lib)/gcc_dll$(WX_CFG)/msw$(WX_SUFFIX)" />
@@ -1280,6 +1282,7 @@
<Option target="sdk" />
</Unit>
<Unit filename="include/sdk.h">
+ <Option compile="1" />
<Option weight="1" />
<Option target="src" />
</Unit>
@@ -1290,6 +1293,7 @@
<Option target="sdk" />
</Unit>
<Unit filename="include/sdk_precomp.h">
+ <Option compile="1" />
<Option weight="0" />
<Option target="sdk" />
</Unit>
--
1.8.5.2.msysgit.0
NOTE: GCC 4.8.x should be avoid if you want to build C::B with PCH enabled under Windows.
The main PCH fix thing that needs done is in this one; just adding the object directory to the Contrib Projects will allow the Contrib use PCH.
Do the Contrib Plugins under Windows really use a PCH version of sdk.h? (http://forums.codeblocks.org/index.php/topic,18553.msg126983.html#msg126983)
I apply the git patch, and I see that building Games plugin now from 22 seconds(before patch) to 7 seconds(after patch). Nice result. :)
I also see that when building FileManager Plugin, there is no time reducing before and after the patch, I'm not sure why.
I haven't tested other plugin yet, but I see it does improve the build performance.
Edit2: Attach Git Patch to add the obj search to cbp and a single sdk_precomp.h to sdk.h fix.
I think we should always use sdk.h, not sdk_precomp.h when building non-sdk target.
Q1: what is better?
or
?
Q2: When I build CodeCompletion plugin, I see such command
[ 6.3%] g++.exe -Wall -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE -DBUILDING_PLUGIN -iquote.objs\include -I.objs\include -I. -IE:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\include -IE:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\mswu -Isdk\wxscintilla\include -Isdk\wxpropgrid\include -Iinclude\tinyxml -Iinclude -Iinclude\mozilla_chardet -Iinclude\mozilla_chardet\mfbt -Iinclude\mozilla_chardet\nsprpub\pr\include -Iinclude\mozilla_chardet\xpcom -Iinclude\mozilla_chardet\xpcom\base -Iinclude\mozilla_chardet\xpcom\glue -c plugins\codecompletion\ccoptionsdlg.cpp -o .objs\plugins\codecompletion\ccoptionsdlg.o
Note, there is: -iquote.objs\include
But I see the command when build FileManager Plugin
[ 14.3%] g++.exe -Wall -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -DWXUSINGDLL -DHAVE_W32API_H -D__WXMSW__ -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE -DBUILDING_PLUGIN -g -I..\..\..\.objs\include -I..\..\..\include -I..\..\..\sdk\wxscintilla\include -I..\..\..\include\mozilla_chardet -I..\..\..\include\mozilla_chardet\mfbt -I..\..\..\include\mozilla_chardet\nsprpub\pr\include -I..\..\..\include\mozilla_chardet\xpcom -I..\..\..\include\mozilla_chardet\xpcom\base -I..\..\..\include\mozilla_chardet\xpcom\glue -IE:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\include -IE:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\mswu -c directorymonitor.cpp -o ..\..\..\.objs\plugins\contrib\FileManager\directorymonitor.o
Why there is no -iquote?
Q3: what does the below statement mean? I don't see the change in wxContrib from your git patch.
The wxContrib changes the build objects NOT the PCH; but, it really speeds it up.
FYI:
I found a quick way too see if Contrib Plugins would be improved by adding PCH headers like sdk.h to them.
Found out about it on gcc help page on gch/PCH stuff. http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html (http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html)
Edit: Changed devpak_plugin from 25 seconds to 16 seconds for me to build.
NOTE: If the CB Project includes the PCH file inside source folders it errors out.
So, only good to check projects NOT including sdk.h
Tim S.
Index: src/plugins/contrib/devpak_plugin/DevPakPlugin.cbp
===================================================================
--- src/plugins/contrib/devpak_plugin/DevPakPlugin.cbp (revision 9602)
+++ src/plugins/contrib/devpak_plugin/DevPakPlugin.cbp (working copy)
@@ -42,6 +42,8 @@
<Add option="-DWXUSINGDLL" />
<Add option="-DcbDEBUG" />
<Add option="-DwxUSE_UNICODE" />
+ <Add option="-include sdk.h" />
+ <Add directory="..\..\..\.objs\include" />
<Add directory="..\..\..\include" />
</Compiler>
<Linker>
The patch I am testing. I do NOT think "src/include/xtra_res.h" needs patched.
But, I am only testing with that for now; looking for compile errors because "wx/wxprec.h" was NOT included.
If I don't find any I will test the patch without changing "src/include/xtra_res.h".
Tim S.
Index: src/CodeBlocks_wx30.cbp
===================================================================
--- src/CodeBlocks_wx30.cbp (revision 9615)
+++ src/CodeBlocks_wx30.cbp (working copy)
@@ -731,7 +731,7 @@
<Add option="-D__WXMSW__" />
<Add option="-DWXUSINGDLL" />
<Add option="-DcbDEBUG" />
- <Add option="-DNOPCH" />
+ <Add option="-DCB_PRECOMP" />
<Add option="-DwxUSE_UNICODE" />
<Add directory="$(#WX30.include)" />
<Add directory="$(#WX30.lib)/gcc_dll$(WX_CFG)/msw$(WX_SUFFIX)" />
@@ -1280,6 +1280,7 @@
<Option target="sdk" />
</Unit>
<Unit filename="include/sdk.h">
+ <Option compile="1" />
<Option weight="1" />
<Option target="src" />
</Unit>
@@ -1290,6 +1291,7 @@
<Option target="sdk" />
</Unit>
<Unit filename="include/sdk_precomp.h">
+ <Option compile="1" />
<Option weight="0" />
<Option target="sdk" />
</Unit>
Index: src/include/sdk_common.h
===================================================================
--- src/include/sdk_common.h (revision 9615)
+++ src/include/sdk_common.h (working copy)
@@ -28,16 +28,26 @@
#if ( defined(CB_PRECOMP) && !defined(WX_PRECOMP) )
#define WX_PRECOMP
+ #ifdef __MINGW32__
+ #if __GNUC__ == 4 && __GNUC_MINOR__ >= 8
+ #include <wx/version.h>
+ #if wxMAJOR_VERSION == 3
+ #undef WX_PRECOMP
+ #endif // wxMAJOR_VERSION
+ #endif // __GNUC__
+ #endif // __MINGW32__
#endif // CB_PRECOMP
// basic wxWidgets headers : this one itself will check for precompiled headers
// and if so will include a list of wx headers, at the bottom we add some more headers
// in the case of precompilation (note : some headers are in both lists)
// so even if NO CB_PRECOMP we can still have WX_PRECOMP turned on in this "wxprec" header
-#include <wx/wxprec.h>
+#ifdef WX_PRECOMP
+ #include <wx/wxprec.h>
-#ifdef __BORLANDC__
- #pragma hdrstop
+ #ifdef __BORLANDC__
+ #pragma hdrstop
+ #endif
#endif
#include "prep.h" // this is deliberately not inside the #ifdef block
Index: src/include/xtra_res.h
===================================================================
--- src/include/xtra_res.h (revision 9615)
+++ src/include/xtra_res.h (working copy)
@@ -6,16 +6,11 @@
#ifndef XTRA_RES_H
#define XTRA_RES_H
-#include <wx/wxprec.h>
#include <wx/xrc/xmlres.h>
#include <wx/xrc/xh_dlg.h>
#include <wx/toolbar.h>
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
class wxXmlResourceHandler;
class wxToolBarAddOnXmlHandler : public wxXmlResourceHandler
is this now standard in wx3.0 projects? Because i try to compile my sqrat port with wx3.0, but i get wired:
sc_consts.cpp|55|error: 'PLUGIN_SDK_VERSION_MAJOR' was not declared in this scope
and there is no special difference between the normal and this project file...
is this now standard in wx3.0 projects? Because i try to compile my sqrat port with wx3.0, but i get wired:
sc_consts.cpp|55|error: 'PLUGIN_SDK_VERSION_MAJOR' was not declared in this scope
and there is no special difference between the normal and this project file...
Patch that should fix it.
Index: src/sdk/scripting/bindings/sc_consts.cpp
===================================================================
--- src/sdk/scripting/bindings/sc_consts.cpp (revision 9659)
+++ src/sdk/scripting/bindings/sc_consts.cpp (working copy)
@@ -10,6 +10,8 @@
#include <sdk_precomp.h>
#ifndef CB_PRECOMP
#include <wx/string.h>
+
+ #include <cbplugin.h>
#include <globals.h>
#include <settings.h>
#endif