ecere/JSON;eCON: Splitting WriteJSONObject / WriteECONObject
[sdk] / ide / src / project / Project.ec
index 99a053d..92bd356 100644 (file)
@@ -406,7 +406,7 @@ static bool IsLinkerOption(String s)
 
 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
 
-enum GenMakefilePrintTypes { objects, cObjects, symbols, imports, sources, resources, eCsources, rcSources };
+enum GenMakefilePrintTypes { noPrint, objects, cObjects, symbols, imports, sources, resources, eCsources, rcSources };
 
 define WorkspaceExtension = "ews";
 define ProjectExtension = "epj";
@@ -599,10 +599,10 @@ void OutputCleanActions(File f, const char * name, int parts)
    {
       int c;
       for(c=0; c<parts; c++)
-         f.Printf("\t$(call rmq,$(_%s%d))\n", name, c+1);
+         f.Printf("\t$(call rm,$(_%s%d))\n", name, c+1);
    }
    else
-      f.Printf("\t$(call rmq,$(_%s))\n", name);
+      f.Printf("\t$(call rm,$(_%s))\n", name);
 }
 
 enum LineOutputMethod { inPlace, newLine, lineEach };
@@ -688,6 +688,15 @@ CompilerConfig GetCompilerConfig()
 #endif
 }
 
+int GetBitDepth()
+{
+#ifdef MAKEFILE_GENERATOR
+   return 0; // todo: improve this somehow? add bit depth command line option?
+#else
+   return ide.workspace.bitDepth;
+#endif
+}
+
 define localTargetType = config && config.options && config.options.targetType ?
             config.options.targetType : options && options.targetType ?
             options.targetType : TargetTypes::executable;
@@ -2560,7 +2569,8 @@ private:
             f.Printf("EAR := %s\n", compiler.earCommand);
 
             f.Puts("AS := $(GCC_PREFIX)as\n");
-            f.Printf("LD := $(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_LD_FLAGS),$(space)$(GCC_LD_FLAGS),)\n", compiler.ldCommand);
+            f.Printf("LD := $(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_LD_FLAGS),$(space)$(GCC_LD_FLAGS),)\n",
+                  compiler.ldCommand && compiler.ldCommand[0] ? compiler.ldCommand : "$(if $(CONTAINS_CXX),$(CXX),$(CC))");
             f.Printf("AR := $(GCC_PREFIX)%s\n", compiler.arCommand);
             f.Puts("STRIP := $(GCC_PREFIX)strip\n");
             f.Puts("ifdef WINDOWS_TARGET\n");
@@ -2672,7 +2682,7 @@ private:
       return result;
    }
 
-   bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config, const char * ldCommand)
+   bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config)
    {
       bool result = false;
       char filePath[MAX_LOCATION];
@@ -2763,6 +2773,9 @@ private:
          f.Printf("MODULE := %s\n", fixedModuleName);
          f.Printf("VERSION := %s\n", property::moduleVersion);
          f.Printf("CONFIG := %s\n", fixedConfigName);
+         topNode.GenMakefilePrintNode(f, this, noPrint, null, null, config, &containsCXX);
+         if(containsCXX)
+            f.Puts("CONTAINS_CXX := defined\n");
          f.Puts("ifndef COMPILER\n" "COMPILER := default\n" "endif\n");
          f.Puts("\n");
 
@@ -2984,7 +2997,7 @@ private:
             f.Puts("endif\n\n");
          }
 
-         numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, &containsCXX);
+         numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, null);
          if(numObjects)
             objectsParts = OutputFileList(f, "_OBJECTS", listItems, varStringLenDiffs, null);
          f.Printf("OBJECTS =%s%s%s%s\n",
@@ -3261,7 +3274,7 @@ private:
 
          f.Puts("objdir:\n");
          if(!relObjDir)
-            f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdirq,$(OBJ)))\n");
+            f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdir,$(OBJ)))\n");
          if(numCObjects)
          {
             f.Puts("\t$(if $(ECERE_SDK_SRC),$(if $(wildcard $(call escspace,$(ECERE_SDK_SRC)/crossplatform.mk)),,@$(call echo,Ecere SDK Source Warning: The value of ECERE_SDK_SRC is pointing to an incorrect ($(ECERE_SDK_SRC)) location.)),)\n");
@@ -3319,7 +3332,7 @@ private:
          if(!sameOrRelObjTargetDirs)
          {
             f.Puts("targetdir:\n");
-               f.Printf("\t$(if $(wildcard %s),,$(call mkdirq,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
+               f.Printf("\t$(if $(wildcard %s),,$(call mkdir,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
             f.Puts("\n");
          }
 
@@ -3327,7 +3340,7 @@ private:
          {
             // Main Module (Linking) for ECERE C modules
             f.Puts("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
-            f.Printf("\t@$(call rmq,$(OBJ)symbols.lst)\n");
+            f.Printf("\t@$(call rm,$(OBJ)symbols.lst)\n");
             f.Printf("\t@$(call touch,$(OBJ)symbols.lst)\n");
             OutputFileListActions(f, "SYMBOLS", eCsourcesParts, "$(OBJ)symbols.lst");
             OutputFileListActions(f, "IMPORTS", eCsourcesParts, "$(OBJ)symbols.lst");
@@ -3357,7 +3370,7 @@ private:
          f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
                rcSourcesParts ? " $(RCSOURCES)" : "", sameOrRelObjTargetDirs ? "" : " targetdir");
 
-         f.Printf("\t@$(call rmq,$(OBJ)objects.lst)\n");
+         f.Printf("\t@$(call rm,$(OBJ)objects.lst)\n");
          f.Printf("\t@$(call touch,$(OBJ)objects.lst)\n");
          OutputFileListActions(f, "_OBJECTS", objectsParts, "$(OBJ)objects.lst");
          if(rcSourcesParts)
@@ -3374,7 +3387,7 @@ private:
 
          f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
 
-         f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n", ldCommand && ldCommand[0] ? "LD" : containsCXX ? "CXX" : "CC");
+         f.Puts("\t$(LD) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
          if(!GetDebug(config))
          {
             f.Puts("ifndef NOSTRIP\n");
@@ -3552,17 +3565,17 @@ 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,$(OBJ)symbols.lst)\n");
+            f.Printf("\t$(call rm,%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 rm,$(OBJ)symbols.lst)\n");
          }
-         f.Printf("\t$(call rmq,$(OBJ)objects.lst)\n");
-         f.Puts("\t$(call rmq,$(TARGET))\n");
+         f.Printf("\t$(call rm,$(OBJ)objects.lst)\n");
+         f.Puts("\t$(call rm,$(TARGET))\n");
          f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
          f.Puts("ifdef LINUX_TARGET\n");
          f.Puts("ifdef LINUX_HOST\n");
          // TODO?: support symlinks for longer version numbers
-         f.Puts("\t$(call rmq,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
-         f.Puts("\t$(call rmq,$(OBJ)$(LP)$(MODULE)$(SO))\n");
+         f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
+         f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO))\n");
          f.Puts("endif\n");
          f.Puts("endif\n");
          f.Puts("endif\n");
@@ -3587,16 +3600,16 @@ private:
          f.Puts("\n");
 
          f.Puts("realclean: cleantarget\n");
-         f.Puts("\t$(call rmrq,$(OBJ))\n");
+         f.Puts("\t$(call rmr,$(OBJ))\n");
          if(!sameOrRelObjTargetDirs)
-            f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
+            f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
          f.Puts("\n");
 
          f.Puts("distclean: cleantarget\n");
          if(!sameOrRelObjTargetDirs)
-            f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
+            f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
          if(!relObjDir)
-            f.Puts("\t$(call rmrq,obj/)\n");
+            f.Puts("\t$(call rmr,obj/)\n");
 
          delete f;