Author Topic: Quick and Dirty way to compile CB using wxMSW without using PCH  (Read 6674 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
FYI:

This thread covers a quick and dirty method to compile Code::Blocks without using Pre-Compiled Headers.

1. Install sed from GnuWin32 http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=16429
2. Run sed-noPCH.bat
3. Compile CodeBlocks-noPCH.cbp
4. ContribPlugins-noPCH.workspace

Note: Steps 3 and 4 can be replaced with just compiling the project_name-noPCH.cbp you are testing.

Tim S

sed-noPCH.bat updated 2007-06-12

This is an smaller version that only replaces the defines of CB_PRECOMP, WX_PRECOMP and USE_PCH with that of NOPCH.
And, changes envvars.cbp to use no_pch target for All.

Code
SET PATH=C:\Program Files\GnuWin32\bin

REM Change Virtual Target All to no_pch
sed "s/Add alias=\"All\" targets=\"default;\"/Add alias=\"All\" targets=\"no_pch;\"/g" src\plugins\contrib\envvars\envvars.cbp  > src\plugins\contrib\envvars\envvars-noPCH.cbp

REM
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\CodeBlocks.cbp                                  | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\CodeBlocks-noPCH.cbp

sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\tools\cb_share_config\cb_share_config.cbp       | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\tools\cb_share_config\cb_share_config-noPCH.cbp

REM
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\byogames\byogames.cbp           | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\byogames\byogames-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\cb_koders\cb_koders.cbp         | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\cb_koders\cb_koders-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\codesnippets\codesnippets.cbp   | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\codesnippets\codesnippets-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\codestat\codestat.cbp           | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\codestat\codestat-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\copystrings\copystrings.cbp     | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\copystrings\copystrings-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\devpak_plugin\DevPakPlugin.cbp  | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\devpak_plugin\DevPakPlugin-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\dragscroll\dragscroll.cbp       | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\dragscroll\dragscroll-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\help_plugin\help-plugin.cbp     | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\help_plugin\help-plugin-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\keybinder\keybinder.cbp         | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\keybinder\keybinder-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\lib_finder\lib_finder.cbp       | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\lib_finder\lib_finder-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\profiler\cbprofiler.cbp         | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\profiler\cbprofiler-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\source_exporter\Exporter.cbp    | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\source_exporter\Exporter-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\symtab\symtab.cbp               | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\symtab\symtab-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\regex_testbed\RegExTestbed.cbp  | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\regex_testbed\RegExTestbed-noPCH.cbp
sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\wxSmith\wxSmith.cbp             | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\wxSmith\wxSmith-noPCH.cbp

sed "s/Add option=\"-DCB_PRECOMP\"/Add option=\"-DNOPCH\"/g" src\plugins\contrib\wxSmithContribItems\wxSmithContribItems.cbp | sed "s/Add option=\"-DWX_PRECOMP\"/Add option=\"-DNOPCH\"/g" | sed "s/Add option=\"-DUSE_PCH\"/Add option=\"-DNOPCH\"/g" > src\plugins\contrib\wxSmithContribItems\wxSmithContribItems-noPCH.cbp

:_end

PAUSE

ContribPlugins-noPCH.workspace
Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_workspace_file>
<Workspace title="All contrib plugins wxWidgets28">
<Project filename="plugins\contrib\byogames\byogames-noPCH.cbp" active="1" />
<Project filename="plugins\contrib\cb_koders\cb_koders-noPCH.cbp" />
<Project filename="plugins\contrib\codesnippets\codesnippets-noPCH.cbp" />
<Project filename="plugins\contrib\codestat\codestat-noPCH.cbp" />
<Project filename="plugins\contrib\copystrings\copystrings-noPCH.cbp" />
<Project filename="plugins\contrib\devpak_plugin\DevPakPlugin-noPCH.cbp" />
<Project filename="plugins\contrib\dragscroll\dragscroll-noPCH.cbp" />
<Project filename="plugins\contrib\envvars\envvars-noPCH.cbp" />
<Project filename="plugins\contrib\help_plugin\help-plugin-noPCH.cbp" />
<Project filename="plugins\contrib\keybinder\keybinder-noPCH.cbp" />
<Project filename="plugins\contrib\lib_finder\lib_finder-noPCH.cbp" />
<Project filename="plugins\contrib\profiler\cbprofiler-noPCH.cbp" />
<Project filename="plugins\contrib\source_exporter\Exporter-noPCH.cbp" />
<Project filename="plugins\contrib\symtab\symtab-noPCH.cbp" />
<Project filename="plugins\contrib\regex_testbed\RegExTestbed-noPCH.cbp" />
<Project filename="plugins\contrib\wxSmith\wxSmith-noPCH.cbp" />
<Project filename="plugins\contrib\wxSmithContribItems\wxSmithContribItems-noPCH.cbp" />
<Project filename="tools\cb_share_config\cb_share_config-noPCH.cbp" />
</Workspace>
</CodeBlocks_workspace_file>
« Last Edit: June 13, 2007, 02:20:45 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Quick and Dirty way to compile CB using wxMSW without using PCH
« Reply #1 on: May 11, 2007, 12:19:21 am »
Patch file for Code::Blocks core

from docs/tech/tn0019.txt
Quote
In no event should the Windows headers such as <windows.h> or <commctrl.h> be
included directly. So instead of #include <...> use "wx/msw/wrapwin.h" or
"wx/msw/wrapcctl.h".
I consider the above to mean any code using wxWidgets Libraries should also obey the above rule. 

noPCH_Core-unix.patch
[ Patch #1992 ] Enable CB build using wxMSW without PCH
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1992&group_id=5358
Code
Index: src/sdk/globals.cpp
===================================================================
--- src/sdk/globals.cpp (revision 3942)
+++ src/sdk/globals.cpp (working copy)
@@ -624,7 +624,8 @@
 // function to check the common controls version
 // (should it be moved in sdk globals?)
 #ifdef __WXMSW__
-#include <windows.h>
+// includes windows.h but wraps it to prevent errors per wxWidgets tech note tn0019.txt
+#include <wx/msw/wrapwin.h>
 #include <shlwapi.h>
 bool UsesCommonControls6()
 {
Index: src/sdk/infowindow.cpp
===================================================================
--- src/sdk/infowindow.cpp (revision 3942)
+++ src/sdk/infowindow.cpp (working copy)
@@ -6,6 +6,8 @@
     #include <wx/sizer.h>
     #include <wx/settings.h>
     #include <wx/statbmp.h>
+    #include <wx/frame.h>
+    #include <wx/panel.h>   
     #include "infowindow.h"
     #include "manager.h"
 #endif
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp (revision 3942)
+++ src/sdk/editormanager.cpp (working copy)
@@ -32,6 +32,7 @@
     #include <wx/splitter.h>
     #include <wx/imaglist.h>
     #include <wx/regex.h>
+    #include <wx/listctrl.h>
 
     #include "editormanager.h" // class's header file
     #include "configmanager.h"
Index: src/plugins/debuggergdb/breakpointsdlg.cpp
===================================================================
--- src/plugins/debuggergdb/breakpointsdlg.cpp (revision 3942)
+++ src/plugins/debuggergdb/breakpointsdlg.cpp (working copy)
@@ -1,4 +1,7 @@
 #include <sdk.h>
+#ifndef CB_PRECOMP
+#   include <wx/listctrl.h>
+#endif
 #include "breakpointsdlg.h"
 #include <manager.h>
 #include <editormanager.h>
Index: src/plugins/debuggergdb/debugger_defs.cpp
===================================================================
--- src/plugins/debuggergdb/debugger_defs.cpp (revision 3942)
+++ src/plugins/debuggergdb/debugger_defs.cpp (working copy)
@@ -2,6 +2,7 @@
 #ifndef CB_PRECOMP
 #include <wx/dialog.h>
 #include <wx/font.h>
+#include <wx/frame.h>
 #include <wx/sizer.h>
 #include <wx/textctrl.h>
 #include "manager.h"
Index: src/plugins/debuggergdb/debuggerdriver.h
===================================================================
--- src/plugins/debuggergdb/debuggerdriver.h (revision 3942)
+++ src/plugins/debuggergdb/debuggerdriver.h (working copy)
@@ -1,6 +1,12 @@
 #ifndef DEBUGGERDRIVER_H
 #define DEBUGGERDRIVER_H
 
+#ifndef WX_PRECOMP
+#   ifdef __WXMSW__
+#       include <wx/msw/wrapwin.h>  // Needed to prevent GetCommandLine define bug.
+#   endif
+#endif
+
 #include "debugger_defs.h"
 #include <wx/regex.h>
 #include <globals.h>
Index: src/plugins/debuggergdb/gdb_driver.cpp
===================================================================
--- src/plugins/debuggergdb/gdb_driver.cpp (revision 3942)
+++ src/plugins/debuggergdb/gdb_driver.cpp (working copy)
@@ -9,7 +9,8 @@
 
 #ifdef __WXMSW__
 // for Registry detection of Cygwin
-#include <windows.h>
+// includes windows.h but wraps it to prevent errors per wxWidgets tech note tn0019.txt
+#include <wx/msw/wrapwin.h>
 #endif
 
 #include <wx/arrimpl.cpp> // this is a magic incantation which must be done!
Index: src/plugins/compilergcc/compilergcc.h
===================================================================
--- src/plugins/compilergcc/compilergcc.h (revision 3942)
+++ src/plugins/compilergcc/compilergcc.h (working copy)
@@ -16,6 +16,7 @@
 #include "compiler_defs.h"
 #include <compilerfactory.h>
 #include <wx/timer.h>
+#include <wx/gauge.h>
 
 #define MAX_TARGETS 128
 
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 3942)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -25,6 +25,9 @@
 */
 
 #include <sdk.h>
+#ifndef CB_PRECOMP
+#   include <wx/listctrl.h>
+#endif
 #include "prep.h"
 #include "compilergcc.h"
 #include <manager.h>
Index: src/plugins/compilergcc/compilerOWgenerator.cpp
===================================================================
--- src/plugins/compilergcc/compilerOWgenerator.cpp (revision 3942)
+++ src/plugins/compilergcc/compilerOWgenerator.cpp (working copy)
@@ -1,6 +1,12 @@
 #ifdef __WXMSW__ // For Windows Only
 
 #include <sdk.h>
+#ifndef CB_PRECOMP
+#   include "compiler.h"
+#   include "cbproject.h"
+#   include "projectbuildtarget.h"
+#   include "messagemanager.h"
+#endif
 #include "compileoptionsbase.h"
 #include "compilerOWgenerator.h"
 
Index: src/include/manager.h
===================================================================
--- src/include/manager.h (revision 3942)
+++ src/include/manager.h (working copy)
@@ -9,6 +9,12 @@
 #ifndef MANAGER_H
 #define MANAGER_H
 
+#ifndef WX_PRECOMP
+#   ifdef __WXMSW__
+#       include <wx/msw/wrapwin.h>  // Needed to prevent Yield define bug.
+#   endif
+#endif
+
 #include <wx/event.h>
 #include <wx/cmdline.h>
 #include "settings.h"
Index: src/include/newfromtemplatedlg.h
===================================================================
--- src/include/newfromtemplatedlg.h (revision 3942)
+++ src/include/newfromtemplatedlg.h (working copy)
@@ -8,6 +8,7 @@
 
 class wxChoice;
 class wxListCtrl;
+class wxListEvent;
 class ProjectTemplateLoader;
 
 class NewFromTemplateDlg : public wxDialog
Index: src/include/replacedlg.h
===================================================================
--- src/include/replacedlg.h (revision 3942)
+++ src/include/replacedlg.h (working copy)
@@ -1,6 +1,10 @@
 #ifndef REPLACEDLG_H
 #define REPLACEDLG_H
 
+#ifndef CB_PRECOMP
+    #include <wx/notebook.h>
+#endif
+
 #include "findreplacebase.h"
 
 class wxComboBox;
Index: src/src/associations.h
===================================================================
--- src/src/associations.h (revision 3942)
+++ src/src/associations.h (working copy)
@@ -10,7 +10,8 @@
  #define DDE_SERVICE _T("CODEBLOCKS")
  #define DDE_TOPIC _T("CodeBlocksDDEServer")
  #ifdef __CBDEBUG__
-        #include <windows.h>
+        // includes windows.h but wraps it to prevent errors per wxWidgets tech note tn0019.txt
+        #include <wx/msw/wrapwin.h>
         #include <wincon.h>
         #include <wx/log.h>
  #endif
« Last Edit: May 11, 2007, 01:58:51 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Quick and Dirty way to compile CB using wxMSW without using PCH
« Reply #2 on: May 11, 2007, 12:20:13 am »
Patch files for Code::Blocks contribs

3 patches

[ Patch #1993 ] Enable Keybinder build using wxMSW without PCH
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1993&group_id=5358


[ Patch #1994 ] Enable wxSmith build using wxMSW without PCH
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1994&group_id=5358


[ Patch #1995 ] Enable codesnippets build using wxMSW without PCH
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1995&group_id=5358


« Last Edit: June 04, 2007, 10:53:44 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Quick and Dirty way to compile CB using wxMSW without using PCH
« Reply #3 on: June 04, 2007, 10:44:27 pm »
Patch for wxSmith applied :)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Quick and Dirty way to compile CB using wxMSW without using PCH
« Reply #4 on: June 04, 2007, 10:54:36 pm »
Patch for wxSmith applied :)

Thanks, that will make it easier for me to test my remaining patches.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org