From 36535d1c9eb2087e2c84489ef392bcce5e47757e Mon Sep 17 00:00:00 2001 From: Rejean Loyer Date: Thu, 7 Mar 2013 19:27:54 -0500 Subject: [PATCH] ide; fixed opening generated files from build log (enter/dblclick). also opening makefiles and resources. --- ide/src/project/Project.ec | 75 +++++++++++++++++------- ide/src/project/ProjectNode.ec | 77 ++++++++++++++++++++++++ ide/src/project/ProjectView.ec | 130 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 250 insertions(+), 32 deletions(-) diff --git a/ide/src/project/Project.ec b/ide/src/project/Project.ec index 64dc7e8..43b79be 100644 --- a/ide/src/project/Project.ec +++ b/ide/src/project/Project.ec @@ -848,6 +848,11 @@ private: String compilerConfigsDir; String moduleVersion; + String lastBuildConfigName; + String lastBuildCompilerName; + + Map lastBuildNamesInfo; + #ifndef MAKEFILE_GENERATOR FileMonitor fileMonitor { @@ -951,6 +956,9 @@ private: delete filePath; delete topNode; delete name; + delete lastBuildConfigName; + delete lastBuildCompilerName; + if(lastBuildNamesInfo) { lastBuildNamesInfo.Free(); delete lastBuildNamesInfo; } } ~Project() @@ -972,6 +980,7 @@ private: topNode.info = CopyString(GetConfigName(config)); } } + property char * filePath { set @@ -994,6 +1003,29 @@ private: } } + ProjectConfig GetConfig(char * configName) + { + ProjectConfig result = null; + if(configName && configName[0] && configurations.count) + { + for(cfg : configurations; !strcmpi(cfg.name, configName)) + { + result = cfg; + break; + } + } + return result; + } + + ProjectNode FindNodeByObjectFileName(char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config) + { + ProjectNode result; + if(!lastBuildNamesInfo) + ProjectLoadLastBuildNamesInfo(this, config); + result = topNode.FindByObjectFileName(fileName, type, dotMain, lastBuildNamesInfo); + return result; + } + TargetTypes GetTargetType(ProjectConfig config) { TargetTypes targetType = localTargetType; @@ -1013,7 +1045,6 @@ private: return false; } - char * GetObjDirExpression(ProjectConfig config) { // TODO: Support platform options @@ -1455,7 +1486,6 @@ private: int compilingEC = 0; int numErrors = 0, numWarnings = 0; bool loggedALine = false; - char * configName = config ? config.name : "Common"; int lenMakeCommand = strlen(compiler.makeCommand); int testLen = 0; char * t; @@ -1885,7 +1915,7 @@ private: char targetFileName[MAX_LOCATION]; targetFileName[0] = '\0'; CatTargetFileName(targetFileName, compiler, config); - ide.outputView.buildBox.Logf("\n%s (%s) - ", targetFileName, configName); + ide.outputView.buildBox.Logf("\n%s (%s) - ", targetFileName, lastBuildConfigName); } if(numErrors) ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error"); @@ -1968,9 +1998,14 @@ private: bool singleProjectOnlyNode = onlyNodes && onlyNodes.count == 1 && onlyNodes[0].type == project; int numJobs = compiler.numJobs; char command[MAX_F_STRING*4]; - char * compilerName; + char * compilerName = CopyString(compiler.name); + + delete lastBuildConfigName; + lastBuildConfigName = CopyString(config ? config.name : "Common"); + delete lastBuildCompilerName; + lastBuildCompilerName = CopyString(compiler.name); + ProjectLoadLastBuildNamesInfo(this, config); - compilerName = CopyString(compiler.name); CamelCase(compilerName); strcpy(configName, config ? config.name : "Common"); @@ -1994,7 +2029,6 @@ private: int len; char pushD[MAX_LOCATION]; char cfDir[MAX_LOCATION]; - Map namesInfo { }; GetIDECompilerConfigsDir(cfDir, true, true); GetWorkingDir(pushD, sizeof(pushD)); ChangeWorkingDir(topNode.path); @@ -2016,7 +2050,6 @@ private: ChangeWorkingDir(pushD); - topNode.GenMakefileGetNameCollisionInfo(namesInfo, config); for(node : onlyNodes) { if(node.GetIsExcluded(config)) @@ -2024,12 +2057,10 @@ private: else { if(!eC_Debug) - node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, mode == cObject ? true : false); - node.GetTargets(config, namesInfo, objDirExp.dir, makeTargets); + node.DeleteIntermediateFiles(compiler, config, bitDepth, lastBuildNamesInfo, mode == cObject ? true : false); + node.GetTargets(config, lastBuildNamesInfo, objDirExp.dir, makeTargets); } } - namesInfo.Free(); - delete namesInfo; } } @@ -3486,6 +3517,17 @@ private: } } +static inline void ProjectLoadLastBuildNamesInfo(Project prj, ProjectConfig cfg) +{ + if(prj.lastBuildNamesInfo) + { + prj.lastBuildNamesInfo.Free(); + delete prj.lastBuildNamesInfo; + } + prj.lastBuildNamesInfo = { }; + prj.topNode.GenMakefileGetNameCollisionInfo(prj.lastBuildNamesInfo, cfg); +} + Project LegacyBinaryLoadProject(File f, char * filePath) { Project project = null; @@ -4354,16 +4396,7 @@ Project LoadProject(char * filePath, char * activeConfigName) { if(!project.options) project.options = { }; if(activeConfigName && activeConfigName[0] && project.configurations) - { - for(cfg : project.configurations) - { - if(!strcmpi(cfg.name, activeConfigName)) - { - project.config = cfg; - break; - } - } - } + project.config = project.GetConfig(activeConfigName); if(!project.config && project.configurations) project.config = project.configurations.firstIterator.data; diff --git a/ide/src/project/ProjectNode.ec b/ide/src/project/ProjectNode.ec index deb8136..8004ca6 100644 --- a/ide/src/project/ProjectNode.ec +++ b/ide/src/project/ProjectNode.ec @@ -177,6 +177,8 @@ class TwoStrings : struct } } +enum IntermediateFileType { none, ec, c, sym, imp, bowl, o }; + class ProjectNode : ListItem { public: @@ -478,6 +480,51 @@ private: return buffer; } + char * GetObjectFileName(char * buffer, Map namesInfo, IntermediateFileType type, bool dotMain) + { + if(buffer && (this.type == file || (this.type == project && dotMain == true))) + { + bool collision; + char extension[MAX_EXTENSION]; + char moduleName[MAX_FILENAME]; + NameCollisionInfo info; + + GetExtension(name, extension); + ReplaceSpaces(moduleName, name); + StripExtension(moduleName); + info = namesInfo[moduleName]; + collision = info ? info.IsExtensionColliding(extension) : false; + + if(dotMain) + { + strcpy(buffer, project.moduleName); + StripExtension(buffer); + strcat(buffer, ".main.ec"); + } + else + strcpy(buffer, name); + if(!strcmp(extension, "ec") || dotMain) + { + if(type == c) + ChangeExtension(buffer, "c", buffer); + else if(type == sym) + ChangeExtension(buffer, "sym", buffer); + else if(type == imp) + ChangeExtension(buffer, "imp", buffer); + else if(type == bowl) + ChangeExtension(buffer, "bowl", buffer); + } + if(type == o) + { + if(collision) + strcat(buffer, ".o"); + else + ChangeExtension(buffer, "o", buffer); + } + } + return buffer; + } + char * GetFileSysMatchingPath(char * buffer) { if(buffer) @@ -1020,6 +1067,36 @@ private: return result; } + ProjectNode FindByObjectFileName(char * fileName, IntermediateFileType type, bool dotMain, Map namesInfo) + { + char p[MAX_LOCATION]; + ProjectNode result = null; + if(dotMain == true && this.type == project) + { + GetObjectFileName(p, namesInfo, type, dotMain); + if(!strcmpi(p, fileName)) + result = this; + } + else if(files) + { + for(child : files; child.type != resources) + { + if(child.type != file && (result = child.FindByObjectFileName(fileName, type, dotMain, namesInfo))) + break; + else if(child.type == file && child.name) + { + child.GetObjectFileName(p, namesInfo, type, dotMain); + if(!strcmpi(p, fileName)) + { + result = child; + break; + } + } + } + } + return result; + } + ProjectNode FindSpecial(char * name, bool recursive, bool includeResources, bool includeFolders) { ProjectNode result = null; diff --git a/ide/src/project/ProjectView.ec b/ide/src/project/ProjectView.ec index 0791add..f54a3e8 100644 --- a/ide/src/project/ProjectView.ec +++ b/ide/src/project/ProjectView.ec @@ -1567,9 +1567,10 @@ class ProjectView : Window } { - char moduleName[MAX_LOCATION], filePath[MAX_LOCATION]; - char ext[MAX_EXTENSION]; + char moduleName[MAX_LOCATION], filePath[MAX_LOCATION] = ""; + char ext[MAX_EXTENSION] = ""; char * bracket; + ProjectNode node = null; if(colon) { char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom); @@ -1586,33 +1587,140 @@ class ProjectView : Window else strcpy(moduleName, line); + if(!colon) + { + char * msg; + if((msg = strstr(moduleName, " - "))) + { + bool found = false; + msg[0] = '\0'; + for(prj : ide.workspace.projects) + { + strcpy(filePath, prj.topNode.path); + PathCatSlash(filePath, moduleName); + if(FileExists(filePath).isFile) + { + found = true; + break; + } + } + if(!found) + { + msg[0] = ' '; + filePath[0] = '\0'; + } + } + else if((msg = strstr(moduleName, "...")) && (colon = strchr(moduleName, ' ')) && (++colon)[0]) + { + bool found = false; + msg[0] = '\0'; + for(prj : ide.workspace.projects) + { + if((node = prj.resNode.Find(colon, true))) + { + strcpy(filePath, prj.topNode.path); + PathCatSlash(filePath, node.path); + PathCatSlash(filePath, node.name); + + found = true; + break; + } + } + if(!found) + { + msg[0] = '.'; + filePath[0] = '\0'; + } + } + colon = null; + } // Remove stuff in brackets /* bracket = strstr(moduleName, "("); if(bracket) *bracket = '\0'; */ MakeSlashPath(moduleName); + GetExtension(moduleName, ext); - if(!colon) + if(!colon && !filePath[0]) { + bool dotMain = false; // Check if it's one of our modules - ProjectNode node = project.topNode.Find(moduleName, false); + node = project.topNode.Find(moduleName, false); if(node) { - strcpy(moduleName, node.path); - PathCatSlash(moduleName, node.name); + strcpy(filePath, node.path); + PathCatSlash(filePath, node.name); } else - moduleName[0] = '\0'; + { + IntermediateFileType type = none; + ProjectConfig config; + if(ext[0]) + { + char ext2[MAX_EXTENSION]; + char stripExt[MAX_LOCATION]; + strcpy(stripExt, moduleName); + StripExtension(stripExt); + GetExtension(stripExt, ext2); + if(ext2[0] && !strcmp(ext2, "main")) + dotMain = true; + if(!strcmp(ext, "ec")) + type = ec; + else if(!strcmp(ext, "c")) + type = c; + else if(!strcmp(ext, "sym")) + type = sym; + else if(!strcmp(ext, "imp")) + type = imp; + else if(!strcmp(ext, "bowl")) + type = bowl; + else if(!strcmp(ext, "o")) + type = o; + + if(type) + { + for(prj : ide.workspace.projects; prj.lastBuildConfigName) + { + if((config = prj.GetConfig(prj.lastBuildConfigName))) + node = prj.FindNodeByObjectFileName(moduleName, type, dotMain, config); + if(node) + break; + } + } + } + if(node) + { + char name[MAX_FILENAME]; + Project project = node.project; + CompilerConfig compiler = ideSettings.GetCompilerConfig(project.lastBuildCompilerName); + if(compiler) + { + int bitDepth = ide.workspace.bitDepth; + DirExpression objDir = project.GetObjDir(compiler, config, bitDepth); + strcpy(filePath, project.topNode.path); + PathCatSlash(filePath, objDir.dir); + node.GetObjectFileName(name, project.lastBuildNamesInfo, type, dotMain); + PathCatSlash(filePath, name); + delete objDir; + } + delete compiler; + } + } + if(!node) + filePath[0] = '\0'; } - GetExtension(moduleName, ext); - if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll")) + if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || + !strcmp(ext, "dll") || !strcmp(ext, "exe") || !strcmp(ext, "mo")) moduleName[0] = 0; // Avoid opening binary files if(moduleName[0]) { CodeEditor codeEditor; - strcpy(filePath, project.topNode.path); - PathCatSlash(filePath, moduleName); + if(!filePath[0]) + { + strcpy(filePath, project.topNode.path); + PathCatSlash(filePath, moduleName); + } codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing); if(!codeEditor && !strcmp(ext, "c")) -- 1.8.3.1