ide/Project: (#241) Seeing GCC warnings when building from IDE
[sdk] / ide / src / project / Project.ec
index 5d05fbe..77463d5 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);
@@ -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);
@@ -1479,7 +1483,7 @@ private:
       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 : "";
 
@@ -1547,7 +1551,7 @@ private:
                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')
+               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] == ':')
                {
@@ -1650,7 +1654,7 @@ private:
                   if(module) module++;
                   if(module)
                   {
-                     byte * tokens[1];
+                     char * tokens[1];
                      char * dashF = strstr(module, "-F ");
                      if(dashF)
                      {
@@ -1787,7 +1791,53 @@ private:
                               numErrors++;
                            }
                            else if(compilingEC == 1 || (objDir && objDir == moduleName))
-                              continue;
+                           {
+                              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, "note: expected 'struct ") || strstr(line, "note: expected ‘struct "))
+                              {
+                                 #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; };
+
+                                 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;
+                                 }
+                              }
+                              // Pointers warnings (eC should already warn about relevant problems, more forgiving for function pointers, should cast in generated code)
+                              else if((strstr(line, "note: expected '") || strstr(line, "note: expected ‘")) && strstr(line, "(*)")) skip = true;
+                              else if(strstr(line, "expected 'void **") || strstr(line, "expected ‘void **")) skip = true;
+                              else if(strstr(line, "from incompatible pointer type")) skip = true;
+                              else if(strstr(line, "comparison of distinct pointer types lacks a cast")) skip = true;
+
+                              // Things being defined for potential use -- Should mark as unused
+                              else if(strstr(line, "unused variable") && (strstr(line, "'__") || strstr(line, "‘__") || strstr(line, "'class'") || strstr(line, "‘class’"))) skip = true;
+                              else if(strstr(line, "defined but not used") && strstr(line, "__ecereProp")) skip = true;
+
+                              // 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++;
@@ -1801,7 +1851,7 @@ private:
                         {
                            char fullModuleName[MAX_LOCATION];
                            FileAttribs found = 0;
-                           Project foundProject = this;
+                           //Project foundProject = this;
                            if(moduleName[0])
                            {
                               char * loc = strstr(moduleName, ":");
@@ -1833,7 +1883,7 @@ private:
                                           found = FileExists(fullModuleName);
                                           if(found)
                                           {
-                                             foundProject = prj;
+                                             //foundProject = prj;
                                              break;
                                           }
                                        }
@@ -1851,7 +1901,7 @@ private:
                                              found = FileExists(fullModuleName);
                                              if(found)
                                              {
-                                                foundProject = prj;
+                                                //foundProject = prj;
                                                 break;
                                              }
                                           }
@@ -1911,7 +1961,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 +2048,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;
@@ -2037,7 +2087,6 @@ private:
          }
          else
          {
-            int len;
             char pushD[MAX_LOCATION];
             char cfDir[MAX_LOCATION];
             GetIDECompilerConfigsDir(cfDir, true, true);
@@ -2046,7 +2095,7 @@ 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 objdir -C \"%s\"%s -f \"%s\"",
                      compiler.makeCommand, cfDir,
                      crossCompiling ? " TARGET_PLATFORM=" : "",
                      targetPlatform,
@@ -2077,7 +2126,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 +2139,7 @@ private:
          {
             ProcessPipeOutputRaw(f);
             delete f;
-            result = true;
+            //result = true;
          }
          ChangeWorkingDir(oldwd);
       }
@@ -2194,7 +2243,7 @@ private:
       char * compilerName;
       DualPipe f;
       PathBackup pathBackup { };
-      bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
+      bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
       const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
 
       compilerName = CopyString(compiler.name);
@@ -2208,7 +2257,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 +2270,7 @@ private:
          {
             ProcessPipeOutputRaw(f);
             delete f;
-            result = true;
+            //result = true;
          }
          ChangeWorkingDir(oldwd);
          //return result;
@@ -2605,7 +2654,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 +2770,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
@@ -3521,10 +3570,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 +3892,6 @@ void ProjectConfig::LegacyProjectConfigLoad(File f)
       char section[128];
       char subSection[128];
       char * equal;
-      int len;
       uint pos;
 
       pos = f.Tell();
@@ -3979,7 +4027,7 @@ void ProjectConfig::LegacyProjectConfigLoad(File f)
 Project LegacyAsciiLoadProject(File f, const char * filePath)
 {
    Project project = null;
-   ProjectNode node = null;
+   //ProjectNode node = null;
    int pos;
    char parentPath[MAX_LOCATION];
    char section[128] = "";
@@ -4047,7 +4095,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 +4129,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 +4173,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 +4210,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 +4548,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 +4630,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 +4702,4 @@ static enum GccVersionInfo
       return result;
    }
 };
+#endif