Patch #922 2006-03-13 21:20

yop

Added distclean for custom makefile projects
Download
922-Added_distclean.patch (3.2 KB)
Category
Plugin::FeatureAdd
Status
Accepted
Close date
2006-03-22 13:13
Assigned to
 
Index: src/sdk/cbplugin.h
===================================================================
--- src/sdk/cbplugin.h    (revision 2189)
+++ src/sdk/cbplugin.h    (working copy)
@@ -234,6 +234,19 @@
         /** Same as Clean(ProjectBuildTarget*) but with a wxString argument. */
         virtual int Clean(const wxString& target) = 0;
 
+        /** @brief DistClean the project/target.
+          *
+          * DistClean will typically remove any config files
+          * and anything else that got created as part of
+          * building a software package.
+          *
+          * @param target The specific build target to "distclean". If NULL, it
+          * cleans all the build targets of the current project.
+          */
+        virtual int DistClean(ProjectBuildTarget* target = 0L) = 0;
+        /** Same as DistClean(ProjectBuildTarget*) but with a wxString argument. */
+        virtual int DistClean(const wxString& target) = 0;
+
         /** @brief Build the project/target.
           *
           * @param target The specific build target to build. If NULL, it
Index: src/plugins/compilergcc/compilergcc.h
===================================================================
--- src/plugins/compilergcc/compilergcc.h    (revision 2189)
+++ src/plugins/compilergcc/compilergcc.h    (working copy)
@@ -67,6 +67,8 @@
         virtual int RunSingleFile(const wxString& filename);
         virtual int Clean(ProjectBuildTarget* target = 0L);
         virtual int Clean(const wxString& target);
+        virtual int DistClean(ProjectBuildTarget* target = 0L);
+        virtual int DistClean(const wxString& target);
         virtual int Build(ProjectBuildTarget* target = 0L);
         virtual int Build(const wxString& target);
         virtual int Rebuild(ProjectBuildTarget* target = 0L);
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp    (revision 2189)
+++ src/plugins/compilergcc/compilergcc.cpp    (working copy)
@@ -1590,6 +1590,43 @@
     return 0;
 }
 
+int CompilerGCC::DistClean(const wxString& target)
+{
+    if (!CheckProject())
+        return -1;
+    return DistClean(m_Project->GetBuildTarget(target.IsEmpty() ? m_LastTargetName : target));
+}
+
+int CompilerGCC::DistClean(ProjectBuildTarget* target)
+{
+    // make sure all project files are saved
+    if (m_Project && !m_Project->SaveAllFiles())
+        Manager::Get()->GetMessageManager()->Log(_("Could not save all files..."));
+
+    DoPrepareQueue();
+    if (!CompilerValid(target))
+        return -1;
+
+//    Manager::Get()->GetMacrosManager()->Reset();
+
+    if (m_Project)
+        wxSetWorkingDirectory(m_Project->GetBasePath());
+    CompilerFactory::GetCompiler(m_CompilerId)->Init(m_Project);
+
+    if (UseMake(target))
+    {
+        wxString cmd = GetMakeCommandFor(mcDistClean, target);
+        m_CommandQueue.Add(new CompilerCommand(cmd, wxEmptyString, m_Project, target));
+        return DoRunQueue();
+    }
+    else
+    {
+        NotImplemented(_T("CompilerGCC::Distclean() without a custom Makefile"));
+        return -1;
+    }
+    return 0;
+}
+
 void CompilerGCC::OnExportMakefile(wxCommandEvent& event)
 {
     cbMessageBox(_("This functionality has been temporarily removed from Code::Blocks.\n"
yop 2006-03-13 21:30

This is more like a feature request.

What it does: it adds support for distcleaning a project / target that uses custom Makefiles. The gui hasn't changed at all (it is easy to but I didn't want to mess up with more than the absolutely necessary). Support for distcleaning using the C::B build system isn't necessery as it would be exactly the same as clean (no autogenerated files etc.) but since I've been working with the Qt plugin, the only way to switch compilers for a project that has already been built is distcleaning it. I see that there is an option to specify the distclean commands in the target/project build options but distcleaning wasn't supported by the actual plugin. Also mcDistClean is also there so I guess it is something that was in your mind but never got developed.