buildsystem, epj2make, ide: support Emscripten compiler.
[sdk] / ide / src / project / Project.ec
index 5d05fbe..5a8c93a 100644 (file)
@@ -42,8 +42,8 @@ IDESettingsContainer settingsContainer
 
    void OnLoad(GlobalSettingsData data)
    {
-      IDESettings settings = (IDESettings)data;
 #ifndef MAKEFILE_GENERATOR
+      IDESettings settings = (IDESettings)data;
       globalSettingsDialog.ideSettings = settings;
       ide.UpdateRecentMenus();
       ide.UpdateCompilerConfigs(true);
@@ -1038,7 +1038,7 @@ private:
       return result;
    }
 
-   ProjectNode FindNodeByObjectFileName(const char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config)
+   ProjectNode FindNodeByObjectFileName(const char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config, const char * objectFileExt)
    {
       ProjectNode result;
       const char * cfgName;
@@ -1047,7 +1047,7 @@ private:
       cfgName = config ? config.name : "";
       if(!configsNameCollisions[cfgName])
          ProjectLoadLastBuildNamesInfo(this, config);
-      result = topNode.FindByObjectFileName(fileName, type, dotMain, configsNameCollisions[cfgName]);
+      result = topNode.FindByObjectFileName(fileName, type, dotMain, configsNameCollisions[cfgName], objectFileExt);
       return result;
    }
 
@@ -1183,6 +1183,8 @@ private:
    {
 #ifndef MAKEFILE_GENERATOR
       return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
+#else
+      return false;
 #endif
    }
 
@@ -1190,6 +1192,8 @@ private:
    {
 #ifndef MAKEFILE_GENERATOR
       return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
+#else
+      return false;
 #endif
    }
 
@@ -1260,7 +1264,7 @@ private:
                strcat(string, ".dylib");
             else
                strcat(string, ".so");
-            if(compiler.targetPlatform == tux && GetRuntimePlatform() == tux && moduleVersion && moduleVersion[0])
+            if(compiler.targetPlatform == tux && __runtimePlatform == tux && moduleVersion && moduleVersion[0])
             {
                strcat(string, ".");
                strcat(string, moduleVersion);
@@ -1345,6 +1349,42 @@ private:
    }
 
 #ifndef MAKEFILE_GENERATOR
+   ProjectNode GetObjectFileNode(const char * filePath, const char * objectFileExt)
+   {
+      ProjectNode node = null;
+      char ext[MAX_EXTENSION];
+      GetExtension(filePath, ext);
+      if(ext[0])
+      {
+         IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+         if(type)
+         {
+            char fileName[MAX_FILENAME];
+            GetLastDirectory(filePath, fileName);
+            if(fileName[0])
+            {
+               DotMain dotMain = DotMain::FromFileName(fileName);
+               node = FindNodeByObjectFileName(fileName, type, dotMain, null, objectFileExt);
+            }
+         }
+      }
+      return node;
+   }
+
+   bool GetAbsoluteFromRelativePath(const char * relativePath, char * absolutePath, const char * objectFileExt)
+   {
+      ProjectNode node = topNode.FindWithPath(relativePath, false);
+      if(!node)
+         node = GetObjectFileNode(relativePath, objectFileExt);
+      if(node)
+      {
+         strcpy(absolutePath, node.project.topNode.path);
+         PathCat(absolutePath, relativePath);
+         MakeSlashPath(absolutePath);
+      }
+      return node != null;
+   }
+
    void MarkChanges(ProjectNode node)
    {
       for(cfg : topNode.configurations)
@@ -1473,13 +1513,14 @@ private:
       CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
       char line[65536];
+      int linePos = 0;
       bool compiling = false, linking = false, precompiling = false;
       int compilingEC = 0;
       int numErrors = 0, numWarnings = 0;
       bool loggedALine = false;
       int lenMakeCommand = strlen(compiler.makeCommand);
       int testLen = 0;
-      const char * t, * s;
+      const char * t, * s, * s2;
       char moduleName[MAX_FILENAME];
       const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
 
@@ -1535,315 +1576,350 @@ private:
 
       while(!f.Eof() && !ide.projectView.stopBuild)
       {
-         bool result = true;
          double lastTime = GetTime();
          bool wait = true;
-         while(result)
+         while(!f.Eof() && !ide.projectView.stopBuild)
          {
-            //printf("Peeking and GetLine...\n");
-            if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
+            int nChars;
+            bool lineDone = f.GetLinePeek(line + linePos, sizeof(line)-linePos-1, &nChars);
+            if(!lineDone)
             {
-               const char * message = null;
-               const char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
-               const char * from = strstr(line, stringFrom);
-               test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
-               if((t = strstr(line, (s=": recipe for target"))) && (t = strstr(t+strlen(s), (s=" failed"))) && (t+strlen(s))[0] == '\0')
-                  ; // ignore this new gnu make error but what is it about?
-               else if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
+               linePos += nChars;
+               Sleep(0.5 / PEEK_RESOLUTION);
+            }
+            else
+            {
+               linePos = 0;
+               if(line[0])
                {
-                  const char * module = strstr(line, "No rule to make target `");
-                  if(module)
+                  const char * message = null;
+                  const char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
+                  const char * from = strstr(line, stringFrom);
+                  test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
+                  if((t = strstr(line, (s=": recipe for target"))) && (t = strstr(t+strlen(s), (s2 = " failed"))) && (t+strlen(s2))[0] == '\0')
+                     ; // ignore this new gnu make error but what is it about?
+                  else if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
                   {
-                     char * end;
-                     module = strchr(module, '`') + 1;
-                     end = strchr(module, '\'');
-                     if(end)
+                     const char * moduleBackTick = strstr(line, "No rule to make target `");
+                     const char * module = moduleBackTick ? moduleBackTick : strstr(line, "No rule to make target '");
+                     if(module)
                      {
-                        *end = '\0';
-                        ide.outputView.buildBox.Logf($"   %s: No such file or directory\n", module);
-                        // ide.outputView.buildBox.Logf("error: %s\n   No such file or directory\n", module);
-                        numErrors++;
+                        char * end;
+                        module = strchr(module, moduleBackTick ? '`' : '\'') + 1;
+                        end = strchr(module, '\'');
+                        if(end)
+                        {
+                           *end = '\0';
+                           ide.outputView.buildBox.Logf($"   %s: No such file or directory\n", module);
+                           // ide.outputView.buildBox.Logf("error: %s\n   No such file or directory\n", module);
+                           numErrors++;
+                        }
                      }
+                     //else
+                     //{
+                        //ide.outputView.buildBox.Logf("error: %s\n", line);
+                        //numErrors++;
+                     //}
                   }
-                  //else
-                  //{
-                     //ide.outputView.buildBox.Logf("error: %s\n", line);
-                     //numErrors++;
-                  //}
-               }
-               else if(strstr(test, "mkdir ") == test);
-               else if((t = strstr(line, "cd ")) && (t = strstr(line, "type ")) && (t = strstr(line, "nul ")) && (t = strstr(line, "copy ")) && (t = strstr(line, "cd ")));
-               else if(strstr(test, ear) == test);
-               else if(strstr(test, strip) == test);
-               else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
-               {
-                  char * module;
-                  bool isPrecomp = false;
-                  bool gotCC = false;
-
-                  if(strstr(test, cc) == test || strstr(test, cxx) == test)
+                  else if(strstr(test, "mkdir ") == test);
+                  else if((t = strstr(line, "cd ")) && (t = strstr(line, "type ")) && (t = strstr(line, "nul ")) && (t = strstr(line, "copy ")) && (t = strstr(line, "cd ")));
+                  else if(strstr(test, ear) == test);
+                  else if(strstr(test, strip) == test);
+                  else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
                   {
-                     module = strstr(line, " -c ");
-                     if(module) module += 4;
-                     gotCC = true;
-                  }
-                  else if(strstr(test, ecc) == test)
-                  {
-                     module = strstr(line, " -c ");
-                     if(module) module += 4;
-                     //module = line + 3;
-                     // Don't show GCC warnings about generated C code because it does not compile clean yet...
-                     compilingEC = 3;//2;
-                     gotCC = true;
-                  }
-                  else if(strstr(test, ecp) == test)
-                  {
-                     // module = line + 8;
-                     module = strstr(line, " -c ");
-                     if(module) module += 4;
-                     isPrecomp = true;
-                     compilingEC = 0;
-                     gotCC = true;
-                  }
+                     char * module = null;
+                     bool isPrecomp = false;
+                     bool gotCC = false;
 
-                  loggedALine = true;
+                     if(strstr(test, cc) == test || strstr(test, cxx) == test)
+                     {
+                        module = strstr(line, " -c ");
+                        if(module) module += 4;
+                        gotCC = true;
+                     }
+                     else if(strstr(test, ecc) == test)
+                     {
+                        module = strstr(line, " -c ");
+                        if(module) module += 4;
+                        //module = line + 3;
+                        // Don't show GCC warnings about generated C code because it does not compile clean yet...
+                        compilingEC = 3;//2;
+                        gotCC = true;
+                     }
+                     else if(strstr(test, ecp) == test)
+                     {
+                        // module = line + 8;
+                        module = strstr(line, " -c ");
+                        if(module) module += 4;
+                        isPrecomp = true;
+                        compilingEC = 0;
+                        gotCC = true;
+                     }
 
-                  if(module)
-                  {
-                     char * tokens[1];
-                     if(!compiling && !isPrecomp)
+                     loggedALine = true;
+
+                     if(module)
+                     {
+                        char * tokens[1];
+                        if(!compiling && !isPrecomp)
+                        {
+                           ide.outputView.buildBox.Logf($"Compiling...\n");
+                           compiling = true;
+                        }
+                        else if(!precompiling && isPrecomp)
+                        {
+                           ide.outputView.buildBox.Logf($"Generating symbols...\n");
+                           precompiling = true;
+                        }
+                        Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
+                        GetLastDirectory(tokens[0], moduleName);
+                        ide.outputView.buildBox.Logf("%s\n", moduleName);
+                     }
+                     else if((module = strstr(line, " -o ")))
                      {
-                        ide.outputView.buildBox.Logf($"Compiling...\n");
-                        compiling = true;
+                        compiling = false;
+                        precompiling = false;
+                        linking = true;
+                        ide.outputView.buildBox.Logf($"Linking...\n");
                      }
-                     else if(!precompiling && isPrecomp)
+                     else
                      {
-                        ide.outputView.buildBox.Logf($"Generating symbols...\n");
-                        precompiling = true;
+                        ide.outputView.buildBox.Logf("%s\n", line);
+                        if(strstr(line, "warning:") || strstr(line, "note:"))
+                           numWarnings++;
+                        else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
+                           numErrors++;
                      }
-                     Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
-                     GetLastDirectory(tokens[0], moduleName);
-                     ide.outputView.buildBox.Logf("%s\n", moduleName);
-                  }
-                  else if((module = strstr(line, " -o ")))
-                  {
-                     compiling = false;
-                     precompiling = false;
-                     linking = true;
-                     ide.outputView.buildBox.Logf($"Linking...\n");
-                  }
-                  else
-                  {
-                     ide.outputView.buildBox.Logf("%s\n", line);
-                     if(strstr(line, "warning:") || strstr(line, "note:"))
-                        numWarnings++;
-                     else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
-                        numErrors++;
-                  }
 
-                  if(compilingEC) compilingEC--;
-               }
-               else if(strstr(test, windres) == test)
-               {
-                  char * module;
-                  module = strstr(line, " ");
-                  if(module) module++;
-                  if(module)
+                     if(compilingEC) compilingEC--;
+                  }
+                  else if(strstr(test, windres) == test)
                   {
-                     byte * tokens[1];
-                     char * dashF = strstr(module, "-F ");
-                     if(dashF)
+                     char * module;
+                     module = strstr(line, " ");
+                     if(module) module++;
+                     if(module)
                      {
-                        dashF+= 3;
-                        while(*dashF && *dashF != ' ') dashF++;
-                        while(*dashF && *dashF == ' ') dashF++;
-                        module = dashF;
+                        char * tokens[1];
+                        char * dashF = strstr(module, "-F ");
+                        if(dashF)
+                        {
+                           dashF+= 3;
+                           while(*dashF && *dashF != ' ') dashF++;
+                           while(*dashF && *dashF == ' ') dashF++;
+                           module = dashF;
+                        }
+                        Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
+                        GetLastDirectory(module, moduleName);
+                        ide.outputView.buildBox.Logf("%s\n", moduleName);
                      }
-                     Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
-                     GetLastDirectory(module, moduleName);
-                     ide.outputView.buildBox.Logf("%s\n", moduleName);
                   }
-               }
-               else if(strstr(test, ar) == test)
-                  ide.outputView.buildBox.Logf($"Building library...\n");
-               else if(strstr(test, ecs) == test)
-                  ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
-               else
-               {
-                  if(linking || compiling || precompiling)
+                  else if(strstr(test, ar) == test)
+                     ide.outputView.buildBox.Logf($"Building library...\n");
+                  else if(strstr(test, ecs) == test)
+                     ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
+                  else
                   {
-                     const char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
-                     const char * colon = strstr(start, ":"); //, * bracket;
-                     if(colon && (colon[1] == '/' || colon[1] == '\\'))
-                        colon = strstr(colon + 1, ":");
-                     if(colon)
+                     if(linking || compiling || precompiling)
                      {
-                        const char * sayError = "";
-                        char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
-                        char * pointer;
-                        char * error;
-                        int len = (int)(colon - start);
-                        char ext[MAX_EXTENSION];
-                        len = Min(len, MAX_LOCATION-1);
-                        // Don't be mistaken by the drive letter colon
-                        // Cut module name
-                        // TODO: need to fix colon - line gives char *
-                        // warning: incompatible expression colon - line (char *); expected int
-                        /*
-                        strncpy(moduleName, line, (int)(colon - line));
-                        moduleName[colon - line] = '\0';
-                        */
-                        strncpy(moduleName, start, len);
-                        moduleName[len] = '\0';
-                        // Remove stuff in brackets
-                        //bracket = strstr(moduleName, "(");
-                        //if(bracket) *bracket = '\0';
-
-                        GetLastDirectory(moduleName, temp);
-                        GetExtension(temp, ext);
-
-                        if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
+                        const char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
+                        const char * colon = strstr(start, ":"); //, * bracket;
+                        if(colon && (colon[1] == '/' || colon[1] == '\\'))
+                           colon = strstr(colon + 1, ":");
+                        if(colon)
                         {
-                           char * cColon = strstr(colon+1, ":");
-                           if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
-                              cColon = strstr(cColon + 1, ":");
-                           if(cColon)
+                           const char * sayError = "";
+                           char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
+                           char * pointer;
+                           char * error;
+                           int len = (int)(colon - start);
+                           char ext[MAX_EXTENSION];
+                           len = Min(len, MAX_LOCATION-1);
+                           // Don't be mistaken by the drive letter colon
+                           // Cut module name
+                           // TODO: need to fix colon - line gives char *
+                           // warning: incompatible expression colon - line (char *); expected int
+                           /*
+                           strncpy(moduleName, line, (int)(colon - line));
+                           moduleName[colon - line] = '\0';
+                           */
+                           strncpy(moduleName, start, len);
+                           moduleName[len] = '\0';
+                           // Remove stuff in brackets
+                           //bracket = strstr(moduleName, "(");
+                           //if(bracket) *bracket = '\0';
+
+                           GetLastDirectory(moduleName, temp);
+                           GetExtension(temp, ext);
+
+                           if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
                            {
-                              int len = (int)(cColon - (colon+1));
-                              char mName[MAX_LOCATION];
-                              len = Min(len, MAX_LOCATION-1);
-                              strncpy(mName, colon+1, len);
-                              mName[len] = '\0';
-                              GetLastDirectory(mName, temp);
-                              GetExtension(temp, ext);
-                              if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
+                              char * cColon = strstr(colon+1, ":");
+                              if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
+                                 cColon = strstr(cColon + 1, ":");
+                              if(cColon)
                               {
-                                 colon = cColon;
-                                 strcpy(moduleName, mName);
+                                 int len = (int)(cColon - (colon+1));
+                                 char mName[MAX_LOCATION];
+                                 len = Min(len, MAX_LOCATION-1);
+                                 strncpy(mName, colon+1, len);
+                                 mName[len] = '\0';
+                                 GetLastDirectory(mName, temp);
+                                 GetExtension(temp, ext);
+                                 if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
+                                 {
+                                    colon = cColon;
+                                    strcpy(moduleName, mName);
+                                 }
                               }
                            }
-                        }
-                        if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
-                        {
-                           moduleName[0] = 0;
-                           if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
+                           if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
                            {
-                              message = $"Linker Message: ";
-                              colon = line;
+                              moduleName[0] = 0;
+                              if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
+                              {
+                                 message = $"Linker Message: ";
+                                 colon = line;
+                              }
+                              else if(SearchString(colon, 0, "warning:", false, false))
+                              {
+                                 message = $"Linker Warning: ";
+                                 colon = line;
+                              }
+                              else
+                              {
+                                 numErrors++;
+                                 message = $"Linker Error: ";
+                              }
                            }
-                           else
+                           else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
                            {
-                              numErrors++;
-                              message = $"Linker Error: ";
+                              moduleName[0] = 0;
+                              colon = line;
+                              if(strstr(colon, "Warning:") == colon)
+                              {
+                                 message = $"Linker ";
+                                 numWarnings++;
+                              }
+                              else if(!strstr(line, "error:"))
+                              {
+                                 message = $"Linker Error: ";
+                                 numErrors++;
+                              }
                            }
-                        }
-                        else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
-                        {
-                           moduleName[0] = 0;
-                           colon = line;
-                           if(strstr(colon, "Warning:") == colon)
+                           else
                            {
-                              message = $"Linker ";
-                              numWarnings++;
+                              strcpy(temp, topNode.path);
+                              PathCatSlash(temp, moduleName);
+                              MakePathRelative(temp, topNode.path, moduleName);
                            }
-                           else if(!strstr(line, "error:"))
-                           {
-                              message = $"Linker Error: ";
+                           error = strstr(line, "error:");
+                           if(!message && error && error > colon)
                               numErrors++;
-                           }
-                        }
-                        else
-                        {
-                           strcpy(temp, topNode.path);
-                           PathCatSlash(temp, moduleName);
-                           MakePathRelative(temp, topNode.path, moduleName);
-                        }
-                        error = strstr(line, "error:");
-                        if(!message && error && error > colon)
-                           numErrors++;
-                        else
-                        {
-                           // Silence warnings for compiled eC
-                           char * objDir = strstr(moduleName, objDirExp.dir);
-
-                           if(linking)
+                           else
                            {
-                              if((pointer = strstr(line, "undefined"))  ||
-                                   (pointer = strstr(line, "multiple definition")) ||
-                                   (pointer = strstr(line, "No such file")) ||
-                                   (pointer = strstr(line, "token")))
+                              // Silence warnings for compiled eC
+                              //char * objDir = strstr(moduleName, objDirExp.dir);
+
+                              if(linking)
+                              {
+                                 if((pointer = strstr(line, "undefined"))  ||
+                                      (pointer = strstr(line, "multiple definition")) ||
+                                      (pointer = strstr(line, "No such file")) ||
+                                      (pointer = strstr(line, "token")))
+                                 {
+                                    strncat(moduleName, colon, pointer - colon);
+                                    sayError = "error: ";
+                                    colon = pointer;
+                                    numErrors++;
+                                 }
+                              }
+                              else if((pointer = strstr(line, "No such file")))
                               {
                                  strncat(moduleName, colon, pointer - colon);
                                  sayError = "error: ";
                                  colon = pointer;
                                  numErrors++;
                               }
-                           }
-                           else if((pointer = strstr(line, "No such file")))
-                           {
-                              strncat(moduleName, colon, pointer - colon);
-                              sayError = "error: ";
-                              colon = pointer;
-                              numErrors++;
-                           }
-                           else if(compilingEC == 1 || (objDir && objDir == moduleName))
-                              continue;
-                           else if(strstr(line, "warning:"))
-                           {
-                              numWarnings++;
-                           }
-                        }
-                        if(message)
-                           ide.outputView.buildBox.Logf("   %s%s\n", message, colon);
-                        /*else if(this == ide.workspace.projects.firstIterator.data)
-                           ide.outputView.buildBox.Logf("   %s%s%s\n", moduleName, sayError, colon);*/
-                        else
-                        {
-                           char fullModuleName[MAX_LOCATION];
-                           FileAttribs found = 0;
-                           Project foundProject = this;
-                           if(moduleName[0])
-                           {
-                              char * loc = strstr(moduleName, ":");
-                              if(loc) *loc = 0;
-                              strcpy(fullModuleName, topNode.path);
-                              PathCat(fullModuleName, moduleName);
-                              found = FileExists(fullModuleName);
-                              if(!found && !strcmp(ext, "c"))
-                              {
-                                 char ecName[MAX_LOCATION];
-                                 ChangeExtension(fullModuleName, "ec", ecName);
-                                 found = FileExists(ecName);
-                              }
-                              if(!found)
+                              else //if(compilingEC == 1 || (objDir && objDir == moduleName))
                               {
-                                 char path[MAX_LOCATION];
-                                 if(ide && ide.workspace)
+                                 bool skip = false;
+
+                                 // Filter out these warnings caused by eC generated C code:
+
+                                 // Declaration ordering bugs -- Awaiting topo sort implementation
+                                 /*
+                                      if(strstr(line, "declared inside parameter list")) skip = true;
+                                 else if(strstr(line, "its scope is only this definition")) skip = true;
+                                 else if(strstr(line, "from incompatible pointer type")) skip = true;
+                                 else if(strstr(line, "note: expected 'struct ") || strstr(line, "note: expected â€˜struct "))
                                  {
-                                    for(prj : ide.workspace.projects)
-                                    {
-                                       ProjectNode node;
-                                       MakePathRelative(fullModuleName, prj.topNode.path, path);
+                                    #define STRUCT_A "'struct "
+                                    #define STRUCT_B "‘struct "
+                                    char * struct1, * struct2, ch1, ch2;
+                                    struct1 = strstr(line, STRUCT_A);
+                                    if(struct1) { struct1 += sizeof(STRUCT_A)-1; } else { struct1 = strstr(line, STRUCT_B); struct1 += sizeof(STRUCT_B)-1; };
 
-                                       if((node = prj.topNode.FindWithPath(path, false)))
-                                       {
-                                          strcpy(fullModuleName, prj.topNode.path);
-                                          PathCatSlash(fullModuleName, node.path);
-                                          PathCatSlash(fullModuleName, node.name);
-                                          found = FileExists(fullModuleName);
-                                          if(found)
-                                          {
-                                             foundProject = prj;
-                                             break;
-                                          }
-                                       }
+                                    struct2 = strstr(struct1, STRUCT_A);
+                                    if(struct2) { struct2 += sizeof(STRUCT_A)-1; } else { struct2 = strstr(struct1, STRUCT_B); if(struct2) struct2 += sizeof(STRUCT_B)-1; };
+
+                                    if(struct1 && struct2)
+                                    {
+                                       while(ch1 = *(struct1++), ch2 = *(struct2++), ch1 && ch2 && (ch1 == '_' || isalnum(ch1)) && (ch2 == '_' || isalnum(ch2)));
+                                       if(ch1 == ch2)
+                                          skip = true;
                                     }
-                                    if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
+                                 }
+
+                                 // For preprocessed code from objidl.h (MinGW-w64 headers)
+                                 else if(strstr(line, "declaration does not declare anything")) skip = true;
+
+                                 // Location information that could apply to ignored warnings
+                                 else if(strstr(line, "In function '") || strstr(line, "In function â€˜") ) skip = true;
+                                 else if(strstr(line, "At top level")) skip = true;
+                                 else if(strstr(line, "(near initialization for '") || strstr(line, "(near initialization for â€˜")) skip = true;
+                                 */
+                                 if(skip) continue;
+                                 numWarnings++;
+                              }
+                              /*else if(strstr(line, "warning:"))
+                              {
+                                 numWarnings++;
+                              }*/
+                           }
+                           if(message)
+                              ide.outputView.buildBox.Logf("   %s%s\n", message, colon);
+                           /*else if(this == ide.workspace.projects.firstIterator.data)
+                              ide.outputView.buildBox.Logf("   %s%s%s\n", moduleName, sayError, colon);*/
+                           else
+                           {
+                              char fullModuleName[MAX_LOCATION];
+                              FileAttribs found = 0;
+                              //Project foundProject = this;
+                              if(moduleName[0])
+                              {
+                                 char * loc = strstr(moduleName, ":");
+                                 if(loc) *loc = 0;
+                                 strcpy(fullModuleName, topNode.path);
+                                 PathCat(fullModuleName, moduleName);
+                                 found = FileExists(fullModuleName);
+                                 if(!found && !strcmp(ext, "c"))
+                                 {
+                                    char ecName[MAX_LOCATION];
+                                    ChangeExtension(fullModuleName, "ec", ecName);
+                                    found = FileExists(ecName);
+                                 }
+                                 if(!found)
+                                 {
+                                    char path[MAX_LOCATION];
+                                    if(ide && ide.workspace)
                                     {
                                        for(prj : ide.workspace.projects)
                                        {
                                           ProjectNode node;
-                                          if((node = prj.topNode.Find(moduleName, false)))
+                                          MakePathRelative(fullModuleName, prj.topNode.path, path);
+
+                                          if((node = prj.topNode.FindWithPath(path, false)))
                                           {
                                              strcpy(fullModuleName, prj.topNode.path);
                                              PathCatSlash(fullModuleName, node.path);
@@ -1851,44 +1927,62 @@ private:
                                              found = FileExists(fullModuleName);
                                              if(found)
                                              {
-                                                foundProject = prj;
+                                                //foundProject = prj;
                                                 break;
                                              }
                                           }
                                        }
+                                       if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
+                                       {
+                                          for(prj : ide.workspace.projects)
+                                          {
+                                             ProjectNode node;
+                                             if((node = prj.topNode.Find(moduleName, false)))
+                                             {
+                                                strcpy(fullModuleName, prj.topNode.path);
+                                                PathCatSlash(fullModuleName, node.path);
+                                                PathCatSlash(fullModuleName, node.name);
+                                                found = FileExists(fullModuleName);
+                                                if(found)
+                                                {
+                                                   //foundProject = prj;
+                                                   break;
+                                                }
+                                             }
+                                          }
+                                       }
                                     }
                                  }
-                              }
-                              if(found)
-                              {
-                                 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
-                                 MakeSystemPath(fullModuleName);
+                                 if(found)
+                                 {
+                                    MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
+                                    MakeSystemPath(fullModuleName);
+                                 }
+                                 else
+                                    strcpy(fullModuleName, moduleName);
+                                 if(loc)
+                                 {
+                                    strcat(fullModuleName, ":");
+                                    strcat(fullModuleName, loc + 1);
+                                 }
                               }
                               else
-                                 strcpy(fullModuleName, moduleName);
-                              if(loc)
-                              {
-                                 strcat(fullModuleName, ":");
-                                 strcat(fullModuleName, loc + 1);
-                              }
+                                 fullModuleName[0] = 0;
+                              ide.outputView.buildBox.Logf("   %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
                            }
-                           else
-                              fullModuleName[0] = 0;
-                           ide.outputView.buildBox.Logf("   %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
+                        }
+                        else
+                        {
+                           ide.outputView.buildBox.Logf("%s\n", line);
+                           linking = compiling = precompiling = false;
                         }
                      }
                      else
-                     {
                         ide.outputView.buildBox.Logf("%s\n", line);
-                        linking = compiling = precompiling = false;
-                     }
                   }
-                  else
-                     ide.outputView.buildBox.Logf("%s\n", line);
+                  wait = false;
                }
-               wait = false;
             }
-            //printf("Done getting line\n");
             if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
          }
          //printf("Processing Input...\n");
@@ -1911,7 +2005,7 @@ private:
       {
          if(f.GetExitCode() && !numErrors)
          {
-            bool result = f.GetLine(line, sizeof(line)-1);
+            /*bool result = */f.GetLine(line, sizeof(line)-1);
             ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
          }
          else if(buildType != install)
@@ -1998,7 +2092,7 @@ private:
       char configName[MAX_LOCATION];
       DirExpression objDirExp = GetObjDir(compiler, config, bitDepth);
       PathBackup pathBackup { };
-      bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
+      bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
       const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
 
       bool eC_Debug = mode.eC_ToolsDebug;
@@ -2007,6 +2101,7 @@ private:
       char command[MAX_F_STRING*4];
       char * compilerName = CopyString(compiler.name);
       Map<String, NameCollisionInfo> cfgNameCollisions;
+      const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) != 0 ? compiler.objectFileExt : null;
 
       delete lastBuildConfigName;
       lastBuildConfigName = CopyString(config ? config.name : "Common");
@@ -2037,7 +2132,6 @@ private:
          }
          else
          {
-            int len;
             char pushD[MAX_LOCATION];
             char cfDir[MAX_LOCATION];
             GetIDECompilerConfigsDir(cfDir, true, true);
@@ -2046,14 +2140,15 @@ private:
             // Create object dir if it does not exist already
             if(!FileExists(objDirExp.dir).isDirectory)
             {
-               sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s objdir -C \"%s\"%s -f \"%s\"",
+               sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s%s%s objdir -C \"%s\"%s -f \"%s\"",
                      compiler.makeCommand, cfDir,
                      crossCompiling ? " TARGET_PLATFORM=" : "",
                      targetPlatform,
                      bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
                      /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" : */"",
-
-                     compilerName, topNode.path, justPrint ? " -n" : "", makeFilePath);
+                     compilerName,
+                     objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
+                     topNode.path, justPrint ? " -n" : "", makeFilePath);
                if(justPrint)
                   ide.outputView.buildBox.Logf("%s\n", command);
                Execute(command);
@@ -2063,13 +2158,13 @@ private:
 
             for(node : onlyNodes)
             {
-               if(node.GetIsExcluded(config))
+               if(node.GetIsExcludedForCompiler(config, compiler))
                   ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
                else
                {
                   if(!eC_Debug)
                      node.DeleteIntermediateFiles(compiler, config, bitDepth, cfgNameCollisions, mode == cObject ? true : false);
-                  node.GetTargets(config, cfgNameCollisions, objDirExp.dir, makeTargets);
+                  node.GetTargets(config, cfgNameCollisions, objDirExp.dir, compiler.objectFileExt, makeTargets);
                }
             }
          }
@@ -2077,7 +2172,7 @@ private:
 
       if(compiler.type.isVC)
       {
-         bool result = false;
+         //bool result = false;
          char oldwd[MAX_LOCATION];
          GetWorkingDir(oldwd, sizeof(oldwd));
          ChangeWorkingDir(topNode.path);
@@ -2090,7 +2185,7 @@ private:
          {
             ProcessPipeOutputRaw(f);
             delete f;
-            result = true;
+            //result = true;
          }
          ChangeWorkingDir(oldwd);
       }
@@ -2104,7 +2199,7 @@ private:
          GccVersionInfo cxxVersion = GetGccVersionInfo(compiler, compiler.cxxCommand);
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s%s COMPILER=%s %s%s%s-j%d %s%s%s -C \"%s\"%s -f \"%s\"",
+         sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s%s COMPILER=%s%s%s %s%s%s-j%d %s%s%s -C \"%s\"%s -f \"%s\"",
 #if defined(__WIN32__)
                "",
 #else
@@ -2119,7 +2214,9 @@ private:
                bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
                ide.workspace.useValgrind ? " DISABLED_POOLING=1" : "",
                /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
-               compilerName, eC_Debug ? "--always-make " : "",
+               compilerName,
+               objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
+               eC_Debug ? "--always-make " : "",
                ccVersion == post4_8 ? "GCC_CC_FLAGS=-fno-diagnostics-show-caret " : "",
                cxxVersion == post4_8 ? "GCC_CXX_FLAGS=-fno-diagnostics-show-caret " : "",
                numJobs,
@@ -2194,8 +2291,9 @@ private:
       char * compilerName;
       DualPipe f;
       PathBackup pathBackup { };
-      bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
+      bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
       const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
+      const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) ? compiler.objectFileExt : null;
 
       compilerName = CopyString(compiler.name);
       CamelCase(compilerName);
@@ -2208,7 +2306,7 @@ private:
 
       if(compiler.type.isVC)
       {
-         bool result = false;
+         //bool result = false;
          char oldwd[MAX_LOCATION];
          GetWorkingDir(oldwd, sizeof(oldwd));
          ChangeWorkingDir(topNode.path);
@@ -2221,7 +2319,7 @@ private:
          {
             ProcessPipeOutputRaw(f);
             delete f;
-            result = true;
+            //result = true;
          }
          ChangeWorkingDir(oldwd);
          //return result;
@@ -2230,11 +2328,12 @@ private:
       {
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s %sclean%s -C \"%s\"%s -f \"%s\"",
+         sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s%s%s %sclean%s -C \"%s\"%s -f \"%s\"",
                compiler.makeCommand, cfDir,
                crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
                bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
                compilerName,
+               objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
                cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
                topNode.path, justPrint ? " -n": "", makeFilePath);
          if(justPrint)
@@ -2317,18 +2416,7 @@ private:
       if(targetType == staticLibrary || targetType == sharedLibrary)
          strcat(fileName, "$(LP)");
       strcat(fileName, GetTargetFileName(config));
-      switch(targetType)
-      {
-         case executable:
-            strcat(fileName, "$(E)");
-            break;
-         case sharedLibrary:
-            strcat(fileName, "$(SO)$(VER)");
-            break;
-         case staticLibrary:
-            strcat(fileName, "$(A)");
-            break;
-      }
+      strcat(fileName, "$(OUT)");
    }
 
    bool GenerateCrossPlatformMk(File altCrossPlatformMk)
@@ -2419,7 +2507,9 @@ private:
                f.Puts("\n");
                for(e : compiler.environmentVars)
                {
+                  ChangeCh(e.string, '\\', '/');
                   f.Printf("export %s := %s\n", e.name, e.string);
+                  ChangeCh(e.string, '/', '\\');
                }
                f.Puts("\n");
             }
@@ -2427,6 +2517,12 @@ private:
             f.Puts("# TOOLCHAIN\n");
             f.Puts("\n");
 
+            f.Puts("# EXTENSIONS\n");
+            if(compiler.outputFileExt)
+               f.Printf("OUT := %s\n", compiler.outputFileExt);
+            else
+               f.Puts("OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))\n");
+
             if(gnuToolchainPrefix && gnuToolchainPrefix[0])
             {
                f.Printf("GCC_PREFIX := %s\n", gnuToolchainPrefix);
@@ -2459,8 +2555,8 @@ private:
             f.Printf("EAR := %s\n", compiler.earCommand);
 
             f.Puts("AS := $(GCC_PREFIX)as\n");
-            f.Puts("LD := $(GCC_PREFIX)ld\n");
-            f.Puts("AR := $(GCC_PREFIX)ar\n");
+            f.Printf("LD := $(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_LD_FLAGS),$(space)$(GCC_LD_FLAGS),)\n", compiler.ldCommand);
+            f.Printf("AR := $(GCC_PREFIX)%s\n", compiler.arCommand);
             f.Puts("STRIP := $(GCC_PREFIX)strip\n");
             f.Puts("ifdef WINDOWS_TARGET\n");
             f.Puts("WINDRES := $(GCC_PREFIX)windres\n");
@@ -2571,7 +2667,7 @@ private:
       return result;
    }
 
-   bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config)
+   bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config, const char * ldCommand)
    {
       bool result = false;
       char filePath[MAX_LOCATION];
@@ -2605,7 +2701,7 @@ private:
          char targetDirExpNoSpaces[MAX_LOCATION];
          char fixedModuleName[MAX_FILENAME];
          char fixedConfigName[MAX_FILENAME];
-         int c, len;
+         int c;
          int lenObjDirExpNoSpaces, lenTargetDirExpNoSpaces;
          // Non-zero if we're building eC code
          // We'll have to be careful with this when merging configs where eC files can be excluded in some configs and included in others
@@ -2721,7 +2817,7 @@ private:
          if(compilerConfigsDir && compilerConfigsDir[0])
          {
             strcpy(cfDir, compilerConfigsDir);
-            if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
+            if(cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
                strcat(cfDir, "/");
          }
          else
@@ -3273,7 +3369,7 @@ private:
 
          f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
 
-         f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n", containsCXX ? "CXX" : "CC");
+         f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n", ldCommand && ldCommand[0] ? "LD" : containsCXX ? "CXX" : "CC");
          if(!GetDebug(config))
          {
             f.Puts("ifndef NOSTRIP\n");
@@ -3296,7 +3392,11 @@ private:
          if(resNode.files && resNode.files.count && !noResources)
             resNode.GenMakefileAddResources(f, resNode.path, config);
          f.Puts("else\n");
+         f.Puts("ifdef WINDOWS_HOST\n");
          f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)objects.lst $(LIBS)\n");
+         f.Puts("else\n");
+         f.Puts("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
+         f.Puts("endif\n");
          f.Puts("endif\n");
          f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
          f.Puts("ifdef LINUX_TARGET\n");
@@ -3447,7 +3547,7 @@ private:
          f.Printf("cleantarget: objdir%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
          if(numCObjects)
          {
-            f.Printf("\t$(call rmq,%s)\n", "$(OBJ)$(MODULE).main.o $(OBJ)$(MODULE).main.c $(OBJ)$(MODULE).main.ec $(OBJ)$(MODULE).main$(I) $(OBJ)$(MODULE).main$(S)");
+            f.Printf("\t$(call rmq,%s)\n", "$(OBJ)$(MODULE).main$(O) $(OBJ)$(MODULE).main.c $(OBJ)$(MODULE).main.ec $(OBJ)$(MODULE).main$(I) $(OBJ)$(MODULE).main$(S)");
             f.Printf("\t$(call rmq,$(OBJ)symbols.lst)\n");
          }
          f.Printf("\t$(call rmq,$(OBJ)objects.lst)\n");
@@ -3521,10 +3621,10 @@ private:
    void GenMakefilePrintMainObjectRule(File f, ProjectConfig config)
    {
       char extension[MAX_EXTENSION] = "c";
-      char modulePath[MAX_LOCATION];
+      //char modulePath[MAX_LOCATION];
       char fixedModuleName[MAX_FILENAME];
-      DualPipe dep;
-      char command[2048];
+      //DualPipe dep;
+      //char command[2048];
       char objDirNoSpaces[MAX_LOCATION];
       const String objDirExp = GetObjDirExpression(config);
 
@@ -3843,7 +3943,6 @@ void ProjectConfig::LegacyProjectConfigLoad(File f)
       char section[128];
       char subSection[128];
       char * equal;
-      int len;
       uint pos;
 
       pos = f.Tell();
@@ -3979,12 +4078,11 @@ void ProjectConfig::LegacyProjectConfigLoad(File f)
 Project LegacyAsciiLoadProject(File f, const char * filePath)
 {
    Project project = null;
-   ProjectNode node = null;
    int pos;
    char parentPath[MAX_LOCATION];
    char section[128] = "";
    char subSection[128] = "";
-   ProjectNode parent;
+   ProjectNode parent = null;
    bool configurationsPresent = false;
 
    f.Seek(0, start);
@@ -4047,7 +4145,7 @@ Project LegacyAsciiLoadProject(File f, const char * filePath)
                   child.type = file;
                   child.icon = NodeIcons::SelectFileIcon(child.name);
                   parent.files.Add(child);
-                  node = child;
+                  //node = child;
                   //child = null;
                }
                else
@@ -4081,7 +4179,7 @@ Project LegacyAsciiLoadProject(File f, const char * filePath)
                PathCatSlash(parentPath, child.name);
                parent.files.Add(child);
                parent = child;
-               node = child;
+               //node = child;
                //child = null;
             }
             else if(!strcmpi(section, "Configurations"))
@@ -4125,7 +4223,7 @@ Project LegacyAsciiLoadProject(File f, const char * filePath)
             project.filePath = topNodePath;
             parentPath[0] = '\0';
             parent = project.topNode;
-            node = parent;
+            //node = parent;
             strcpy(section, "Target");
             equal = &buffer[6];
             if(equal[0] == ' ')
@@ -4162,7 +4260,7 @@ Project LegacyAsciiLoadProject(File f, const char * filePath)
             child.icon = archiveFile;
             project.resNode = child;
             parent = child;
-            node = child;
+            //node = child;
             strcpy(subSection, buffer);
          }
          else
@@ -4500,7 +4598,7 @@ Project LoadProject(const char * filePath, const char * activeConfigName)
       if(!project)
       {
          JSONParser parser { f = f };
-         JSONResult result = parser.GetObject(class(Project), &project);
+         /*JSONResult result = */parser.GetObject(class(Project), &project);
          if(project)
          {
             char insidePath[MAX_LOCATION];
@@ -4582,6 +4680,7 @@ Project LoadProject(const char * filePath, const char * activeConfigName)
    return project;
 }
 
+#ifndef MAKEFILE_GENERATOR
 static GccVersionInfo GetGccVersionInfo(CompilerConfig compiler, const String compilerCommand)
 {
    GccVersionInfo result = unknown;
@@ -4653,3 +4752,4 @@ static enum GccVersionInfo
       return result;
    }
 };
+#endif