ide:Project/Makefile: added realclean feature making use of realclean makefile target...
authorRejean Loyer <rejean.loyer@gmail.com>
Mon, 19 Mar 2012 05:44:14 +0000 (01:44 -0400)
committerRejean Loyer <rejean.loyer@gmail.com>
Tue, 20 Mar 2012 02:41:13 +0000 (22:41 -0400)
ide/src/ide.ec
ide/src/project/Project.ec
ide/src/project/ProjectView.ec

index a70a62a..5f03a2c 100644 (file)
@@ -218,7 +218,7 @@ class IDEToolbar : ToolBar
    // Undo
    // Redo
 
-   //ToolSeparator separator2 { this };
+   // ToolSeparator separator2 { this };
 
    /* Project  options */
    // New project
@@ -228,7 +228,7 @@ class IDEToolbar : ToolBar
    // Add project to workspace
    ToolButton buttonAddProject { this, toolTip = $"Add project to workspace", menuItemPtr = IDEItem(projectAddItem), disabled = true; };
    // Close project
-   //ToolButton buttonCloseProject { this, toolTip = $"Close project", menuItemPtr = IDEItem(projectCloseItem), disabled = true; };
+   // ToolButton buttonCloseProject { this, toolTip = $"Close project", menuItemPtr = IDEItem(projectCloseItem), disabled = true; };
 
    ToolSeparator separator3 { this };
 
@@ -241,6 +241,8 @@ class IDEToolbar : ToolBar
    ToolButton buttonRebuild { this, toolTip = $"Rebuild project", menuItemPtr = IDEItem(projectRebuildItem), disabled = true; };
    // Clean
    ToolButton buttonClean { this, toolTip = $"Clean project", menuItemPtr = IDEItem(projectCleanItem), disabled = true; };
+   // Real Clean
+   // ToolButton buttonRealClean { this, toolTip = $"Real clean project", menuItemPtr = IDEItem(projectRealCleanItem), disabled = true; };
    // Regenerate Makefile
    ToolButton buttonRegenerateMakefile { this, toolTip = $"Regenerate Makefile", menuItemPtr = IDEItem(projectRegenerateItem), disabled = true; };
    // Compile actual file
@@ -937,6 +939,20 @@ class IDEWorkSpace : Window
             return true;
          }
       }
+      MenuItem projectRealCleanItem
+      {
+         projectMenu, $"Real Clean", e, disabled = true;
+         bitmap = { ":actions/clean.png" };
+         bool NotifySelect(MenuItem selection, Modifiers mods)
+         {
+            if(projectView)
+            {
+               debugger.Stop();
+               projectView.ProjectRealClean(projectView.active ? selection : null, mods);
+            }
+            return true;
+         }
+      }
       MenuItem projectRegenerateItem
       {
          projectMenu, $"Regenerate Makefile", m, disabled = true;
@@ -1529,7 +1545,7 @@ class IDEWorkSpace : Window
       projectQuickItem.disabled           = !unavailable;
 
       projectAddItem.disabled             = unavailable;
-      ((IDEMainFrame)master).toolBar.buttonAddProject.disabled = unavailable;
+      toolBar.buttonAddProject.disabled   = unavailable;
 
       activeCompilerItem.disabled         = unavailable;
       projectActiveConfigItem.disabled    = unavailable;
@@ -1547,29 +1563,31 @@ class IDEWorkSpace : Window
    {
       bool unavailable = project && projectView.buildInProgress;
 
-      projectNewItem.disabled          = unavailable;
-      toolBar.buttonNewProject.disabled = unavailable;
-      projectOpenItem.disabled         = unavailable;
-      toolBar.buttonOpenProject.disabled = unavailable;
+      projectNewItem.disabled             = unavailable;
+      toolBar.buttonNewProject.disabled   = unavailable;
+      projectOpenItem.disabled            = unavailable;
+      toolBar.buttonOpenProject.disabled  = unavailable;
 
       unavailable = !project || projectView.buildInProgress;
 
-      projectCloseItem.disabled        = unavailable;
+      projectCloseItem.disabled           = unavailable;
       // toolBar.buttonCloseProject.disabled = unavailable;
 
-      projectRunItem.disabled          = unavailable || project.GetTargetType(project.config) != executable;
+      projectRunItem.disabled    = unavailable || project.GetTargetType(project.config) != executable;
       toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
-      projectBuildItem.disabled        = unavailable;
-      toolBar.buttonBuild.disabled = unavailable;
-      projectLinkItem.disabled         = unavailable;
-      toolBar.buttonReLink.disabled = unavailable;
-      projectRebuildItem.disabled      = unavailable;
-      toolBar.buttonRebuild.disabled = unavailable;
-      projectCleanItem.disabled        = unavailable;
-      toolBar.buttonClean.disabled = unavailable;
-      projectRegenerateItem.disabled   = unavailable;
+      projectBuildItem.disabled                 = unavailable;
+      toolBar.buttonBuild.disabled              = unavailable;
+      projectLinkItem.disabled                  = unavailable;
+      toolBar.buttonReLink.disabled             = unavailable;
+      projectRebuildItem.disabled               = unavailable;
+      toolBar.buttonRebuild.disabled            = unavailable;
+      projectCleanItem.disabled                 = unavailable;
+      toolBar.buttonClean.disabled              = unavailable;
+      projectRealCleanItem.disabled             = unavailable;
+      // toolBar.buttonRealClean.disabled          = unavailable;
+      projectRegenerateItem.disabled            = unavailable;
       toolBar.buttonRegenerateMakefile.disabled = unavailable;
-      projectCompileItem.disabled      = unavailable;
+      projectCompileItem.disabled               = unavailable;
    }
 
    void AdjustDebugMenus()
index 77d3725..cf9817b 100644 (file)
@@ -1489,7 +1489,7 @@ private:
       return result;
    }
 
-   void Clean(CompilerConfig compiler, ProjectConfig config)
+   void Clean(CompilerConfig compiler, ProjectConfig config, bool realclean)
    {
       char makeFile[MAX_LOCATION];
       char makeFilePath[MAX_LOCATION];
@@ -1523,7 +1523,7 @@ private:
       }
       else
       {
-         sprintf(command, "%s clean -C \"%s\" -f \"%s\"", compiler.makeCommand, topNode.path, makeFilePath);
+         sprintf(command, "%s %sclean -C \"%s\" -f \"%s\"", compiler.makeCommand, realclean ? "real" : "", topNode.path, makeFilePath);
          if((f = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
          {
             ide.outputView.buildBox.Tell($"Deleting target and object files...");
@@ -1695,7 +1695,7 @@ private:
 
          sameObjTargetDirs = !fstrcmp(objDirExpNoSpaces, targetDirExpNoSpaces);
 
-         f.Printf(".PHONY: all objdir%s clean distclean\n\n", sameObjTargetDirs ? "" : " targetdir");
+         f.Printf(".PHONY: all objdir%s clean realclean\n\n", sameObjTargetDirs ? "" : " targetdir");
 
          f.Printf("# CONTENT\n\n");
 
@@ -2270,8 +2270,8 @@ private:
          }
          f.Printf("\n");
 
-         f.Printf("distclean: clean\n");
-         f.Printf("\t$(call rmdirq,$(OBJ))\n");
+         f.Printf("realclean: clean\n");
+         f.Printf("\t$(call rmrq,$(OBJ))\n");
          if(!sameObjTargetDirs)
             f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
 
index ddbd953..50606b3 100644 (file)
@@ -219,6 +219,7 @@ class ProjectView : Window
                      MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
                      MenuItem { popupContent, $"Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
                      MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
+                     MenuItem { popupContent, $"Real Clean", d, NotifySelect = ProjectRealClean }.disabled = buildMenuUnavailable;
                      MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
                      MenuDivider { popupContent };
                   }
@@ -658,7 +659,7 @@ class ProjectView : Window
          
          // TODO: Disabled until problems fixed... is it fixed?
          if(buildType == rebuild || (config && config.compilingModified))
-            prj.Clean(compiler, config);
+            prj.Clean(compiler, config, false);
          else
          {
             if(buildType == relink || (config && config.linkingModified))
@@ -834,11 +835,44 @@ class ProjectView : Window
       if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
       {
          ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
-         
+
+         buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
+         ide.AdjustBuildMenus();
+
+         prj.Clean(compiler, config, false);
+         buildInProgress = none;
+         ide.AdjustBuildMenus();
+      }
+      delete compiler;
+      return true;
+   }
+
+   bool ProjectRealClean(MenuItem selection, Modifiers mods)
+   {
+      Project prj = project;
+      CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
+      ProjectConfig config;
+      if(selection || !ide.activeClient)
+      {
+         DataRow row = fileList.currentRow;
+         ProjectNode node = row ? (ProjectNode)row.tag : null;
+         if(node) prj = node.project;
+      }
+      else
+      {
+         ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
+         if(node)
+            prj = node.project;
+      }
+      config = prj.config;
+      if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
+      {
+         ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
+
          buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
          ide.AdjustBuildMenus();
 
-         prj.Clean(compiler, config);
+         prj.Clean(compiler, config, true);
          buildInProgress = none;
          ide.AdjustBuildMenus();
       }