ide/Project; ecere/sys/FileMonitor: (#1113) Fixed Crash on closing IDE (from dock...
[sdk] / ide / src / project / Project.ec
index 2b2d3ae..a968ce2 100644 (file)
@@ -587,9 +587,11 @@ void OutputFileListActions(File f, const char * name, int parts, const char * fi
    {
       int c;
       for(c=0; c<parts; c++)
-         f.Printf("\t@$(call echo,$(%s%d)) >> %s\n", name, c+1, fileName);
-   } else if(parts) {
-      f.Printf("\t@$(call echo,$(%s)) >> %s\n", name, fileName);
+         f.Printf("\t$(call addtolistfile,$(%s%d),%s)\n", name, c+1, fileName);
+   }
+   else if(parts)
+   {
+      f.Printf("\t$(call addtolistfile,$(%s),%s)\n", name, fileName);
    }
 }
 
@@ -959,7 +961,7 @@ private:
          }
          return true;
       }
-      return true;
+      return !ide.destroyed;
    }
 
 #endif
@@ -1230,7 +1232,7 @@ private:
          files.Remove(resNode);
          version = 0.2f;
 
-         WriteJSONObject(f, class(Project), this, 0, false);
+         WriteJSONObject(f, class(Project), this, 0);
 
          files.Add(resNode);
 
@@ -2531,6 +2533,11 @@ private:
             f.Puts("# TOOLCHAIN\n");
             f.Puts("\n");
 
+            f.Puts("# OPTIONS\n");
+            if(compiler.resourcesDotEar)
+               f.Puts("USE_RESOURCES_EAR := defined\n");
+            f.Puts("\n");
+
             f.Puts("# EXTENSIONS\n");
             if(compiler.outputFileExt)
                f.Printf("OUT := %s\n", compiler.outputFileExt);
@@ -3022,6 +3029,13 @@ private:
             resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config, null);
          OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs, null);
 
+         f.Puts("ifdef USE_RESOURCES_EAR\n");
+         f.Puts("RESOURCES_EAR = $(OBJ)resources.ear\n");
+         f.Puts("else\n");
+         f.Puts("RESOURCES_EAR = $(RESOURCES)\n");
+         f.Puts("endif\n");
+         f.Puts("\n");
+
          f.Puts("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n");
          f.Puts("\n");
          if((config && config.options && config.options.libraries) ||
@@ -3357,6 +3371,15 @@ private:
             f.Puts("\n");
          }
 
+         if(resNode.files && resNode.files.count && !noResources)
+         {
+            f.Puts("ifdef USE_RESOURCES_EAR\n");
+            f.Puts("$(RESOURCES_EAR): $(RESOURCES) | objdir\n");
+               resNode.GenMakefileAddResources(f, resNode.path, config, "RESOURCES_EAR");
+            f.Puts("endif\n");
+            f.Puts("\n");
+         }
+
          // *** Target ***
 
          // This would not rebuild the target on updated objects
@@ -3367,7 +3390,7 @@ private:
          f.Puts("$(OBJECTS): | objdir\n");
 
          // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
-         f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
+         f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES_EAR) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
                rcSourcesParts ? " $(RCSOURCES)" : "", sameOrRelObjTargetDirs ? "" : " targetdir");
 
          f.Printf("\t@$(call rm,$(OBJ)objects.lst)\n");
@@ -3381,7 +3404,7 @@ private:
          }
          if(numCObjects)
          {
-            f.Printf("\t@$(call echo,$(OBJ)$(MODULE).main$(O)) >> $(OBJ)objects.lst\n");
+            f.Printf("\t$(call addtolistfile,$(OBJ)$(MODULE).main$(O),$(OBJ)objects.lst)\n");
             OutputFileListActions(f, "ECOBJECTS", eCsourcesParts, "$(OBJ)objects.lst");
          }
 
@@ -3408,7 +3431,11 @@ private:
             }
          }
          if(resNode.files && resNode.files.count && !noResources)
-            resNode.GenMakefileAddResources(f, resNode.path, config);
+         {
+            f.Puts("ifndef USE_RESOURCES_EAR\n");
+            resNode.GenMakefileAddResources(f, resNode.path, config, "TARGET");
+            f.Puts("endif\n");
+         }
          f.Puts("else\n");
          f.Puts("ifdef WINDOWS_HOST\n");
          f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)objects.lst $(LIBS)\n");
@@ -3597,6 +3624,12 @@ private:
             OutputCleanActions(f, "IMPORTS", eCsourcesParts);
             OutputCleanActions(f, "SYMBOLS", eCsourcesParts);
          }
+         if(resNode.files && resNode.files.count && !noResources)
+         {
+            f.Puts("ifdef USE_RESOURCES_EAR\n");
+            f.Printf("\t$(call rm,$(RESOURCES_EAR))\n");
+            f.Puts("endif\n");
+         }
          f.Puts("\n");
 
          f.Puts("realclean: cleantarget\n");
@@ -3610,6 +3643,9 @@ private:
             f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
          if(!relObjDir)
             f.Puts("\t$(call rmr,obj/)\n");
+         f.Puts("\t$(call rmr,.configs/)\n");
+         f.Puts("\t$(call rm,*.ews)\n");
+         f.Puts("\t$(call rm,*.Makefile)\n");
 
          delete f;
 
@@ -4615,7 +4651,7 @@ Project LoadProject(const char * filePath, const char * activeConfigName)
       project = LegacyBinaryLoadProject(f, filePath);
       if(!project)
       {
-         JSONParser parser { f = f };
+         ECONParser parser { f = f };
          /*JSONResult result = */parser.GetObject(class(Project), &project);
          if(project)
          {