Hello,
It is not relevant for many people, but there is something unexpected.
The "Compile single file" with makefile does not work.
To repreat the bug you have to create a HelloWorld project and apply this makefile.
main.o: main.c
mingw32-gcc.exe -Wall -O2 -c main.c -o main.o
HelloWorld.exe: main.o
mingw32-g++.exe -o HelloWorld.exe main.o -s
Then right click on file (main.c) to build this file. Codeblocks does not run makefile but run default compiler settings.
I discovered it when I was trying to implement another compiler in codeblocks. I am using codeblocks with PowerPC EABI compiler. I hope to share my compiller settings in the future, when I finished it.
Patch file that might fix the issue. I am way too tired to be sure this patch is correct.
Tim S.
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 9854)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -2903,10 +2903,29 @@
return -2;
}
if (m_pProject)
- wxSetWorkingDirectory(m_pProject->GetBasePath());
+ {
+ if ( UseMake(m_pProject) )
+ {
+ wxSetWorkingDirectory(m_pProject->GetExecutionDir());
+ return CompileFileWithMake(file, m_pProject, bt); // compile file using custom makefile
+ }
+ else
+ {
+ wxSetWorkingDirectory(m_pProject->GetBasePath());
+ }
+ }
return CompileFileDefault(m_pProject, pf, bt); // compile file using default build system
}
+int CompilerGCC::CompileFileWithMake(const wxString& file, cbProject* project, ProjectBuildTarget* bt)
+{
+ wxString cmd = GetMakeCommandFor(mcCompileFile, project, bt);
+ cmd.Replace(_T("$file"), file);
+ m_CommandQueue.Add(new CompilerCommand(cmd, wxEmptyString, project, bt));
+
+ return DoRunQueue();
+}
+
int CompilerGCC::CompileFileWithoutProject(const wxString& file)
{
// compile single file not belonging to a project
Index: src/plugins/compilergcc/compilergcc.h
===================================================================
--- src/plugins/compilergcc/compilergcc.h (revision 9854)
+++ src/plugins/compilergcc/compilergcc.h (working copy)
@@ -115,6 +115,7 @@
virtual int RebuildWorkspace(const wxString& target = wxEmptyString);
virtual int CompileFile(const wxString& file);
virtual int CompileFileWithoutProject(const wxString& file);
+ virtual int CompileFileWithMake(const wxString& file, cbProject* project, ProjectBuildTarget* bt);
virtual int CompileFileDefault(cbProject* project, ProjectFile* pf, ProjectBuildTarget* bt);
virtual int KillProcess();
virtual bool IsRunning() const;