ide; added Debug Precompile, Debug Compile and Debug Generate Symbols support to...
authorRejean Loyer <rejean.loyer@gmail.com>
Wed, 21 Nov 2012 16:27:11 +0000 (11:27 -0500)
committerRejean Loyer <rejean.loyer@gmail.com>
Fri, 23 Nov 2012 04:56:22 +0000 (23:56 -0500)
ide/src/ide.ec
ide/src/project/Project.ec
ide/src/project/ProjectView.ec

index fc00bff..90ab6d7 100644 (file)
@@ -1657,15 +1657,18 @@ class IDEWorkSpace : Window
       if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
       {
          MenuItem menu;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);      if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0);       if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0);    if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0);      if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0);  if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0);     if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0);         if(menu) menu.disabled = unavailable;
-         menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0);       if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);             if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0);              if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0);           if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0);             if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0);         if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0);        if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0);            if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0);                if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0);              if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0);      if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0);         if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
          projectView.popupMenu.Update(null);
       }
    }
@@ -2440,7 +2443,7 @@ class IDEWorkSpace : Window
                               {
                                  List<ProjectNode> nodes { };
                                  nodes.Add(node);
-                                 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift);
+                                 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
                                  delete nodes;
 
                                  result = true;
@@ -2485,69 +2488,89 @@ class IDEWorkSpace : Window
    bool OnPostCreate()
    {
       int c;
+      bool passThrough = false;
+      bool debugStart = false;
+      DynamicString passArgs { };
       for(c = 1; c<app.argc; c++)
       {
-         char fullPath[MAX_LOCATION];
-         char parentPath[MAX_LOCATION];
-         char ext[MAX_EXTENSION];
-         bool isProject;
-         FileAttribs dirAttribs;
-         GetWorkingDir(fullPath, MAX_LOCATION);
-         PathCat(fullPath, app.argv[c]);
-         StripLastDirectory(fullPath, parentPath);
-         GetExtension(app.argv[c], ext);
-         isProject = !strcmpi(ext, "epj");
-
-         if(isProject && c > 1) continue;
-
-         // Create directory for projects (only)
-         if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
+         if(!strcmp(app.argv[c], "-debug-start"))
+            debugStart = true;
+         else if(!passThrough && !strcmp(app.argv[c], "-@"))
+            passThrough = true;
+         else if(passThrough)
          {
-            if(isProject && !FileExists(fullPath))
+            passArgs.concat(" ");
+            passArgs.concat(app.argv[c]);
+         }
+         else
+         {
+            char fullPath[MAX_LOCATION];
+            char parentPath[MAX_LOCATION];
+            char ext[MAX_EXTENSION];
+            bool isProject;
+            FileAttribs dirAttribs;
+            GetWorkingDir(fullPath, MAX_LOCATION);
+            PathCat(fullPath, app.argv[c]);
+            StripLastDirectory(fullPath, parentPath);
+            GetExtension(app.argv[c], ext);
+            isProject = !strcmpi(ext, "epj");
+
+            if(isProject && c > (debugStart ? 2 : 1)) continue;
+
+            // Create directory for projects (only)
+            if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
             {
-               // The NewProject will handle directory creation
-               /*if(!dirAttribs.isDirectory)
-               {
-                  MakeDir(parentPath);
-                  dirAttribs = FileExists(parentPath);
-               }
-               if(dirAttribs.isDirectory)*/
+               if(isProject && !FileExists(fullPath))
                {
-                  char name[MAX_LOCATION];
-                  NewProjectDialog newProjectDialog;
-
-                  if(projectView)
+                  // The NewProject will handle directory creation
+                  /*if(!dirAttribs.isDirectory)
                   {
-                     projectView.visible = false;
-                     if(!projectView.Destroy(0))
-                        return true;
+                     MakeDir(parentPath);
+                     dirAttribs = FileExists(parentPath);
                   }
+                  if(dirAttribs.isDirectory)*/
+                  {
+                     char name[MAX_LOCATION];
+                     NewProjectDialog newProjectDialog;
 
-                  newProjectDialog = { master = this };
+                     if(projectView)
+                     {
+                        projectView.visible = false;
+                        if(!projectView.Destroy(0))
+                           return true;
+                     }
 
-                  strcpy(name, app.argv[c]);
-                  StripExtension(name);
-                  GetLastDirectory(name, name);
-                  newProjectDialog.projectName.contents = name;
-                  newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
-                  newProjectDialog.locationEditBox.path = parentPath;
-                  newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
+                     newProjectDialog = { master = this };
 
-                  newProjectDialog.Modal();
-                  if(projectView)
-                  {
-                     ideSettings.AddRecentProject(projectView.fileName);
-                     ide.UpdateRecentMenus();
-                     settingsContainer.Save();
+                     strcpy(name, app.argv[c]);
+                     StripExtension(name);
+                     GetLastDirectory(name, name);
+                     newProjectDialog.projectName.contents = name;
+                     newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
+                     newProjectDialog.locationEditBox.path = parentPath;
+                     newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
+
+                     newProjectDialog.Modal();
+                     if(projectView)
+                     {
+                        ideSettings.AddRecentProject(projectView.fileName);
+                        ide.UpdateRecentMenus();
+                        settingsContainer.Save();
+                     }
                   }
+                  // Open only one project
+                  break;
                }
-               // Open only one project
-               break;
+               else
+                  ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
             }
-            else
-               ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
          }
       }
+      if(passThrough && projectView && projectView.project && workspace)
+         workspace.commandLineArgs = passArgs;
+      delete passArgs;
+      if(debugStart)
+         ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
       return true;
    }
 
index e224877..8ec3d3e 100755 (executable)
@@ -696,6 +696,8 @@ char * GetConfigName(ProjectConfig config)
    return config ? config.name : "Common";
 }
 
+public enum SingleFileCompileMode { normal, debugPrecompile, debugCompile, debugGenerateSymbols };
+
 class Project : struct
 {
    class_no_expansion;  // To use Find on the Container<Project> in Workspace::projects
@@ -1695,7 +1697,7 @@ private:
       }
    }
 
-   bool Build(bool isARun, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, bool justPrint)
+   bool Build(bool isARun, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, bool justPrint, SingleFileCompileMode mode)
    {
       bool result = false;
       DualPipe f;
@@ -1790,25 +1792,49 @@ private:
       {
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s CF_DIR=\"%s\"%s%s COMPILER=%s -j%d %s%s%s -C \"%s\"%s -f \"%s\"",
-               compiler.makeCommand, cfDir,
+         sprintf(command, "%s %sCF_DIR=\"%s\"%s%s COMPILER=%s -j%d %s%s%s -C \"%s\"%s -f \"%s\"",
+               compiler.makeCommand,
+               mode == normal ? "" : (mode == debugPrecompile ? "ECP_DEBUG=y " : mode == debugCompile ? "ECC_DEBUG=y " : mode == debugGenerateSymbols ? "ECS_DEBUG=y " : ""),
+               cfDir,
                crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
                compilerName, numJobs,
                compiler.ccacheEnabled ? "CCACHE=y " : "",
                compiler.distccEnabled ? "DISTCC=y " : "",
-               (String)makeTargets, topNode.path, justPrint ? " -n" : "", makeFilePath);
+               (String)makeTargets, topNode.path, (justPrint || mode != normal) ? " -n" : "", makeFilePath);
          if(justPrint)
             ide.outputView.buildBox.Logf("%s\n", command);
          if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
          {
+            bool found = false;
             if(justPrint)
             {
                ProcessPipeOutputRaw(f);
                result = true;
             }
+            else if(mode != normal)
+            {
+               char line[65536];
+               while(!f.Eof())
+               {
+                  bool result = true;
+                  while(result)
+                  {
+                     if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
+                     {
+                        if(!found && strstr(line, "ide ") == line)
+                        {
+                           strcpy(command, line);
+                           found = true;
+                        }
+                     }
+                  }
+               }
+            }
             else
                result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNodes, compiler, config);
             delete f;
+            if(found)
+               Execute(command);
          }
          else
             ide.outputView.buildBox.Logf($"Error executing make (%s) command\n", compiler.makeCommand);
@@ -1938,9 +1964,9 @@ private:
       delete target;
    }
 
-   void Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, bool justPrint)
+   void Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, bool justPrint, SingleFileCompileMode mode)
    {
-      Build(false, nodes, compiler, config, justPrint);
+      Build(false, nodes, compiler, config, justPrint, mode);
    }
 #endif
 
@@ -2045,6 +2071,16 @@ private:
          File f = FileOpen(path, write);
          if(f)
          {
+            if(compiler.environmentVars && compiler.environmentVars.count)
+            {
+               f.Puts("# ENVIRONMENT VARIABLES\n");
+               f.Puts("\n");
+               for(e : compiler.environmentVars)
+               {
+                  f.Printf("export %s := %s\n", e.name, e.string);
+               }
+            }
+
             f.Puts("# TOOLCHAIN\n");
             f.Puts("\n");
 
@@ -2065,9 +2101,9 @@ private:
             f.Printf("CPP := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cppCommand);
             f.Printf("CC := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.ccCommand);
             f.Printf("CXX := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cxxCommand);
-            f.Printf("ECP := %s\n", compiler.ecpCommand);
-            f.Printf("ECC := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
-            f.Printf("ECS := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.ecsCommand);
+            f.Printf("ECP := $(if $(ECP_DEBUG),ide -debug-start $(ECERE_SDK_SRC)/compiler/ecp/ecp.epj -@,%s)\n", compiler.ecpCommand);
+            f.Printf("ECC := $(if $(ECC_DEBUG),ide -debug-start $(ECERE_SDK_SRC)/compiler/ecc/ecc.epj -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
+            f.Printf("ECS := $(if $(ECS_DEBUG),ide -debug-start $(ECERE_SDK_SRC)/compiler/ecs/ecs.epj -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.ecsCommand);
             f.Printf("EAR := %s\n", compiler.earCommand);
 
             f.Puts("AS := $(GCC_PREFIX)as\n");
@@ -2077,16 +2113,6 @@ private:
             f.Puts("UPX := upx\n");
             f.Puts("\n");
 
-            if(compiler.environmentVars && compiler.environmentVars.count)
-            {
-               f.Puts("# ENVIRONMENT VARIABLES\n");
-               f.Puts("\n");
-               for(e : compiler.environmentVars)
-               {
-                  f.Printf("export %s := %s\n", e.name, e.string);
-               }
-            }
-
             f.Puts("UPXFLAGS = -9\n"); // TOFEAT: Compression Level Option? Other UPX Options?
             f.Puts("\n");
 
index b2b57f1..0f8eb50 100644 (file)
@@ -223,6 +223,8 @@ class ProjectView : Window
                      MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
                      MenuDivider { popupContent };
                   }
+                  MenuItem { popupContent, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = buildMenuUnavailable;
+                  MenuDivider { popupContent };
                   MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
                   MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
                   MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
@@ -263,6 +265,9 @@ class ProjectView : Window
                   MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
                   MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
                   MenuDivider { popupContent };
+                  MenuItem { popupContent, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = buildMenuUnavailable;
+                  MenuItem { popupContent, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = buildMenuUnavailable;
+                  MenuDivider { popupContent };
                   MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
                   MenuDivider { popupContent };
                   MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
@@ -762,7 +767,7 @@ class ProjectView : Window
          ide.AdjustBuildMenus();
          ide.AdjustDebugMenus();
 
-         result = prj.Build(buildType == run, null, compiler, config, justPrint);
+         result = prj.Build(buildType == run, null, compiler, config, justPrint, normal);
 
          if(config)
          {
@@ -990,7 +995,7 @@ class ProjectView : Window
       return true;
    }
 
-   bool Compile(Project project, List<ProjectNode> nodes, bool justPrint)
+   bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
    {
       bool result = true;
       char fileName[MAX_LOCATION];
@@ -1023,15 +1028,15 @@ class ProjectView : Window
          if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
          {
             if(config)
-               ide.outputView.buildBox.Logf($"Compiling specific file(s) in project %s using the %s configuration...\n",
-                     project.name, config.name);
+               ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
+                     mode == normal ? $"Compiling" : $"Debug compiling", project.name, config.name);
             else
-               ide.outputView.buildBox.Logf($"Compiling specific file(s) in project %s...\n",
-                     project.name);
+               ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
+                     mode == normal ? $"Compiling" : $"Debug compiling", project.name);
 
             buildInProgress = compilingFile;
             ide.AdjustBuildMenus();
-            project.Compile(nodes, compiler, config, justPrint);
+            project.Compile(nodes, compiler, config, justPrint, mode);
             buildInProgress = none;
             ide.AdjustBuildMenus();
 
@@ -1289,7 +1294,7 @@ class ProjectView : Window
       }
       selectedRows.Free(null);
       if(project)
-         Compile(project, nodes, mods.ctrl && mods.shift);
+         Compile(project, nodes, mods.ctrl && mods.shift, normal);
       else
          ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
       delete nodes;
@@ -1326,6 +1331,45 @@ class ProjectView : Window
       return true;
    }
 
+   bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
+   {
+      DataRow row = fileList.currentRow;
+      ProjectNode node = row ? (ProjectNode)row.tag : null;
+      if(node)
+      {
+         List<ProjectNode> nodes { };
+         nodes.Add(node);
+         Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
+         delete nodes;
+      }
+   }
+
+   bool FileDebugCompile(MenuItem selection, Modifiers mods)
+   {
+      DataRow row = fileList.currentRow;
+      ProjectNode node = row ? (ProjectNode)row.tag : null;
+      if(node)
+      {
+         List<ProjectNode> nodes { };
+         nodes.Add(node);
+         Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
+         delete nodes;
+      }
+   }
+
+   bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
+   {
+      DataRow row = fileList.currentRow;
+      ProjectNode node = row ? (ProjectNode)row.tag : null;
+      if(node)
+      {
+         List<ProjectNode> nodes { };
+         nodes.Add(node);
+         Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
+         delete nodes;
+      }
+   }
+
    Project GetSelectedProject(bool useSelection)
    {
       Project prj = project;