ide; fixed compiling single file with same name but different extension conflict...
authorRejean Loyer <rejean.loyer@gmail.com>
Sun, 24 Feb 2013 01:46:17 +0000 (20:46 -0500)
committerJerome St-Louis <jerome@ecere.com>
Wed, 6 Mar 2013 13:25:25 +0000 (08:25 -0500)
ide/src/project/Project.ec
ide/src/project/ProjectNode.ec
ide/src/project/ProjectView.ec

index 6b2db7f..1943dd6 100644 (file)
@@ -1775,6 +1775,7 @@ private:
             int len;
             char pushD[MAX_LOCATION];
             char cfDir[MAX_LOCATION];
+            Map<String, NameCollisionInfo> namesInfo { };
             GetIDECompilerConfigsDir(cfDir, true, true);
             GetWorkingDir(pushD, sizeof(pushD));
             ChangeWorkingDir(topNode.path);
@@ -1792,16 +1793,19 @@ private:
 
             ChangeWorkingDir(pushD);
 
+            topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
             for(node : onlyNodes)
             {
                if(node.GetIsExcluded(config))
                   ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
                else
                {
-                  node.DeleteIntermediateFiles(compiler, config);
-                  node.GetTargets(config, objDirExp.dir, makeTargets);
+                  node.DeleteIntermediateFiles(compiler, config, namesInfo);
+                  node.GetTargets(config, namesInfo, objDirExp.dir, makeTargets);
                }
             }
+            namesInfo.Free();
+            delete namesInfo;
          }
       }
 
index 2d74752..6ac134c 100644 (file)
@@ -2264,21 +2264,32 @@ private:
       return platforms;
    }
 
-   void GetTargets(ProjectConfig prjConfig, char * objDir, DynamicString output)
+   void GetTargets(ProjectConfig prjConfig, Map<String, NameCollisionInfo> namesInfo, char * objDir, DynamicString output)
    {
       if(type == file)
       {
-         //output.concat(" $(OBJ)");
+         bool collision;
+         char extension[MAX_EXTENSION];
+         char moduleName[MAX_FILENAME];
+         NameCollisionInfo info;
+         Project prj = property::project;
+
+         GetExtension(name, extension);
+         ReplaceSpaces(moduleName, name);
+         StripExtension(moduleName);
+         info = namesInfo[moduleName];
+         collision = info ? info.IsExtensionColliding(extension) : false;
+
          output.concat(" \"");
-         output.concat(objDir);
+         output.concat(objDir); //.concat(" $(OBJ)");
          output.concat("/");
+         if(collision)
          {
-            char fileName[MAX_FILENAME];
-            strcpy(fileName, name);
-            // TODO/NOTE: this will not be correct for file.o instead of file.c.o when whe have both a file.c and a file.ec in a project.
-            ChangeExtension(fileName, "o", fileName);
-            output.concat(fileName);
+            strcat(moduleName, ".");
+            strcat(moduleName, extension);
          }
+         strcat(moduleName, ".o");
+         output.concat(moduleName);
          output.concat("\"");
       }
       else if(files)
@@ -2286,49 +2297,52 @@ private:
          for(child : files)
          {
             if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
-               child.GetTargets(prjConfig, objDir, output);
+               child.GetTargets(prjConfig, namesInfo, objDir, output);
          }
       }
    }
 
-   void DeleteIntermediateFiles(CompilerConfig compiler, ProjectConfig prjConfig)
+   void DeleteIntermediateFiles(CompilerConfig compiler, ProjectConfig prjConfig, Map<String, NameCollisionInfo> namesInfo)
    {
       if(type == file)
       {
-         char fileName[MAX_FILENAME];
+         bool collision;
          char extension[MAX_EXTENSION];
+         char fileName[MAX_FILENAME];
+         char moduleName[MAX_FILENAME];
+         NameCollisionInfo info;
          Project prj = property::project;
          DirExpression objDir = prj.GetObjDir(compiler, prjConfig);
 
+         GetExtension(name, extension);
+         ReplaceSpaces(moduleName, name);
+         StripExtension(moduleName);
+         info = namesInfo[moduleName];
+         collision = info ? info.IsExtensionColliding(extension) : false;
+
          strcpy(fileName, prj.topNode.path);
          PathCatSlash(fileName, objDir.dir);
          PathCatSlash(fileName, name);
 
-         // TODO/NOTE: this will not delete file.c.o when whe have both a file.c and a file.ec in a project.
-         ChangeExtension(fileName, "o", fileName);
-         if(FileExists(fileName))
-            DeleteFile(fileName);
-
-         GetExtension(name, extension);
          if(!strcmp(extension, "ec"))
          {
             ChangeExtension(fileName, "c", fileName);
-            if(FileExists(fileName))
-               DeleteFile(fileName);
-
+            if(FileExists(fileName)) DeleteFile(fileName);
             ChangeExtension(fileName, "sym", fileName);
-            if(FileExists(fileName))
-               DeleteFile(fileName);
-
+            if(FileExists(fileName)) DeleteFile(fileName);
             ChangeExtension(fileName, "imp", fileName);
-            if(FileExists(fileName))
-               DeleteFile(fileName);
-
+            if(FileExists(fileName)) DeleteFile(fileName);
             ChangeExtension(fileName, "bowl", fileName);
-            if(FileExists(fileName))
-               DeleteFile(fileName);
+            if(FileExists(fileName)) DeleteFile(fileName);
+            ChangeExtension(fileName, "ec", fileName);
          }
 
+         if(collision)
+            strcat(fileName, ".o");
+         else
+            ChangeExtension(fileName, "o", fileName);
+         if(FileExists(fileName)) DeleteFile(fileName);
+
          delete objDir;
       }
       else if(files)
@@ -2336,7 +2350,7 @@ private:
          for(child : files)
          {
             if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
-               child.DeleteIntermediateFiles(compiler, prjConfig);
+               child.DeleteIntermediateFiles(compiler, prjConfig, namesInfo);
          }
       }
    }
index 229aa74..7eff355 100644 (file)
@@ -1079,6 +1079,8 @@ class ProjectView : Window
          result = false;
          if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
          {
+            Map<String, NameCollisionInfo> namesInfo { };
+            project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
             for(node : nodes)
             {
                if(node.GetIsExcluded(config))
@@ -1092,10 +1094,12 @@ class ProjectView : Window
                      ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
                            node.type == file ? $"single file" : $"folder", node.name, project.name);
 
-                  node.DeleteIntermediateFiles(compiler, config);
+                  node.DeleteIntermediateFiles(compiler, config, namesInfo);
                   result = true;
                }
             }
+            namesInfo.Free();
+            delete namesInfo;
          }
          delete compiler;
       }