Patch #1888 2007-02-16 18:53

dermeister

[ Feature Request #3129 ] 'clean' command line option
Download
1888-Feature_Reques.patch (3.5 KB)
Category
Application::FeatureAdd
Status
Accepted
Close date
2007-02-28 10:51
Assigned to
 
Index: src/src/app.h
===================================================================
--- src/src/app.h       (revision 3610)
+++ src/src/app.h       (working copy)
@@ -82,6 +82,7 @@
         bool m_BatchWindowAutoClose; // default: true
         bool m_Build;
         bool m_ReBuild;
+        bool m_Clean;
         bool m_HasProject;
         bool m_HasWorkSpace;
         bool m_NoSplash; // no splash screen
Index: src/src/app.cpp
===================================================================
--- src/src/app.cpp     (revision 3610)
+++ src/src/app.cpp     (working copy)
@@ -152,6 +152,7 @@
     { wxCMD_LINE_OPTION, _T(""), _T("profile"),  _T("synonym to personality"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_NEEDS_SEPARATOR },
     { wxCMD_LINE_SWITCH, _T(""), _T("rebuild"), _T("clean and then build the project/workspace"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
     { wxCMD_LINE_SWITCH, _T(""), _T("build"), _T("just build the project/workspace"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
+    { wxCMD_LINE_SWITCH, _T(""), _T("clean"), _T("clean the project/workspace"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
     { wxCMD_LINE_OPTION, _T(""), _T("target"),  _T("the target for the batch build"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_NEEDS_SEPARATOR },
     { wxCMD_LINE_SWITCH, _T(""), _T("no-batch-window-close"),  _T("do not auto-close log window when batch build is done"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
     { wxCMD_LINE_SWITCH, _T(""), _T("batch-build-notify"),  _T("show message when batch build is done"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
@@ -427,6 +428,7 @@
     m_BatchNotify = false;
     m_Build = false;
     m_ReBuild = false;
+    m_Clean = false;
     m_HasProject = false;
     m_HasWorkSpace = false;
 
@@ -582,10 +584,10 @@
 #endif
     if (m_pSingleInstance)
         delete m_pSingleInstance;
-       
+
        // ultimate shutdown...
        Manager::Free();
-    
+
     // WX docs say that this function's return value is ignored,
     // but we return our value anyway. It might not be ignored at some point...
     return m_Batch ? m_BatchExitCode : 0;
@@ -689,6 +691,17 @@
                compiler->BuildWorkspace(m_BatchTarget);
        }
     }
+    else if (m_Clean)
+    {
+       if(m_HasProject)
+       {
+               compiler->Clean(m_BatchTarget);
+       }
+       else if(m_HasWorkSpace)
+       {
+               compiler->CleanWorkspace(m_BatchTarget);
+       }
+    }
 
     // the batch build log might have been deleted in
     // CodeBlocksApp::OnBatchBuildDone().
@@ -833,7 +846,7 @@
 
                     // batch jobs
                     m_Batch = m_HasProject || m_HasWorkSpace;
-                    m_Batch = m_Batch && (m_Build || m_ReBuild);
+                    m_Batch = m_Batch && (m_Build || m_ReBuild || m_Clean);
                 }
                 else
                 {
@@ -857,10 +870,11 @@
                     m_BatchWindowAutoClose = !parser.Found(_T("no-batch-window-close"));
                     m_Build = parser.Found(_T("build"));
                     m_ReBuild = parser.Found(_T("rebuild"));
+                    m_Clean = parser.Found(_T("clean"));
                     parser.Found(_T("target"), &m_BatchTarget);
                     parser.Found(_T("script"), &m_Script);
                     // initial setting for batch flag (will be reset when ParseCmdLine() is called again).
-                    m_Batch = m_Build || m_ReBuild;
+                    m_Batch = m_Build || m_ReBuild || m_Clean;
                 }
             }
             break;
dermeister 2007-02-16 18:56

This patch implements feature request #3129 ('clean' command line option).

Drawback:

The batch-build window is not closed after cleaning the target has finished. This is because the compiler plugin generates no EVT_COMPILER_FINISHED event when it is called for cleaning the project. I'm not quite sure about how to solve that.