2 public import static "ecere"
7 #ifndef MAKEFILE_GENERATOR
9 // We should have the .sln/.vcproj generation even on other platforms
10 // e.g. detect from an environment variable pointing to a Windows drive
16 import "ProjectConfig"
22 static void DummyFunction()
30 extern int __ecereVMethodID_class_OnCompare;
31 extern int __ecereVMethodID_class_OnFree;
34 define cfDir = "C:/temp/";
36 define cfDir = "/home/redj/.ecereIDE/";
39 IDESettings ideSettings;
41 IDESettingsContainer settingsContainer
44 dataOwner = &ideSettings;
45 dataClass = class(IDESettings);
47 void OnLoad(GlobalSettingsData data)
49 IDESettings settings = (IDESettings)data;
50 #ifndef MAKEFILE_GENERATOR
51 globalSettingsDialog.ideSettings = settings;
52 ide.UpdateRecentMenus();
53 // ide.UpdateMakefiles(); -- can't really regenerate on Load since all recent menus changes will happen
58 #ifdef MAKEFILE_GENERATOR
59 CompilerConfig defaultCompiler;
62 // LEGACY BINARY EPJ LOADING
64 SetBool ParseTrueFalseValue(char * string)
66 if(!strcmpi(string, "True")) return true;
70 void ParseArrayValue(Array<String> array, char * equal)
72 char * start, * comma;
74 string = CopyString(equal);
78 comma = strstr(start, ",");
81 array.Add(CopyString(start));
91 void ProjectNode::LegacyBinaryLoadNode(File f)
96 f.Read(&len, sizeof(len), 1);
97 name = new char[len+1];
99 f.Read(name, sizeof(char), len+1);
100 f.Read(&len, sizeof(len), 1);
102 path = new char[len+1];
103 f.Read(path, sizeof(char), len+1);
106 fileName = new char[fileNameLen+2];
107 strcpy(fileName, path);
108 if(fileName[0]) strcat(fileName, "/");
109 strcat(fileName, name);
112 f.Read(&type, sizeof(type), 1);
113 f.Read(&count, sizeof(count), 1);
118 icon = NodeIcons::SelectFileIcon(name);
123 icon = NodeIcons::SelectNodeIcon(type);
126 if(count && !files) files = { };
127 for(c = 0; c < count; c++)
129 ProjectNode child { };
132 child.indent = indent + 1;
133 LegacyBinaryLoadNode(child, f);
137 /*void LegacyBinarySaveNode(File f)
142 f.Write(&len, sizeof(len), 1);
143 f.Write(name, sizeof(char), len+1);
147 // Projects Absolute Path Are Not Saved
149 f.Write(&len, sizeof(len), 1);
150 f.Write(&len, sizeof(char), 1);
155 f.Write(&len, sizeof(len), 1);
156 f.Write(path, sizeof(char), len+1);
158 f.Write(&type, sizeof(type), 1);
159 f.Write(&children.count, sizeof(children.count), 1);
160 for(child = children.first; child; child.next)
164 void ProjectNode::LegacyAsciiSaveNode(File f, char * indentation, char * insidePath)
167 char printPath[MAX_LOCATION];
169 if(type == project && (files.count /*|| preprocessorDefs.first*/))
171 f.Printf("\n Files\n");
173 else if(type == file)
175 if(!strcmp(path, insidePath))
176 f.Printf("%s - %s\n", indentation, name);
179 strcpy(printPath, path);
180 len = strlen(printPath);
182 if(printPath[len-1] != '/')
183 strcat(printPath, "/");
184 strcat(printPath, name);
185 f.Printf("%s = %s\n", indentation, printPath);
188 f.Printf("\nError\n\n");
190 else if(type == folder)
192 f.Printf("%s + %s\n", indentation, name);
194 else if(type == resources && files.count)
196 PathCatSlash(insidePath, path);
197 f.Printf("\n%sResources\n", indentation);
199 f.Printf("%s Path = %s\n", indentation, path);
202 /*if(buildExclusions.first && type != project)
204 for(item = buildExclusions.first; item; item = item.next)
206 if(item == buildExclusions.first)
207 f.Printf("%s Build Exclusions = %s", indentation, item.name);
209 f.Printf(", %s", item.name);
214 if(preprocessorDefs.first && (type == project || ((type == file || type == folder) && !isInResources)))
216 for(item = preprocessorDefs.first; item; item = item.next)
218 if(item == preprocessorDefs.first)
219 f.Printf("%s%s Preprocessor Definitions = %s", indentation, type == project ? "" : " ", item.name);
221 f.Printf(", %s", item.name);
227 if(type == project && (files.count /*|| preprocessorDefs.first*/))
231 LegacyAsciiSaveNode(child, f, indentation, insidePath);
233 else if(type == folder)
235 strcat(indentation, " ");
236 // WHAT WAS THIS: strcpy(printPath, path);
237 // TOCHECK: why is Unix/PathCat not used here
238 len = strlen(insidePath);
240 if(insidePath[len-1] != '/')
241 strcat(insidePath, "/");
242 strcat(insidePath, name);
245 LegacyAsciiSaveNode(child, f, indentation, insidePath);
246 f.Printf("%s -\n", indentation);
247 indentation[strlen(indentation) - 3] = '\0';
248 StripLastDirectory(insidePath, insidePath);
250 else if(type == resources && files.count)
254 LegacyAsciiSaveNode(child, f, indentation, insidePath);
255 StripLastDirectory(insidePath, insidePath);
260 void ProjectConfig::LegacyProjectConfigSave(File f)
262 char * indentation = " ";
264 //f.Printf("\n * Common\n");
266 f.Printf("\n + %s\n", name);
267 f.Printf("\n Compiler\n\n");
268 if(objDir.expression[0])
269 f.Printf("%sIntermediate Directory = %s\n", indentation, objDir.expression);
270 f.Printf("%sDebug = %s\n", indentation, (options.debug == true) ? "True" : "False");
271 switch(options.optimization)
273 // case none: f.Printf("%sOptimize = %s\n", indentation, "None"); break;
274 case speed: f.Printf("%sOptimize = %s\n", indentation, "Speed"); break;
275 case size: f.Printf("%sOptimize = %s\n", indentation, "Size"); break;
277 f.Printf("%sAllWarnings = %s\n", indentation, (options.warnings == all) ? "True" : "False");
279 f.Printf("%sProfile = %s\n", indentation, (options.profile == true) ? "True" : "False");
280 if(options.memoryGuard == true)
281 f.Printf("%sMemoryGuard = %s\n", indentation, (options.memoryGuard == true) ? "True" : "False");
282 if(options.strictNameSpaces == true)
283 f.Printf("%sStrict Name Spaces = %s\n", indentation, (options.strictNameSpaces == true) ? "True" : "False");
284 if(options.defaultNameSpace && strlen(options.defaultNameSpace))
285 f.Printf("%sDefault Name Space = %s\n", indentation, options.defaultNameSpace);
286 TOFIX: Compiler Bug {
287 if(options.preprocessorDefinitions.count)
290 for(item : options.preprocessorDefinitions)
294 f.Printf("\n%sPreprocessor Definitions = %s", indentation, item);
298 f.Printf(", %s", item);
303 if(options.includeDirs.count)
305 f.Printf("\n%sInclude Directories\n", indentation);
306 for(item : options.includeDirs)
307 f.Printf("%s - %s\n", indentation, name);
311 f.Printf("\n%sLinker\n\n", indentation);
312 f.Printf("%sTarget Name = %s\n", indentation, options.targetFileName);
313 switch(options.targetType)
315 case executable: f.Printf("%sTarget Type = %s\n", indentation, "Executable"); break;
316 case sharedLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Shared"); break;
317 case staticLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Static"); break;
319 if(targetDir.expression[0])
320 f.Printf("%sTarget Directory = %s\n", indentation, targetDir.expression);
322 f.Printf("%sConsole = %s\n", indentation, options.console ? "True" : "False");
324 f.Printf("%sCompress = %s\n", indentation, options.compress ? "True" : "False");
325 if(options.libraries.count)
328 for(item : options.libraries)
332 f.Printf("\n%sLibraries = %s", indentation, name);
336 f.Printf(", %s", item);
340 if(options.libraryDirs.count)
342 f.Printf("\n%sLibrary Directories\n\n", indentation);
343 for(item : options.libraryDirs)
344 f.Printf(" - %s\n", indentation, item);
348 void LegacyAsciiSaveProject(File f, Project project)
350 char indentation[128*3];
351 char path[MAX_LOCATION];
353 f.Printf("\nECERE Project File : Format Version 0.1b\n");
354 f.Printf("\nDescription\n%s\n.\n", project.description);
355 f.Printf("\nLicense\n%s\n.\n", project.license);
356 f.Printf("\nModule Name = %s\n", project.moduleName);
357 f.Printf("\n Configurations\n");
358 //////////////////////////////////////commonConfig.Save(f, true);
359 for(cfg : project.configurations)
360 LegacyProjectConfigSave(cfg, f);
362 strcpy(indentation, " ");
364 LegacyAsciiSaveNode(project.topNode, f, indentation, path);
370 // *** NEW JSON PROJECT FORMAT ***
371 public enum ProjectNodeType { file, folder };
373 // *******************************
375 define PEEK_RESOLUTION = (18.2 * 10);
381 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
383 enum GenMakefilePrintTypes { objects, cObjects, symbols, imports, sources, resources, eCsources };
385 define WorkspaceExtension = "ews";
386 define ProjectExtension = "epj";
388 define stringInFileIncludedFrom = "In file included from ";
390 void ReplaceSpaces(char * output, char * source)
395 for(c = 0, dc = 0; (ch = source[c]); c++, dc++)
397 if(ch == ' ') output[dc++] = '\\';
400 if(ch == '(' || ch == ')') output[dc++] = '\\';
410 void ReplaceUnwantedMakeChars(char * output, char * source)
415 for(c = 0, dc = 0; (ch = source[c]); c++, dc++)
419 if(ch == '(' || ch == ')') output[dc++] = '\\';
432 static void OutputNoSpace(File f, char * source)
434 char * output = new char[strlen(source)+1024];
435 ReplaceSpaces(output, source);
440 enum ListOutputMethod { inPlace, newLine, lineEach };
442 int OutputFileList(File f, char * name, Array<String> list, Map<String, int> varStringLenDiffs, char * prefix)
445 const int breakListLength = 1536;
446 const int breakLineLength = 78; // TODO: turn this into an option.
448 int c, len, itemCount = 0;
449 Array<int> breaks { };
453 MapNode<String, int> mn;
454 for(c=0; c<list.count; c++)
456 len = strlen(list[c]) + 3;
457 if(strstr(list[c], "$(") && varStringLenDiffs && varStringLenDiffs.count)
459 for(mn = varStringLenDiffs.root.minimum; mn; mn = mn.next)
461 if(strstr(list[c], mn.key))
465 if(charCount + len > breakListLength)
467 breaks.Add(itemCount);
475 breaks.Add(itemCount);
476 numOfBreaks = breaks.count;
481 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
482 for(c=0; c<numOfBreaks; c++)
483 f.Printf(" $(%s%d)", name, c+1);
487 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
493 for(c=0; c<numOfBreaks; c++)
496 f.Printf("%s%d =", name, c+1);
499 itemCount = breaks[c];
500 for(n=offset; n<offset+itemCount; n++)
502 if(false) // TODO: turn this into an option.
504 int itemLen = strlen(list[n]);
505 if(len > 3 && len + itemLen > breakLineLength)
507 f.Printf(" \\\n\t%s", list[n]);
513 f.Printf(" %s", list[n]);
517 f.Printf(" \\\n\t%s", list[n]);
532 void OutputCleanActions(File f, char * name, int parts)
537 for(c=0; c<parts; c++)
538 f.Printf("\t$(call rmq,$(%s%d))\n", name, c+1);
541 f.Printf("\t$(call rmq,$(%s))\n", name);
544 void OutputListOption(File f, char * option, Array<String> list, ListOutputMethod method, bool noSpace)
548 if(method == newLine)
552 if(method == lineEach)
554 f.Printf(" -%s", option);
556 OutputNoSpace(f, item);
558 f.Printf("%s", item);
563 static void OutputLibraries(File f, Array<String> libraries)
565 for(item : libraries)
567 char ext[MAX_EXTENSION];
568 char temp[MAX_LOCATION];
570 GetExtension(item, ext);
571 if(!strcmp(ext, "o") || !strcmp(ext, "a"))
575 if(!strcmp(ext, "so") || !strcmp(ext, "dylib"))
577 if(!strncmp(item, "lib", 3))
578 strcpy(temp, item + 3);
581 StripExtension(temp);
590 void CamelCase(char * string)
592 int c, len = strlen(string);
593 for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
594 string[c] = (char)tolower(string[c]);
597 CompilerConfig GetCompilerConfig()
599 #ifndef MAKEFILE_GENERATOR
600 CompilerConfig compiler = null;
601 if(ide && ide.workspace)
602 compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
605 incref defaultCompiler;
606 return defaultCompiler;
610 define localTargetType = config && config.options && config.options.targetType ?
611 config.options.targetType : options && options.targetType ?
612 options.targetType : TargetTypes::executable;
613 define localWarnings = config && config.options && config.options.warnings ?
614 config.options.warnings : options && options.warnings ?
615 options.warnings : WarningsOption::unset;
616 define localDebug = config && config.options && config.options.debug ?
617 config.options.debug : options && options.debug ?
618 options.debug : SetBool::unset;
619 define localMemoryGuard = config && config.options && config.options.memoryGuard ?
620 config.options.memoryGuard : options && options.memoryGuard ?
621 options.memoryGuard : SetBool::unset;
622 define localNoLineNumbers = config && config.options && config.options.noLineNumbers ?
623 config.options.noLineNumbers : options && options.noLineNumbers ?
624 options.noLineNumbers : SetBool::unset;
625 define localProfile = config && config.options && config.options.profile ?
626 config.options.profile : options && options.profile ?
627 options.profile : SetBool::unset;
628 define localOptimization = config && config.options && config.options.optimization ?
629 config.options.optimization : options && options.optimization ?
630 options.optimization : OptimizationStrategy::none;
631 define localDefaultNameSpace = config && config.options && config.options.defaultNameSpace ?
632 config.options.defaultNameSpace : options && options.defaultNameSpace ?
633 options.defaultNameSpace : null;
634 define localStrictNameSpaces = config && config.options && config.options.strictNameSpaces ?
635 config.options.strictNameSpaces : options && options.strictNameSpaces ?
636 options.strictNameSpaces : SetBool::unset;
637 // TODO: I would rather have null here, check if it'll be ok, have the property return "" if required
638 define localTargetFileName = config && config.options && config.options.targetFileName ?
639 config.options.targetFileName : options && options.targetFileName ?
640 options.targetFileName : "";
641 define localTargetDirectory = config && config.options && config.options.targetDirectory && config.options.targetDirectory[0] ?
642 config.options.targetDirectory : options && options.targetDirectory && options.targetDirectory[0] ?
643 options.targetDirectory : null;
644 define settingsTargetDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
645 ideSettings.projectDefaultIntermediateObjDir[0] ?
646 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
647 define localObjectsDirectory = config && config.options && config.options.objectsDirectory && config.options.objectsDirectory[0] ?
648 config.options.objectsDirectory : options && options.objectsDirectory && options.objectsDirectory[0] ?
649 options.objectsDirectory : null;
650 define settingsObjectsDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
651 ideSettings.projectDefaultIntermediateObjDir[0] ?
652 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
653 define localConsole = config && config.options && config.options.console ?
654 config.options.console : options && options.console ?
655 options.console : SetBool::unset;
656 define localCompress = config && config.options && config.options.compress ?
657 config.options.compress : options && options.compress ?
658 options.compress : SetBool::unset;
660 define platformTargetType =
661 configPOs && configPOs.options && configPOs.options.targetType && configPOs.options.targetType != localTargetType ?
662 configPOs.options.targetType :
663 projectPOs && projectPOs.options && projectPOs.options.targetType && projectPOs.options.targetType != localTargetType ?
664 projectPOs.options.targetType : TargetTypes::unset;
667 // we should have some kind of direct mapping between a platform and it's makefile variable
668 char * PlatformToMakefileVariable(Platform platform)
670 return platform == win32 ? "WINDOWS" :
671 platform == tux ? "LINUX" :
672 platform == apple ? "OSX"/*"APPLE"*/ :
676 char * TargetTypeToMakefileVariable(TargetTypes targetType)
678 return targetType == executable ? "executable" :
679 targetType == sharedLibrary ? "sharedlib" :
680 targetType == staticLibrary ? "staticlib" :
684 // Move this to ProjectConfig? null vs Common to consider...
685 char * GetConfigName(ProjectConfig config)
687 return config ? config.name : "Common";
690 class Project : struct
692 class_no_expansion; // To use Find on the Container<Project> in Workspace::projects
693 // We might want to tweak this default behavior of regular classes ?
694 // Expansion/the current default kind of Find matching we want for things like BitmapResource, FontResource (Also regular classes)
699 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
700 property Array<PlatformOptions> platforms
702 get { return platforms; }
705 if(platforms) { platforms.Free(); delete platforms; }
708 List<PlatformOptions> empty { };
709 Iterator<PlatformOptions> it { value };
711 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
712 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
722 if(p.options && !p.options.isEmpty)
729 List<ProjectConfig> configurations;
730 LinkList<ProjectNode> files;
731 String resourcesPath;
732 LinkList<ProjectNode> resources;
734 property char * description
736 set { delete description; if(value && value[0]) description = CopyString(value); }
737 get { return description ? description : ""; }
738 isset { return description != null && description[0]; }
741 property char * license
743 set { delete license; if(value && value[0]) license = CopyString(value); }
744 get { return license ? license : ""; }
745 isset { return license != null && license[0]; }
749 // topNode.name holds the file name (.epj)
750 ProjectOptions options;
751 Array<PlatformOptions> platforms;
752 ProjectNode topNode { type = project, icon = epjFile, files = LinkList<ProjectNode>{ }, project = this };
755 ProjectConfig config;
757 // This is the file name stripped of the epj extension
758 // It should NOT be edited, saved or loaded anywhere
766 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
767 topNode.configurations = null;
768 topNode.platforms = null;
769 topNode.options = null;
772 if(platforms) { platforms.Free(); delete platforms; }
773 if(configurations) { configurations.Free(); delete configurations; }
774 if(files) { files.Free(); delete files; }
775 if(resources) { resources.Free(); delete resources; }
777 delete resourcesPath;
787 property ProjectConfig config
793 topNode.info = CopyString(GetConfigName(config));
796 property char * filePath
802 char string[MAX_LOCATION];
803 GetLastDirectory(value, string);
805 topNode.name = CopyString(string);
806 StripExtension(string);
808 name = CopyString(string);
809 StripLastDirectory(value, string);
811 topNode.path = CopyString(string);
813 filePath = CopyString(value);
818 TargetTypes GetTargetType(ProjectConfig config)
820 TargetTypes targetType = localTargetType;
824 bool GetTargetTypeIsSetByPlatform(ProjectConfig config)
827 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
829 PlatformOptions projectPOs, configPOs;
830 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
831 if(platformTargetType)
838 char * GetObjDirExpression(CompilerConfig compiler, ProjectConfig config)
840 // TODO: Support platform options
841 char * expression = localObjectsDirectory;
843 expression = settingsObjectsDirectory;
847 DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config)
849 char * expression = GetObjDirExpression(compiler, config);
850 DirExpression objDir { type = intermediateObjectsDir };
851 objDir.Evaluate(expression, this, compiler, config);
855 char * GetTargetDirExpression(CompilerConfig compiler, ProjectConfig config)
857 // TODO: Support platform options
858 char * expression = localTargetDirectory;
860 expression = settingsTargetDirectory;
864 DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config)
866 char * expression = GetTargetDirExpression(compiler, config);
867 DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
868 targetDir.Evaluate(expression, this, compiler, config);
872 WarningsOption GetWarnings(ProjectConfig config)
874 WarningsOption warnings = localWarnings;
878 bool GetDebug(ProjectConfig config)
880 SetBool debug = localDebug;
881 return debug == true;
884 bool GetMemoryGuard(ProjectConfig config)
886 SetBool memoryGuard = localMemoryGuard;
887 return memoryGuard == true;
890 bool GetNoLineNumbers(ProjectConfig config)
892 SetBool noLineNumbers = localNoLineNumbers;
893 return noLineNumbers == true;
896 bool GetProfile(ProjectConfig config)
898 SetBool profile = localProfile;
899 return profile == true;
902 OptimizationStrategy GetOptimization(ProjectConfig config)
904 OptimizationStrategy optimization = localOptimization;
908 String GetDefaultNameSpace(ProjectConfig config)
910 String defaultNameSpace = localDefaultNameSpace;
911 return defaultNameSpace;
914 bool GetStrictNameSpaces(ProjectConfig config)
916 SetBool strictNameSpaces = localStrictNameSpaces;
917 return strictNameSpaces == true;
920 String GetTargetFileName(ProjectConfig config)
922 String targetFileName = localTargetFileName;
923 return targetFileName;
926 //String targetDirectory;
927 //String objectsDirectory;
928 bool GetConsole(ProjectConfig config)
930 SetBool console = localConsole;
931 return console == true;
934 bool GetCompress(ProjectConfig config)
936 SetBool compress = localCompress;
937 return compress == true;
939 //SetBool excludeFromBuild;
941 bool GetConfigIsInActiveDebugSession(ProjectConfig config)
943 #ifndef MAKEFILE_GENERATOR
944 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
948 bool GetConfigIsInDebugSession(ProjectConfig config)
950 #ifndef MAKEFILE_GENERATOR
951 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
955 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config)
957 #ifndef MAKEFILE_GENERATOR
958 ide.SetPath(projectsDirs, compiler, config);
962 #ifndef MAKEFILE_GENERATOR
963 bool Save(char * fileName)
966 /*char output[MAX_LOCATION];
967 ChangeExtension(fileName, "json", output);
968 f = FileOpen(output, write);*/
969 f = FileOpen(fileName, write);
972 files = topNode.files;
973 resources = resNode.files;
974 resourcesPath = resNode.path;
976 files.Remove(resNode);
979 WriteJSONObject(f, class(Project), this, 0);
985 resourcesPath = null;
992 #ifndef MAKEFILE_GENERATOR
993 bool GetRelativePath(char * filePath, char * relativePath)
996 char moduleName[MAX_FILENAME];
997 GetLastDirectory(filePath, moduleName);
998 // try with workspace dir first?
999 if((node = topNode.Find(moduleName, false)))
1001 strcpy(relativePath, strcmp(node.path, ".") ? node.path : "");
1002 PathCatSlash(relativePath, node.name);
1005 // WARNING: On failure, relative path is uninitialized
1010 void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
1012 TargetTypes targetType = GetTargetType(config);
1013 String targetFileName = GetTargetFileName(config);
1014 if(targetType == staticLibrary)
1016 PathCatSlash(string, "lib");
1017 strcat(string, targetFileName);
1019 else if(compiler.targetPlatform != win32 && targetType == sharedLibrary)
1021 PathCatSlash(string, "lib");
1022 strcat(string, targetFileName);
1025 PathCatSlash(string, targetFileName);
1030 if(compiler.targetPlatform == win32)
1031 strcat(string, ".exe");
1034 if(compiler.targetPlatform == win32)
1035 strcat(string, ".dll");
1036 else if(compiler.targetPlatform == apple)
1037 strcat(string, ".dylib");
1039 strcat(string, ".so");
1042 strcat(string, ".a");
1047 void CatMakeFileName(char * string, CompilerConfig compiler, ProjectConfig config)
1049 char projectName[MAX_LOCATION];
1050 strcpy(projectName, name);
1051 if(strcmpi(compiler.name, defaultCompilerName))
1052 sprintf(string, "%s-%s-%s.Makefile", projectName, compiler.name, config.name);
1054 sprintf(string, "%s%s%s.Makefile", projectName, config ? "-" : "", config ? config.name : "");
1057 #ifndef MAKEFILE_GENERATOR
1058 void MarkChanges(ProjectNode node)
1060 for(cfg : topNode.configurations)
1062 ProjectConfig c = null;
1063 for(i : node.configurations; !strcmpi(i.name, cfg.name)) { c = i; break; }
1065 if(c && ((c.options && cfg.options && cfg.options.console != c.options.console) ||
1066 (!c.options || !cfg.options)))
1067 cfg.symbolGenModified = true;
1069 cfg.makingModified = true;
1073 void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
1075 for(cfg : configurations)
1078 cfg.makingModified = true;
1080 cfg.compilingModified = true;
1082 cfg.linkingModified = true;
1084 cfg.symbolGenModified = true;
1086 if(compiling || linking)
1088 ide.projectView.modifiedDocument = true;
1089 ide.workspace.modified = true;
1093 void RotateActiveConfig(bool forward)
1095 if(configurations.first && configurations.last != configurations.first)
1097 Iterator<ProjectConfig> cfg { configurations };
1098 while(forward ? cfg.Next() : cfg.Prev())
1099 if(cfg.data == config)
1113 property::config = cfg.data;
1114 ide.workspace.modified = true;
1115 ide.projectView.Update(null);
1119 void ProcessPipeOutputRaw(DualPipe f)
1122 while(!f.Eof() && !ide.ShouldStopBuild())
1125 double lastTime = GetTime();
1129 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1131 ide.outputView.buildBox.Logf("%s\n", line);
1133 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1135 //printf("Processing Input...\n");
1136 if(app.ProcessInput(true))
1138 app.UpdateDisplay();
1141 //printf("Waiting...\n");
1144 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1146 if(ide.ShouldStopBuild())
1148 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1153 bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, bool isARun, ProjectNode onlyNode,
1154 CompilerConfig compiler, ProjectConfig config)
1157 bool compiling = false, linking = false, precompiling = false;
1158 int compilingEC = 0;
1159 int numErrors = 0, numWarnings = 0;
1160 bool loggedALine = false;
1161 char * configName = config.name;
1162 int lenMakeCommand = strlen(compiler.makeCommand);
1164 char cppCommand[MAX_LOCATION];
1165 char ccCommand[MAX_LOCATION];
1166 char ecpCommand[MAX_LOCATION];
1167 char eccCommand[MAX_LOCATION];
1168 char ecsCommand[MAX_LOCATION];
1169 char earCommand[MAX_LOCATION];
1171 char * cc = compiler.ccCommand;
1172 char * cpp = compiler.cppCommand;
1173 sprintf(cppCommand, "%s%s%s%s ",
1174 compiler.ccacheEnabled ? "ccache " : "",
1175 compiler.ccacheEnabled && !compiler.distccEnabled ? " " : "",
1176 compiler.distccEnabled ? "distcc " : "",
1177 compiler.cppCommand);
1178 sprintf(ccCommand, "%s%s%s%s ",
1179 compiler.ccacheEnabled ? "ccache " : "",
1180 compiler.ccacheEnabled && !compiler.distccEnabled ? " " : "",
1181 compiler.distccEnabled ? "distcc " : "",
1182 compiler.ccCommand);
1183 sprintf(ecpCommand, "%s ", compiler.ecpCommand);
1184 sprintf(eccCommand, "%s ", compiler.eccCommand);
1185 sprintf(ecsCommand, "%s ", compiler.ecsCommand);
1186 sprintf(earCommand, "%s ", compiler.earCommand);
1188 while(!f.Eof() && !ide.ShouldStopBuild())
1191 double lastTime = GetTime();
1195 //printf("Peeking and GetLine...\n");
1196 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1198 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1199 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
1201 char * module = strstr(line, "No rule to make target `");
1205 module = strchr(module, '`') + 1;
1206 end = strchr(module, '\'');
1210 ide.outputView.buildBox.Logf($" %s: No such file or directory\n", module);
1211 // ide.outputView.buildBox.Logf("error: %s\n No such file or directory\n", module);
1217 //ide.outputView.buildBox.Logf("error: %s\n", line);
1221 else if(strstr(line, "ear ") == line);
1222 else if(strstr(line, "strip ") == line);
1223 else if(strstr(line, ccCommand) == line || strstr(line, ecpCommand) == line || strstr(line, eccCommand) == line)
1225 char moduleName[MAX_FILENAME];
1228 bool isPrecomp = false;
1230 if(strstr(line, ccCommand) == line)
1232 module = strstr(line, " -c ");
1233 if(module) module += 4;
1235 else if(strstr(line, eccCommand) == line)
1237 module = strstr(line, " -c ");
1238 if(module) module += 4;
1239 //module = line + 3;
1240 // Don't show GCC warnings about generated C code because it does not compile clean yet...
1241 compilingEC = 3;//2;
1243 else if(strstr(line, ecpCommand) == line)
1245 // module = line + 8;
1246 module = strstr(line, " -c ");
1247 if(module) module += 4;
1256 if(!compiling && !isPrecomp)
1258 ide.outputView.buildBox.Logf($"Compiling...\n");
1261 else if(!precompiling && isPrecomp)
1263 ide.outputView.buildBox.Logf($"Generating symbols...\n");
1264 precompiling = true;
1266 // Changed escapeBackSlashes here to handle paths with spaces
1267 Tokenize(module, 1, tokens, true); // false);
1268 GetLastDirectory(module, moduleName);
1269 ide.outputView.buildBox.Logf("%s\n", moduleName);
1271 else if((module = strstr(line, " -o ")))
1274 precompiling = false;
1276 ide.outputView.buildBox.Logf($"Linking...\n");
1280 ide.outputView.buildBox.Logf("%s\n", line);
1284 if(compilingEC) compilingEC--;
1286 else if(strstr(line, "ar rcs") == line)
1287 ide.outputView.buildBox.Logf($"Building library...\n");
1288 else if(strstr(line, ecsCommand) == line)
1289 ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
1292 if(linking || compiling || precompiling)
1294 char * colon = strstr(line, ":"); //, * bracket;
1295 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1296 colon = strstr(colon + 1, ":");
1299 char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
1302 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1303 int len = (int)(colon - start);
1304 len = Min(len, MAX_LOCATION-1);
1305 // Don't be mistaken by the drive letter colon
1307 // TODO: need to fix colon - line gives char *
1308 // warning: incompatible expression colon - line (char *); expected int
1310 strncpy(moduleName, line, (int)(colon - line));
1311 moduleName[colon - line] = '\0';
1313 strncpy(moduleName, start, len);
1314 moduleName[len] = '\0';
1315 // Remove stuff in brackets
1316 //bracket = strstr(moduleName, "(");
1317 //if(bracket) *bracket = '\0';
1319 GetLastDirectory(moduleName, temp);
1320 if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
1323 strcpy(moduleName, $"Linker Error");
1327 strcpy(temp, topNode.path);
1328 PathCatSlash(temp, moduleName);
1329 MakePathRelative(temp, topNode.path, moduleName);
1331 if(strstr(line, "error:"))
1335 // Silence warnings for compiled EC
1336 char * objDir = strstr(moduleName, objDirExp.dir);
1340 if((pointer = strstr(line, "undefined")) ||
1341 (pointer = strstr(line, "No such file")) ||
1342 (pointer = strstr(line, "token")))
1344 strncat(moduleName, colon, pointer - colon);
1345 strcat(moduleName, "error: ");
1350 else if((pointer = strstr(line, "No such file")))
1352 strncat(moduleName, colon, pointer - colon);
1353 strcat(moduleName, "error: ");
1357 else if(compilingEC == 1 || (objDir && objDir == moduleName))
1359 else if(strstr(line, "warning:"))
1364 if(this == ide.workspace.projects.firstIterator.data)
1365 ide.outputView.buildBox.Logf(" %s%s\n", moduleName, colon);
1368 char fullModuleName[MAX_LOCATION];
1369 strcpy(fullModuleName, topNode.path);
1370 PathCat(fullModuleName, moduleName);
1371 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
1372 MakeSystemPath(fullModuleName);
1373 ide.outputView.buildBox.Logf(" %s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : "", fullModuleName, colon);
1378 ide.outputView.buildBox.Logf("%s\n", line);
1379 linking = compiling = precompiling = false;
1383 ide.outputView.buildBox.Logf("%s\n", line);
1387 //printf("Done getting line\n");
1388 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1390 //printf("Processing Input...\n");
1391 if(app.ProcessInput(true))
1393 app.UpdateDisplay();
1396 //printf("Waiting...\n");
1399 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1401 if(ide.ShouldStopBuild())
1403 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1406 else if(loggedALine || !isARun)
1408 if(f.GetExitCode() && !numErrors)
1410 bool result = f.GetLine(line, sizeof(line)-1);
1411 ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
1416 ide.outputView.buildBox.Logf("\n%s (%s) - ", GetTargetFileName(config), configName);
1418 ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
1420 ide.outputView.buildBox.Logf($"no error, ");
1423 ide.outputView.buildBox.Logf("%d %s\n", numWarnings, (numWarnings > 1) ? $"warnings" : $"warning");
1425 ide.outputView.buildBox.Logf($"no warning\n");
1428 return numErrors == 0;
1431 void ProcessCleanPipeOutput(DualPipe f, CompilerConfig compiler, ProjectConfig config)
1434 int lenMakeCommand = strlen(compiler.makeCommand);
1439 double lastTime = GetTime();
1442 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1444 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':');
1445 else if(strstr(line, "del") == line);
1446 else if(strstr(line, "rm") == line);
1447 else if(strstr(line, "Could Not Find") == line);
1450 ide.outputView.buildBox.Logf(line);
1451 ide.outputView.buildBox.Logf("\n");
1455 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1457 if(app.ProcessInput(true))
1459 app.UpdateDisplay();
1462 //Sleep(1.0 / PEEK_RESOLUTION);
1466 bool Build(bool isARun, ProjectNode onlyNode, CompilerConfig compiler, ProjectConfig config)
1468 bool result = false;
1470 char targetFileName[MAX_LOCATION] = "";
1471 char makeTarget[MAX_LOCATION] = "";
1472 char makeFile[MAX_LOCATION];
1473 char makeFilePath[MAX_LOCATION];
1474 char configName[MAX_LOCATION];
1475 DirExpression objDirExp = GetObjDir(compiler, config);
1476 PathBackup pathBackup { };
1478 int numJobs = compiler.numJobs;
1479 char command[MAX_LOCATION];
1480 char * compilerName;
1482 compilerName = CopyString(compiler.name);
1483 CamelCase(compilerName);
1485 strcpy(configName, config ? config.name : "Common");
1487 SetPath(false, compiler, config); //true
1488 CatTargetFileName(targetFileName, compiler, config);
1490 strcpy(makeFilePath, topNode.path);
1491 CatMakeFileName(makeFile, compiler, config);
1492 PathCatSlash(makeFilePath, makeFile);
1494 // TODO: TEST ON UNIX IF \" around makeTarget is ok
1497 if(compiler.type.isVC)
1499 PrintLn("compiling a single file is not yet supported");
1504 char pushD[MAX_LOCATION];
1505 GetWorkingDir(pushD, sizeof(pushD));
1506 ChangeWorkingDir(topNode.path);
1507 // Create object dir if it does not exist already
1508 if(!FileExists(objDirExp.dir).isDirectory)
1509 Execute("%s E_IDE_CF_DIR=%s COMPILER=%s objdir -C \"%s\" -f \"%s\"", compiler.makeCommand, cfDir, compilerName, topNode.path, makeFilePath);
1510 ChangeWorkingDir(pushD);
1512 PathCatSlash(makeTarget+1, objDirExp.dir);
1513 PathCatSlash(makeTarget+1, onlyNode.name);
1514 StripExtension(makeTarget+1);
1515 strcat(makeTarget+1, ".o");
1516 makeTarget[0] = '\"';
1517 len = strlen(makeTarget);
1518 makeTarget[len++] = '\"';
1519 makeTarget[len++] = '\0';
1523 if(compiler.type.isVC)
1525 bool result = false;
1526 char oldwd[MAX_LOCATION];
1527 GetWorkingDir(oldwd, sizeof(oldwd));
1528 ChangeWorkingDir(topNode.path);
1530 sprintf(command, "%s /useenv /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
1531 ide.outputView.buildBox.Logf("command: %s\n", command);
1532 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
1534 ProcessPipeOutputRaw(f);
1538 ChangeWorkingDir(oldwd);
1542 sprintf(command, "%s E_IDE_CF_DIR=%s COMPILER=%s -j%d %s%s%s -C \"%s\" -f \"%s\"", compiler.makeCommand, cfDir, compilerName, numJobs,
1543 compiler.ccacheEnabled ? "CCACHE=y " : "",
1544 compiler.distccEnabled ? "DISTCC=y " : "",
1545 makeTarget, topNode.path, makeFilePath);
1546 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
1548 result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNode, compiler, config);
1552 ide.outputView.buildBox.Logf($"Error executing make (%s) command\n", compiler.makeCommand);
1557 delete compilerName;
1561 void Clean(CompilerConfig compiler, ProjectConfig config, bool realclean)
1563 char makeFile[MAX_LOCATION];
1564 char makeFilePath[MAX_LOCATION];
1565 char command[MAX_LOCATION];
1566 char * compilerName;
1568 PathBackup pathBackup { };
1570 compilerName = CopyString(compiler.name);
1571 CamelCase(compilerName);
1573 SetPath(false, compiler, config);
1575 strcpy(makeFilePath, topNode.path);
1576 CatMakeFileName(makeFile, compiler, config);
1577 PathCatSlash(makeFilePath, makeFile);
1579 if(compiler.type.isVC)
1581 bool result = false;
1582 char oldwd[MAX_LOCATION];
1583 GetWorkingDir(oldwd, sizeof(oldwd));
1584 ChangeWorkingDir(topNode.path);
1586 sprintf(command, "%s /useenv /clean /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
1587 ide.outputView.buildBox.Logf("command: %s\n", command);
1588 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
1590 ProcessPipeOutputRaw(f);
1594 ChangeWorkingDir(oldwd);
1599 sprintf(command, "%s E_IDE_CF_DIR=%s COMPILER=%s %sclean -C \"%s\" -f \"%s\"", compiler.makeCommand, cfDir, compilerName, realclean ? "real" : "", topNode.path, makeFilePath);
1600 if((f = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
1602 ide.outputView.buildBox.Tell($"Deleting target and object files...");
1603 ProcessCleanPipeOutput(f, compiler, config);
1606 ide.outputView.buildBox.Logf($"Target and object files deleted\n");
1611 delete compilerName;
1614 void Run(char * args, CompilerConfig compiler, ProjectConfig config)
1616 String target = new char[maxPathLen];
1617 char oldDirectory[MAX_LOCATION];
1618 DirExpression targetDirExp = GetTargetDir(compiler, config);
1619 PathBackup pathBackup { };
1621 // Build(project, ideMain, true, null);
1623 #if defined(__WIN32__)
1624 strcpy(target, topNode.path);
1628 PathCatSlash(target, targetDirExp.dir);
1629 CatTargetFileName(target, compiler, config);
1630 sprintf(target, "%s %s", target, args);
1631 GetWorkingDir(oldDirectory, MAX_LOCATION);
1633 if(strlen(ide.workspace.debugDir))
1635 char temp[MAX_LOCATION];
1636 strcpy(temp, topNode.path);
1637 PathCatSlash(temp, ide.workspace.debugDir);
1638 ChangeWorkingDir(temp);
1641 ChangeWorkingDir(topNode.path);
1642 // ChangeWorkingDir(topNode.path);
1643 SetPath(true, compiler, config);
1644 if(compiler.execPrefixCommand)
1646 char * prefixedTarget = new char[strlen(compiler.execPrefixCommand) + strlen(target) + 2];
1647 prefixedTarget[0] = '\0';
1648 strcat(prefixedTarget, compiler.execPrefixCommand);
1649 strcat(prefixedTarget, " ");
1650 strcat(prefixedTarget, target);
1651 Execute(prefixedTarget);
1652 delete prefixedTarget;
1657 ChangeWorkingDir(oldDirectory);
1660 delete targetDirExp;
1664 void Compile(ProjectNode node, CompilerConfig compiler, ProjectConfig config)
1666 Build(false, node, compiler, config);
1670 void GetMakefileTargetFileName(TargetTypes targetType, char * fileName, ProjectConfig config)
1673 if(targetType == staticLibrary || targetType == sharedLibrary)
1674 strcat(fileName, "$(LP)");
1675 // !!! ReplaceSpaces must be done after all PathCat calls !!!
1676 // ReplaceSpaces(s, GetTargetFileName(config));
1677 strcat(fileName, GetTargetFileName(config));
1681 strcat(fileName, "$(E)");
1684 strcat(fileName, "$(SO)");
1687 strcat(fileName, "$(A)");
1692 bool GenerateDebugCf(CompilerConfig compiler)
1694 bool result = false;
1695 char path[MAX_LOCATION];
1697 GetWorkingDir(path, sizeof(path));
1698 PathCatSlash(path, cfDir);
1699 PathCatSlash(path, "debug.cf");
1701 if(!FileExists(path))
1703 File f = FileOpen(path, write);
1706 f.Printf(".PHONY: debug_lists\n");
1709 f.Printf("ifdef WINDOWS\n");
1710 f.Printf(".PHONY: debug_openssl\n");
1711 f.Printf("debug_openssl:\n");
1712 f.Printf(" @$(call echo,OPENSSL_CONF = $(OPENSSL_CONF))\n");
1713 f.Printf(" @$(call echo,_OPENSSL_CONF = $(_OPENSSL_CONF))\n");
1714 f.Printf(" @$(call echo,OPENSSL_INCLUDE_DIR = $(OPENSSL_INCLUDE_DIR))\n");
1715 f.Printf(" @$(call echo,OPENSSL_LIB_DIR = $(OPENSSL_LIB_DIR))\n");
1716 f.Printf(" @$(call echo,OPENSSL_BIN_DIR = $(OPENSSL_BIN_DIR))\n");
1717 f.Printf("endif\n");
1720 f.Printf("debug_lists:\n");
1721 f.Printf(" @$(call echo,ECSOURCES = $(ECSOURCES))\n");
1722 f.Printf(" @$(call echo,SYMBOLS = $(SYMBOLS))\n");
1723 f.Printf(" @$(call echo,IMPORTS = $(IMPORTS))\n");
1724 f.Printf(" @$(call echo,COBJECTS = $(COBJECTS))\n");
1732 bool GenerateCrossPlatformCf()
1734 bool result = false;
1735 char path[MAX_LOCATION];
1737 GetWorkingDir(path, sizeof(path));
1738 PathCatSlash(path, cfDir);
1739 PathCatSlash(path, "crossplatform.cf");
1741 if(!FileExists(path))
1743 File f = FileOpen(path, write);
1746 File include = FileOpen(":crossplatform.cf", read);
1749 for(; !include.Eof(); )
1752 int count = include.Read(buffer, 1, 4096);
1753 f.Write(buffer, 1, count);
1764 bool GenerateCompilerMk(CompilerConfig compiler)
1766 bool result = false;
1767 char path[MAX_LOCATION];
1769 char * compilerName;
1770 bool gccCompiler = compiler.ccCommand && strstr(compiler.ccCommand, "gcc") != null;
1771 Platform platform = GetRuntimePlatform();
1773 compilerName = CopyString(compiler.name);
1774 CamelCase(compilerName);
1775 name = PrintString(platform, "-", compilerName, ".cf");
1777 GetWorkingDir(path, sizeof(path));
1778 PathCatSlash(path, cfDir);
1779 PathCatSlash(path, name);
1781 if(!FileExists(path))
1783 File f = FileOpen(path, write);
1786 bool crossCompiling = compiler.targetPlatform != platform;
1788 f.Printf("# TOOLCHAIN\n\n");
1790 //f.Printf("SHELL := %s\n", "ar"/*compiler.arCommand*/); // is this really needed?
1791 f.Printf("CPP := $(CCACHE_COMPILE) $(DISTCC_COMPILE) %s\n", compiler.cppCommand);
1792 f.Printf("CC := $(CCACHE_COMPILE) $(DISTCC_COMPILE) %s\n", compiler.ccCommand);
1793 f.Printf("ECP := %s\n", compiler.ecpCommand);
1794 f.Printf("ECC := %s\n", compiler.eccCommand);
1795 f.Printf("ECS := %s%s%s\n", compiler.ecsCommand,
1796 crossCompiling ? " -t " : "", crossCompiling ? (char*)compiler.targetPlatform : "");
1797 f.Printf("EAR := %s\n", compiler.earCommand);
1799 f.Printf("AS := as\n");
1800 f.Printf("LD := ld\n");
1801 f.Printf("AR := ar\n");
1802 f.Printf("STRIP := strip\n");
1803 f.Printf("UPX := upx\n");
1807 f.Printf("UPXFLAGS = -9\n\n"); // TOFEAT: Compression Level Option? Other UPX Options?
1809 f.Printf("# HARD CODED PLATFORM-SPECIFIC OPTIONS\n");
1810 f.Printf("ifdef %s\n", PlatformToMakefileVariable(tux));
1811 f.Printf("OFLAGS += -Wl,--no-undefined\n");
1812 f.Printf("endif\n\n");
1815 f.Printf("ifdef %s\n", PlatformToMakefileVariable(apple));
1816 f.Printf("OFLAGS += -framework cocoa -framework OpenGL\n");
1817 f.Printf("endif\n\n");
1820 f.Printf("PLATFORM = %s\n", (char *)compiler.targetPlatform);
1822 if((compiler.includeDirs && compiler.includeDirs.count) ||
1823 (compiler.libraryDirs && compiler.libraryDirs.count))
1825 if(compiler.includeDirs && compiler.includeDirs.count)
1827 f.Printf("CFLAGS +=");
1828 OutputListOption(f, gccCompiler ? "isystem " : "I", compiler.includeDirs, lineEach, true);
1831 if(compiler.libraryDirs && compiler.libraryDirs.count)
1833 f.Printf("OFLAGS +=");
1834 OutputListOption(f, "L", compiler.libraryDirs, lineEach, true);
1844 delete compilerName;
1848 bool GenerateMakefile(char * altMakefilePath, bool noResources, char * includemkPath,
1849 CompilerConfig compiler, ProjectConfig config)
1851 bool result = false;
1852 char filePath[MAX_LOCATION];
1853 char makeFile[MAX_LOCATION];
1854 // PathBackup pathBackup { };
1855 // char oldDirectory[MAX_LOCATION];
1858 if(!altMakefilePath)
1860 strcpy(filePath, topNode.path);
1861 CatMakeFileName(makeFile, compiler, config);
1862 PathCatSlash(filePath, makeFile);
1865 #if defined(__WIN32__) && !defined(MAKEFILE_GENERATOR)
1866 if(compiler.type.isVC)
1868 GenerateVSSolutionFile(this, compiler);
1869 GenerateVCProjectFile(this, compiler);
1873 f = FileOpen(altMakefilePath ? altMakefilePath : filePath, write);
1875 /*SetPath(false, compiler, config);
1876 GetWorkingDir(oldDirectory, MAX_LOCATION);
1877 ChangeWorkingDir(topNode.path);*/
1884 Platform runtimePlatform = GetRuntimePlatform();
1885 char targetDir[MAX_LOCATION];
1886 char objDirExpNoSpaces[MAX_LOCATION];
1887 char objDirNoSpaces[MAX_LOCATION];
1888 char resDirNoSpaces[MAX_LOCATION];
1889 char targetDirExpNoSpaces[MAX_LOCATION];
1890 char fixedModuleName[MAX_FILENAME];
1891 char fixedConfigName[MAX_FILENAME];
1892 char fixedCompilerName[MAX_FILENAME];
1894 int numCObjects = 0;
1895 bool sameObjTargetDirs;
1896 DirExpression objDirExp = GetObjDir(compiler, config);
1897 TargetTypes targetType = GetTargetType(config);
1899 bool crossCompiling = compiler.targetPlatform != runtimePlatform;
1900 bool gccCompiler = compiler.ccCommand && strstr(compiler.ccCommand, "gcc") != null;
1901 bool tccCompiler = compiler.ccCommand && strstr(compiler.ccCommand, "tcc") != null;
1902 bool defaultPreprocessor = compiler.cppCommand && (strstr(compiler.cppCommand, "gcc") != null || compiler.cppCommand && strstr(compiler.cppCommand, "cpp") != null);
1904 int objectsParts, eCsourcesParts;
1905 Array<String> listItems { };
1906 Map<String, int> varStringLenDiffs { };
1907 Map<String, NameCollisionInfo> namesInfo { };
1909 ReplaceSpaces(objDirNoSpaces, objDirExp.dir);
1910 strcpy(targetDir, GetTargetDirExpression(compiler, config));
1911 ReplaceSpaces(targetDirExpNoSpaces, targetDir);
1913 strcpy(objDirExpNoSpaces, GetObjDirExpression(compiler, config));
1914 ChangeCh(objDirExpNoSpaces, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
1915 ReplaceSpaces(objDirExpNoSpaces, objDirExpNoSpaces);
1916 ReplaceSpaces(resDirNoSpaces, resNode.path ? resNode.path : "");
1917 //ReplaceSpaces(fixedPrjName, name);
1918 ReplaceSpaces(fixedModuleName, moduleName);
1919 ReplaceSpaces(fixedConfigName, GetConfigName(config));
1920 ReplaceSpaces(fixedCompilerName, compiler.name);
1921 //CamelCase(fixedModuleName); // case is important for static linking
1922 CamelCase(fixedConfigName);
1923 CamelCase(fixedCompilerName);
1925 sameObjTargetDirs = !fstrcmp(objDirExpNoSpaces, targetDirExpNoSpaces);
1927 f.Printf(".PHONY: all objdir%s clean realclean\n\n", sameObjTargetDirs ? "" : " targetdir");
1929 f.Printf("# CONTENT\n\n");
1931 f.Printf("MODULE := %s\n", fixedModuleName);
1932 //f.Printf("VERSION = %s\n", version);
1933 f.Printf("CONFIG := %s\n", fixedConfigName);
1934 f.Printf("ifndef COMPILER\n");
1935 f.Printf("COMPILER := %s\n", fixedCompilerName);
1936 f.Printf("endif\n");
1937 test = GetTargetTypeIsSetByPlatform(config);
1941 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
1943 TargetTypes targetType;
1944 PlatformOptions projectPOs, configPOs;
1945 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
1946 targetType = platformTargetType;
1952 f.Printf("ifdef %s\n", PlatformToMakefileVariable(platform));
1954 f.Printf("TARGET_TYPE = ");
1955 f.Printf(TargetTypeToMakefileVariable(targetType));
1959 f.Printf("else\n"); // ifCount should always be > 0
1961 f.Printf("TARGET_TYPE = ");
1962 f.Printf(TargetTypeToMakefileVariable(targetType));
1968 for(c = 0; c < ifCount; c++)
1969 f.Printf("endif\n");
1974 f.Printf("# FLAGS\n\n");
1976 f.Printf("CFLAGS =\n");
1977 f.Printf("CECFLAGS =\n");
1978 f.Printf("ECFLAGS =\n");
1979 f.Printf("OFLAGS =\n");
1980 f.Printf("LIBS =\n");
1983 f.Printf("# INCLUDES\n\n");
1985 f.Printf("include %s\n", includemkPath ? includemkPath : "$(E_IDE_CF_DIR)crossplatform.cf");
1986 f.Printf("include $(E_IDE_CF_DIR)%s-%s.cf\n", (char*)runtimePlatform, fixedCompilerName);
1989 f.Printf("# VARIABLES\n\n");
1991 f.Printf("OBJ = %s%s\n\n", objDirExpNoSpaces, objDirExpNoSpaces[0] ? "/" : "");
1993 f.Printf("RES = %s%s\n\n", resDirNoSpaces, resDirNoSpaces[0] ? "/" : "");
1995 // test = GetTargetTypeIsSetByPlatform(config);
1997 char target[MAX_LOCATION];
1998 char targetNoSpaces[MAX_LOCATION];
2003 for(type = (TargetTypes)1; type < TargetTypes::enumSize; type++)
2005 if(type != targetType)
2010 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(type));
2012 GetMakefileTargetFileName(type, target, config);
2013 strcpy(targetNoSpaces, targetDir);
2014 PathCatSlash(targetNoSpaces, target);
2015 ReplaceSpaces(targetNoSpaces, targetNoSpaces);
2016 f.Printf("TARGET = %s\n", targetNoSpaces);
2019 f.Printf("else\n"); // ifCount should always be > 0
2021 GetMakefileTargetFileName(targetType, target, config);
2022 strcpy(targetNoSpaces, targetDir);
2023 PathCatSlash(targetNoSpaces, target);
2024 ReplaceSpaces(targetNoSpaces, targetNoSpaces);
2025 f.Printf("TARGET = %s\n", targetNoSpaces);
2030 for(c = 0; c < ifCount; c++)
2031 f.Printf("endif\n");
2037 varStringLenDiffs["$(OBJ)"] = strlen(objDirNoSpaces) - 6;
2039 topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
2041 numCObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config);
2043 listItems.Add(CopyString("$(OBJ)$(MODULE).main$(O)"));
2044 objectsParts = OutputFileList(f, "OBJECTS", listItems, varStringLenDiffs, null);
2048 char * map[3][2] = { { "COBJECTS", "C" }, { "SYMBOLS", "S" }, { "IMPORTS", "I" } };
2050 topNode.GenMakefilePrintNode(f, this, eCsources, namesInfo, listItems, config);
2051 eCsourcesParts = OutputFileList(f, "_ECSOURCES", listItems, varStringLenDiffs, null);
2053 f.Printf("ECSOURCES = $(call shwspace,$(_ECSOURCES))\n");
2054 if(eCsourcesParts > 1)
2056 for(c = 1; c <= eCsourcesParts; c++)
2057 f.Printf("ECSOURCES%d = $(call shwspace,$(_ECSOURCES%d))\n", c, c);
2061 for(c = 0; c < 3; c++)
2063 if(eCsourcesParts > 1)
2066 f.Printf("%s =", map[c][0]);
2067 for(n = 1; n <= eCsourcesParts; n++)
2068 f.Printf(" $(%s%d)", map[c][0], n);
2070 for(n = 1; n <= eCsourcesParts; n++)
2071 f.Printf("%s%d = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES%d)))))\n", map[c][0], n, map[c][1], n);
2073 else if(eCsourcesParts == 1)
2074 f.Printf("%s = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES)))))\n", map[c][0], map[c][1]);
2079 topNode.GenMakefilePrintNode(f, this, sources, null, listItems, config);
2080 OutputFileList(f, "SOURCES", listItems, varStringLenDiffs, "$(ECSOURCES)");
2083 resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config);
2084 OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs, null);
2086 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(executable));
2087 f.Printf("CONSOLE = %s\n", GetConsole(config) ? "-mconsole" : "-mwindows");
2088 f.Printf("endif\n\n");
2090 if((config && config.options && config.options.libraries) ||
2091 (options && options.libraries))
2093 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2094 f.Printf("LIBS +=");
2095 if(config && config.options && config.options.libraries)
2096 OutputLibraries(f, config.options.libraries);
2097 else if(options && options.libraries)
2098 OutputLibraries(f, options.libraries);
2100 f.Printf("endif\n");
2103 f.Printf("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n\n");
2105 if(platforms || (config && config.platforms))
2108 //for(platform = firstPlatform; platform <= lastPlatform; platform++)
2109 //for(platform = win32; platform <= apple; platform++)
2111 f.Printf("# PLATFORM-SPECIFIC OPTIONS\n\n");
2112 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2114 PlatformOptions projectPlatformOptions, configPlatformOptions;
2115 MatchProjectAndConfigPlatformOptions(config, platform, &projectPlatformOptions, &configPlatformOptions);
2117 if(projectPlatformOptions || configPlatformOptions)
2123 f.Printf(PlatformToMakefileVariable(platform));
2126 if((projectPlatformOptions && projectPlatformOptions.options.preprocessorDefinitions && projectPlatformOptions.options.preprocessorDefinitions.count) ||
2127 (configPlatformOptions && configPlatformOptions.options.preprocessorDefinitions && configPlatformOptions.options.preprocessorDefinitions.count) ||
2128 (projectPlatformOptions && projectPlatformOptions.options.includeDirs && projectPlatformOptions.options.includeDirs.count) ||
2129 (configPlatformOptions && configPlatformOptions.options.includeDirs && configPlatformOptions.options.includeDirs.count))
2131 f.Printf("CFLAGS +=");
2132 if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
2134 f.Printf(" \\\n\t -Wl");
2135 for(s : projectPlatformOptions.options.linkerOptions)
2138 if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
2140 f.Printf(" \\\n\t -Wl");
2141 for(s : configPlatformOptions.options.linkerOptions)
2144 if(projectPlatformOptions && projectPlatformOptions.options.preprocessorDefinitions)
2145 OutputListOption(f, "D", projectPlatformOptions.options.preprocessorDefinitions, newLine, false);
2146 if(configPlatformOptions && configPlatformOptions.options.preprocessorDefinitions)
2147 OutputListOption(f, "D", configPlatformOptions.options.preprocessorDefinitions, newLine, false );
2148 if(configPlatformOptions && configPlatformOptions.options.includeDirs)
2149 OutputListOption(f, "I", configPlatformOptions.options.includeDirs, lineEach, true);
2150 if(projectPlatformOptions && projectPlatformOptions.options.includeDirs)
2151 OutputListOption(f, "I", projectPlatformOptions.options.includeDirs, lineEach, true);
2155 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
2156 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count) ||
2157 (projectPlatformOptions && projectPlatformOptions.options.libraries && projectPlatformOptions.options.libraries.count) ||
2158 (configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
2160 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2161 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
2162 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count))
2164 f.Printf("OFLAGS +=");
2165 if(configPlatformOptions && configPlatformOptions.options.libraryDirs)
2166 OutputListOption(f, "L", configPlatformOptions.options.libraryDirs, lineEach, true);
2167 if(projectPlatformOptions && projectPlatformOptions.options.libraryDirs)
2168 OutputListOption(f, "L", projectPlatformOptions.options.libraryDirs, lineEach, true);
2172 if(projectPlatformOptions && projectPlatformOptions.options.libraries &&
2173 projectPlatformOptions.options.libraries.count)
2175 f.Printf("LIBS +=");
2176 OutputLibraries(f, projectPlatformOptions.options.libraries);
2179 if((configPlatformOptions && configPlatformOptions.options.libraries &&
2180 configPlatformOptions.options.libraries.count))
2182 f.Printf("LIBS +=");
2183 OutputLibraries(f, configPlatformOptions.options.libraries);
2186 f.Printf("endif\n\n");
2192 for(c = 0; c < ifCount; c++)
2193 f.Printf("endif\n");
2198 f.Printf("CFLAGS +=");
2201 f.Printf(" -fmessage-length=0");
2202 switch(GetOptimization(config))
2206 f.Printf(" -ffast-math");
2212 //if(compiler.targetPlatform.is32Bits)
2214 //else if(compiler.targetPlatform.is64Bits)
2215 // f.Printf(" -m64");
2216 f.Printf(" $(FPIC)");
2217 //f.Printf(" -fpack-struct");
2219 switch(GetWarnings(config))
2221 case all: f.Printf(" -Wall"); break;
2222 case none: f.Printf(" -w"); break;
2224 if(GetDebug(config))
2226 if(GetProfile(config))
2228 if(options && options.linkerOptions && options.linkerOptions.count)
2230 f.Printf(" \\\n\t -Wl");
2231 for(s : options.linkerOptions)
2235 if(options && options.preprocessorDefinitions)
2236 OutputListOption(f, "D", options.preprocessorDefinitions, newLine, false);
2237 if(config && config.options && config.options.preprocessorDefinitions)
2238 OutputListOption(f, "D", config.options.preprocessorDefinitions, newLine, false);
2239 if(config && config.options && config.options.includeDirs)
2240 OutputListOption(f, "I", config.options.includeDirs, lineEach, true);
2241 if(options && options.includeDirs)
2242 OutputListOption(f, "I", options.includeDirs, lineEach, true);
2245 f.Printf("CECFLAGS +=%s%s%s%s", defaultPreprocessor ? "" : " -cpp ", defaultPreprocessor ? "" : compiler.cppCommand,
2246 crossCompiling ? " -t " : "", crossCompiling ? (char*)compiler.targetPlatform : "");
2249 f.Printf("ECFLAGS +=");
2250 if(GetMemoryGuard(config))
2251 f.Printf(" -memguard");
2252 if(GetStrictNameSpaces(config))
2253 f.Printf(" -strictns");
2254 if(GetNoLineNumbers(config))
2255 f.Printf(" -nolinenumbers");
2258 if((s = GetDefaultNameSpace(config)) && s[0])
2259 f.Printf(" -defaultns %s", s);
2263 f.Printf("OFLAGS +=\n");
2264 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2265 f.Printf("OFLAGS += -m32");
2266 if(GetProfile(config))
2268 if(config && config.options && config.options.libraryDirs)
2269 OutputListOption(f, "L", config.options.libraryDirs, lineEach, true);
2270 if(options && options.libraryDirs)
2271 OutputListOption(f, "L", options.libraryDirs, lineEach, true);
2273 f.Printf("endif\n\n");
2275 f.Printf("# TARGETS\n\n");
2277 f.Printf("all: objdir%s $(TARGET)\n\n", sameObjTargetDirs ? "" : " targetdir");
2279 f.Printf("objdir:\n");
2280 f.Printf("\t$(if $(wildcard $(OBJ)),,$(call mkdirq,$(OBJ)))\n");
2281 //f.Printf("# PRE-BUILD COMMANDS\n");
2282 if(options && options.prebuildCommands)
2284 for(s : options.prebuildCommands)
2285 if(s && s[0]) f.Printf("\t%s\n", s);
2287 if(config && config.options && config.options.prebuildCommands)
2289 for(s : config.options.prebuildCommands)
2290 if(s && s[0]) f.Printf("\t%s\n", s);
2292 if(platforms || (config && config.platforms))
2295 //f.Printf("# PLATFORM-SPECIFIC PRE-BUILD COMMANDS\n");
2296 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2298 PlatformOptions projectPOs, configPOs;
2299 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2301 if((projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count) ||
2302 (configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count))
2308 f.Printf(PlatformToMakefileVariable(platform));
2311 if(projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count)
2313 for(s : projectPOs.options.prebuildCommands)
2314 if(s && s[0]) f.Printf("\t%s\n", s);
2316 if(configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count)
2318 for(s : configPOs.options.prebuildCommands)
2319 if(s && s[0]) f.Printf("\t%s\n", s);
2326 for(c = 0; c < ifCount; c++)
2327 f.Printf("endif\n");
2332 if(!sameObjTargetDirs)
2334 f.Printf("targetdir:\n");
2335 f.Printf("\t$(if $(wildcard %s),,$(call mkdirq,%s))\n\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
2340 // Main Module (Linking) for ECERE C modules
2341 f.Printf("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
2342 // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
2343 f.Printf("\t$(ECS)%s $(ECSLIBOPT) $(SYMBOLS) $(IMPORTS) -symbols %s -o $(OBJ)$(MODULE).main.ec\n\n",
2344 GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
2345 // Main Module (Linking) for ECERE C modules
2346 f.Printf("$(OBJ)$(MODULE).main.c: $(OBJ)$(MODULE).main.ec\n");
2347 f.Printf("\t$(ECP) $(CECFLAGS) $(ECFLAGS) $(CFLAGS)"
2348 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
2349 f.Printf("\t$(ECC) $(CECFLAGS) $(ECFLAGS) $(CFLAGS) $(FVISIBILITY)"
2350 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.c -symbols $(OBJ)\n\n");
2355 // This would not rebuild the target on updated objects
2356 // f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) | objdir $(SYMBOLS) $(OBJECTS)%s\n", sameObjTargetDirs ? "" : " targetdir");
2358 // This should fix it for good!
2359 f.Printf("$(SYMBOLS): | objdir\n");
2360 f.Printf("$(OBJECTS): | objdir\n");
2362 // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
2363 f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
2365 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2366 f.Printf("\t$(CC) $(OFLAGS) $(OBJECTS) $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
2367 if(!GetDebug(config))
2369 f.Printf("ifndef NOSTRIP\n");
2370 f.Printf("\t$(STRIP) $(STRIPOPT) $(TARGET)\n");
2371 f.Printf("endif\n");
2373 if(GetCompress(config))
2375 f.Printf("ifndef WINDOWS\n");
2376 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(executable));
2377 f.Printf("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
2378 f.Printf("endif\n");
2380 f.Printf("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
2381 f.Printf("endif\n");
2384 if(resNode.files && resNode.files.count && !noResources)
2385 resNode.GenMakefileAddResources(f, resNode.path, config);
2387 f.Printf("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
2388 f.Printf("endif\n");
2390 //f.Printf("# POST-BUILD COMMANDS\n");
2391 if(options && options.postbuildCommands)
2393 for(s : options.postbuildCommands)
2394 if(s && s[0]) f.Printf("\t%s\n", s);
2396 if(config && config.options && config.options.postbuildCommands)
2398 for(s : config.options.postbuildCommands)
2399 if(s && s[0]) f.Printf("\t%s\n", s);
2401 if(platforms || (config && config.platforms))
2404 //f.Printf("# PLATFORM-SPECIFIC POST-BUILD COMMANDS\n");
2405 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2407 PlatformOptions projectPOs, configPOs;
2408 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2410 if((projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count) ||
2411 (configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count))
2417 f.Printf(PlatformToMakefileVariable(platform));
2420 if(projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count)
2422 for(s : projectPOs.options.postbuildCommands)
2423 if(s && s[0]) f.Printf("\t%s\n", s);
2425 if(configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count)
2427 for(s : configPOs.options.postbuildCommands)
2428 if(s && s[0]) f.Printf("\t%s\n", s);
2435 for(c = 0; c < ifCount; c++)
2436 f.Printf("endif\n");
2441 f.Printf("# SYMBOL RULES\n\n");
2443 Map<Platform, bool> excludedPlatforms { };
2444 topNode.GenMakefilePrintSymbolRules(f, this, compiler, config, excludedPlatforms);
2445 delete excludedPlatforms;
2448 f.Printf("# C OBJECT RULES\n\n");
2450 Map<Platform, bool> excludedPlatforms { };
2451 topNode.GenMakefilePrintCObjectRules(f, this, compiler, config, excludedPlatforms);
2452 delete excludedPlatforms;
2455 f.Printf("# OBJECT RULES\n\n");
2456 // todo call this still but only generate rules whith specific options
2457 // see we-have-file-specific-options in ProjectNode.ec
2459 Map<Platform, bool> excludedPlatforms { };
2460 topNode.GenMakefilePrintObjectRules(f, this, namesInfo, compiler, config, excludedPlatforms);
2461 delete excludedPlatforms;
2465 GenMakefilePrintMainObjectRule(f, compiler, config);
2467 f.Printf("clean: objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
2468 f.Printf("\t$(call rmq,%s$(TARGET))\n", numCObjects ? "$(OBJ)$(MODULE).main.c $(OBJ)$(MODULE).main.ec $(OBJ)$(MODULE).main$(I) $(OBJ)$(MODULE).main$(S) " : "");
2469 OutputCleanActions(f, "OBJECTS", objectsParts);
2470 OutputCleanActions(f, "COBJECTS", eCsourcesParts);
2473 OutputCleanActions(f, "IMPORTS", eCsourcesParts);
2474 OutputCleanActions(f, "SYMBOLS", eCsourcesParts);
2478 f.Printf("realclean: clean\n");
2479 f.Printf("\t$(call rmrq,$(OBJ))\n");
2480 if(!sameObjTargetDirs)
2481 f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
2484 f.Printf("include $(E_IDE_CF_DIR)debug.cf\n");
2490 varStringLenDiffs.Free();
2491 delete varStringLenDiffs;
2498 // ChangeWorkingDir(oldDirectory);
2499 // delete pathBackup;
2502 config.makingModified = false;
2506 void GenMakefilePrintMainObjectRule(File f, CompilerConfig compiler, ProjectConfig config)
2508 char extension[MAX_EXTENSION] = "c";
2509 char modulePath[MAX_LOCATION];
2510 char fixedModuleName[MAX_FILENAME];
2513 char objDirNoSpaces[MAX_LOCATION];
2514 DirExpression objDirExp = GetObjDir(compiler, config);
2516 ReplaceSpaces(objDirNoSpaces, objDirExp.dir);
2517 ReplaceSpaces(fixedModuleName, moduleName);
2519 //sprintf(fixedModuleName, "%s.main", fixedPrjName);
2520 //strcat(fixedModuleName, ".main");
2522 #if 0 // TODO: Fix nospaces stuff
2523 // *** Dependency command ***
2524 sprintf(command, "gcc -MT $(OBJ)%s$(O) -MM $(OBJ)%s.c", fixedModuleName, fixedModuleName);
2526 // System Includes (from global settings)
2527 for(item : compiler.dirs[Includes])
2529 strcat(command, " -isystem ");
2530 if(strchr(item.name, ' '))
2532 strcat(command, "\"");
2533 strcat(command, item);
2534 strcat(command, "\"");
2537 strcat(command, item);
2540 for(item = includeDirs.first; item; item = item.next)
2542 strcat(command, " -I");
2543 if(strchr(item.name, ' '))
2545 strcat(command, "\"");
2546 strcat(command, item.name);
2547 strcat(command, "\"");
2550 strcat(command, item.name);
2552 for(item = preprocessorDefs.first; item; item = item.next)
2554 strcat(command, " -D");
2555 strcat(command, item.name);
2559 if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
2563 bool firstLine = true;
2565 // To do some time: auto save external dependencies?
2568 if(dep.GetLine(line, sizeof(line)-1))
2572 char * colon = strstr(line, ":");
2573 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
2587 // If we failed to generate dependencies...
2591 f.Printf("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
2597 f.Printf("\t$(CC) $(CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(OBJ)$(MODULE).main$(O)\n\n", extension);
2602 void MatchProjectAndConfigPlatformOptions(ProjectConfig config, Platform platform,
2603 PlatformOptions * projectPlatformOptions, PlatformOptions * configPlatformOptions)
2605 *projectPlatformOptions = null;
2606 *configPlatformOptions = null;
2611 if(!strcmpi(p.name, platform))
2613 *projectPlatformOptions = p;
2618 if(config && config.platforms)
2620 for(p : config.platforms)
2622 if(!strcmpi(p.name, platform))
2624 *configPlatformOptions = p;
2632 Project LegacyBinaryLoadProject(File f, char * filePath)
2634 Project project = null;
2635 char signature[sizeof(epjSignature)];
2637 f.Read(signature, sizeof(signature), 1);
2638 if(!strncmp(signature, (char *)epjSignature, sizeof(epjSignature)))
2640 char topNodePath[MAX_LOCATION];
2641 /*ProjectConfig newConfig
2643 name = CopyString("Default");
2644 makingModified = true;
2645 compilingModified = true;
2646 linkingModified = true;
2650 project = Project { options = { } };
2651 LegacyBinaryLoadNode(project.topNode, f);
2652 delete project.topNode.path;
2653 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
2654 MakeSlashPath(topNodePath);
2656 PathCatSlash(topNodePath, filePath);
2657 project.filePath = topNodePath;
2659 /* THIS IS ALREADY DONE BY filePath property
2660 StripLastDirectory(topNodePath, topNodePath);
2661 project.topNode.path = CopyString(topNodePath);
2663 // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
2665 // newConfig.options.defaultNameSpace = "";
2666 /*newConfig.objDir.dir = "obj";
2667 newConfig.targetDir.dir = "";*/
2669 //project.configurations = { [ newConfig ] };
2670 //project.config = newConfig;
2677 String targetFileName, targetDirectory, objectsDirectory;
2679 // { executable = 0, sharedLibrary = 1, staticLibrary = 2 };
2680 f.Read(&temp, sizeof(int),1);
2683 case 0: project.options.targetType = executable; break;
2684 case 1: project.options.targetType = sharedLibrary; break;
2685 case 2: project.options.targetType = staticLibrary; break;
2688 f.Read(&len, sizeof(int),1);
2689 targetFileName = new char[len+1];
2690 f.Read(targetFileName, sizeof(char), len+1);
2691 project.options.targetFileName = targetFileName;
2692 delete targetFileName;
2694 f.Read(&len, sizeof(int),1);
2695 targetDirectory = new char[len+1];
2696 f.Read(targetDirectory, sizeof(char), len+1);
2697 project.options.targetDirectory = targetDirectory;
2698 delete targetDirectory;
2700 f.Read(&len, sizeof(int),1);
2701 objectsDirectory = new byte[len+1];
2702 f.Read(objectsDirectory, sizeof(char), len+1);
2703 project.options.objectsDirectory = objectsDirectory;
2704 delete objectsDirectory;
2706 f.Read(&temp, sizeof(int),1);
2707 project./*config.*/options.debug = temp ? true : false;
2708 f.Read(&temp, sizeof(int),1);
2709 project./*config.*/options.optimization = temp ? speed : none;
2710 f.Read(&temp, sizeof(int),1);
2711 project./*config.*/options.profile = temp ? true : false;
2712 f.Read(&temp, sizeof(int),1);
2713 project.options.warnings = temp ? all : unset;
2715 f.Read(&count, sizeof(int),1);
2718 project.options.includeDirs = { };
2719 for(c = 0; c < count; c++)
2722 f.Read(&len, sizeof(int),1);
2723 name = new char[len+1];
2724 f.Read(name, sizeof(char), len+1);
2725 project.options.includeDirs.Add(name);
2729 f.Read(&count, sizeof(int),1);
2732 project.options.libraryDirs = { };
2733 for(c = 0; c < count; c++)
2736 f.Read(&len, sizeof(int),1);
2737 name = new char[len+1];
2738 f.Read(name, sizeof(char), len+1);
2739 project.options.libraryDirs.Add(name);
2743 f.Read(&count, sizeof(int),1);
2746 project.options.libraries = { };
2747 for(c = 0; c < count; c++)
2750 f.Read(&len, sizeof(int),1);
2751 name = new char[len+1];
2752 f.Read(name, sizeof(char), len+1);
2753 project.options.libraries.Add(name);
2757 f.Read(&count, sizeof(int),1);
2760 project.options.preprocessorDefinitions = { };
2761 for(c = 0; c < count; c++)
2764 f.Read(&len, sizeof(int),1);
2765 name = new char[len+1];
2766 f.Read(name, sizeof(char), len+1);
2767 project.options.preprocessorDefinitions.Add(name);
2771 f.Read(&temp, sizeof(int),1);
2772 project.options.console = temp ? true : false;
2775 for(node : project.topNode.files)
2777 if(node.type == resources)
2779 project.resNode = node;
2789 void ProjectConfig::LegacyProjectConfigLoad(File f)
2797 char subSection[128];
2803 f.GetLine(buffer, 65536 - 1);
2804 TrimLSpaces(buffer, buffer);
2805 TrimRSpaces(buffer, buffer);
2808 if(buffer[0] == '-')
2812 TrimLSpaces(equal, equal);
2813 if(!strcmpi(subSection, "LibraryDirs"))
2815 if(!options.libraryDirs)
2816 options.libraryDirs = { [ CopyString(equal) ] };
2818 options.libraryDirs.Add(CopyString(equal));
2820 else if(!strcmpi(subSection, "IncludeDirs"))
2822 if(!options.includeDirs)
2823 options.includeDirs = { [ CopyString(equal) ] };
2825 options.includeDirs.Add(CopyString(equal));
2828 else if(buffer[0] == '+')
2839 TrimLSpaces(equal, equal);
2840 delete name; name = CopyString(equal); // property::name = equal;
2843 else if(!strcmpi(buffer, "Compiler Options"))
2844 strcpy(section, buffer);
2845 else if(!strcmpi(buffer, "IncludeDirs"))
2846 strcpy(subSection, buffer);
2847 else if(!strcmpi(buffer, "Linker Options"))
2848 strcpy(section, buffer);
2849 else if(!strcmpi(buffer, "LibraryDirs"))
2850 strcpy(subSection, buffer);
2851 else if(!strcmpi(buffer, "Files") || !strcmpi(buffer, "Resources"))
2858 equal = strstr(buffer, "=");
2862 TrimRSpaces(buffer, buffer);
2864 TrimLSpaces(equal, equal);
2865 if(!strcmpi(buffer, "Target Name"))
2866 options.targetFileName = /*CopyString(*/equal/*)*/;
2867 else if(!strcmpi(buffer, "Target Type"))
2869 if(!strcmpi(equal, "Executable"))
2870 options.targetType = executable;
2871 else if(!strcmpi(equal, "Shared"))
2872 options.targetType = sharedLibrary;
2873 else if(!strcmpi(equal, "Static"))
2874 options.targetType = staticLibrary;
2876 options.targetType = executable;
2878 else if(!strcmpi(buffer, "Target Directory"))
2879 options.targetDirectory = /*CopyString(*/equal/*)*/;
2880 else if(!strcmpi(buffer, "Console"))
2881 options.console = ParseTrueFalseValue(equal);
2882 else if(!strcmpi(buffer, "Libraries"))
2884 if(!options.libraries) options.libraries = { };
2885 ParseArrayValue(options.libraries, equal);
2887 else if(!strcmpi(buffer, "Intermediate Directory"))
2888 options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
2889 else if(!strcmpi(buffer, "Debug"))
2890 options.debug = ParseTrueFalseValue(equal);
2891 else if(!strcmpi(buffer, "Optimize"))
2893 if(!strcmpi(equal, "None"))
2894 options.optimization = none;
2895 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
2896 options.optimization = speed;
2897 else if(!strcmpi(equal, "Size"))
2898 options.optimization = size;
2900 options.optimization = none;
2902 else if(!strcmpi(buffer, "Compress"))
2903 options.compress = ParseTrueFalseValue(equal);
2904 else if(!strcmpi(buffer, "Profile"))
2905 options.profile = ParseTrueFalseValue(equal);
2906 else if(!strcmpi(buffer, "AllWarnings"))
2907 options.warnings = ParseTrueFalseValue(equal) ? all : unset;
2908 else if(!strcmpi(buffer, "MemoryGuard"))
2909 options.memoryGuard = ParseTrueFalseValue(equal);
2910 else if(!strcmpi(buffer, "Default Name Space"))
2911 options.defaultNameSpace = CopyString(equal);
2912 else if(!strcmpi(buffer, "Strict Name Spaces"))
2913 options.strictNameSpaces = ParseTrueFalseValue(equal);
2914 else if(!strcmpi(buffer, "Preprocessor Definitions"))
2916 if(!options.preprocessorDefinitions) options.preprocessorDefinitions = { };
2917 ParseArrayValue(options.preprocessorDefinitions, equal);
2923 if(!options.targetDirectory && options.objectsDirectory)
2924 options.targetDirectory = /*CopyString(*/options.objectsDirectory/*)*/;
2925 //if(!objDir.dir) objDir.dir = "obj";
2926 //if(!targetDir.dir) targetDir.dir = "";
2927 // if(!targetName) property::targetName = ""; // How can a targetFileName be nothing???
2928 // if(!defaultNameSpace) property::defaultNameSpace = "";
2929 makingModified = true;
2932 Project LegacyAsciiLoadProject(File f, char * filePath)
2934 Project project = null;
2935 ProjectNode node = null;
2937 char parentPath[MAX_LOCATION];
2938 char section[128] = "";
2939 char subSection[128] = "";
2941 bool configurationsPresent = false;
2951 f.GetLine(buffer, 65536 - 1);
2952 TrimLSpaces(buffer, buffer);
2953 TrimRSpaces(buffer, buffer);
2956 if(buffer[0] == '-' || buffer[0] == '=')
2958 bool simple = buffer[0] == '-';
2961 TrimLSpaces(equal, equal);
2962 if(!strcmpi(section, "Target") && !strcmpi(subSection, "LibraryDirs"))
2964 if(!project.config.options.libraryDirs) project.config.options.libraryDirs = { };
2965 project.config.options.libraryDirs.Add(CopyString(equal));
2967 else if(!strcmpi(section, "Target") && !strcmpi(subSection, "IncludeDirs"))
2969 if(!project.config.options.includeDirs) project.config.options.includeDirs = { };
2970 project.config.options.includeDirs.Add(CopyString(equal));
2972 else if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
2974 len = strlen(equal);
2977 char temp[MAX_LOCATION];
2978 ProjectNode child { };
2979 // We don't need to do this anymore, fileName is just a property that sets name & path
2980 // child.fileName = CopyString(equal);
2983 child.name = CopyString(equal);
2984 child.path = CopyString(parentPath);
2988 GetLastDirectory(equal, temp);
2989 child.name = CopyString(temp);
2990 StripLastDirectory(equal, temp);
2991 child.path = CopyString(temp);
2993 child.nodeType = file;
2994 child.parent = parent;
2995 child.indent = parent.indent + 1;
2997 child.icon = NodeIcons::SelectFileIcon(child.name);
2998 parent.files.Add(child);
3004 StripLastDirectory(parentPath, parentPath);
3005 parent = parent.parent;
3009 else if(buffer[0] == '+')
3013 TrimLSpaces(equal, equal);
3014 if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
3016 char temp[MAX_LOCATION];
3017 ProjectNode child { };
3018 // NEW: Folders now have a path set like files
3019 child.name = CopyString(equal);
3020 strcpy(temp, parentPath);
3021 PathCatSlash(temp, child.name);
3022 child.path = CopyString(temp);
3024 child.parent = parent;
3025 child.indent = parent.indent + 1;
3026 child.type = folder;
3027 child.nodeType = folder;
3029 child.icon = folder;
3030 PathCatSlash(parentPath, child.name);
3031 parent.files.Add(child);
3036 else if(!strcmpi(section, "Configurations"))
3038 ProjectConfig newConfig
3040 makingModified = true;
3044 LegacyProjectConfigLoad(newConfig, f);
3045 project.configurations.Add(newConfig);
3048 else if(!strcmpi(buffer, "ECERE Project File"));
3049 else if(!strcmpi(buffer, "Version 0a"))
3050 ; //strcpy(version, "0a");
3051 else if(!strcmpi(buffer, "Version 0.1a"))
3052 ; //strcpy(version, "0.1a");
3053 else if(!strcmpi(buffer, "Configurations"))
3055 project.configurations.Free();
3056 project.config = null;
3057 strcpy(section, buffer);
3058 configurationsPresent = true;
3060 else if(!strcmpi(buffer, "Target") || !strnicmp(buffer, "Target \"", strlen("Target \"")))
3062 ProjectConfig newConfig { name = CopyString("Default"), options = { } };
3063 char topNodePath[MAX_LOCATION];
3064 // newConfig.defaultNameSpace = "";
3065 //newConfig.objDir.dir = "obj";
3066 //newConfig.targetDir.dir = "";
3067 project = Project { /*options = { }*/ };
3068 project.configurations = { [ newConfig ] };
3069 project.config = newConfig;
3070 // if(project.topNode.path) delete project.topNode.path;
3071 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3072 MakeSlashPath(topNodePath);
3073 PathCatSlash(topNodePath, filePath);
3074 project.filePath = topNodePath;
3075 parentPath[0] = '\0';
3076 parent = project.topNode;
3078 strcpy(section, "Target");
3083 if(equal[0] == '\"')
3085 StripQuotes(equal, equal);
3086 delete project.moduleName; project.moduleName = CopyString(equal);
3090 else if(!strcmpi(buffer, "Compiler Options"));
3091 else if(!strcmpi(buffer, "IncludeDirs"))
3092 strcpy(subSection, buffer);
3093 else if(!strcmpi(buffer, "Linker Options"));
3094 else if(!strcmpi(buffer, "LibraryDirs"))
3095 strcpy(subSection, buffer);
3096 else if(!strcmpi(buffer, "Files"))
3098 strcpy(section, "Target");
3099 strcpy(subSection, buffer);
3101 else if(!strcmpi(buffer, "Resources"))
3103 ProjectNode child { };
3104 parent.files.Add(child);
3105 child.parent = parent;
3106 child.indent = parent.indent + 1;
3107 child.name = CopyString(buffer);
3108 child.path = CopyString("");
3109 child.type = resources;
3111 child.icon = archiveFile;
3112 project.resNode = child;
3115 strcpy(subSection, buffer);
3119 equal = strstr(buffer, "=");
3123 TrimRSpaces(buffer, buffer);
3125 TrimLSpaces(equal, equal);
3127 if(!strcmpi(section, "Target"))
3129 if(!strcmpi(buffer, "Build Exclusions"))
3131 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
3133 /*if(node && node.type != NodeTypes::project)
3134 ParseListValue(node.buildExclusions, equal);*/
3137 else if(!strcmpi(buffer, "Path") && !strcmpi(subSection, "Resources"))
3139 delete project.resNode.path;
3140 project.resNode.path = CopyString(equal);
3141 PathCatSlash(parentPath, equal);
3145 else if(!strcmpi(buffer, "Intermediate Directory"))
3146 project.config.options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
3147 else if(!strcmpi(buffer, "Debug"))
3148 project.config.options.debug = ParseTrueFalseValue(equal);
3149 else if(!strcmpi(buffer, "Optimize"))
3151 if(!strcmpi(equal, "None"))
3152 project.config.options.optimization = none;
3153 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
3154 project.config.options.optimization = speed;
3155 else if(!strcmpi(equal, "Size"))
3156 project.config.options.optimization = size;
3158 project.config.options.optimization = none;
3160 else if(!strcmpi(buffer, "Profile"))
3161 project.config.options.profile = ParseTrueFalseValue(equal);
3162 else if(!strcmpi(buffer, "MemoryGuard"))
3163 project.config.options.memoryGuard = ParseTrueFalseValue(equal);
3166 if(!project.options) project.options = { };
3168 // Project Wide Settings (All configs)
3169 if(!strcmpi(buffer, "Target Name"))
3170 project.options.targetFileName = /*CopyString(*/equal/*)*/;
3171 else if(!strcmpi(buffer, "Target Type"))
3173 if(!strcmpi(equal, "Executable"))
3174 project.options.targetType = executable;
3175 else if(!strcmpi(equal, "Shared"))
3176 project.options.targetType = sharedLibrary;
3177 else if(!strcmpi(equal, "Static"))
3178 project.options.targetType = staticLibrary;
3180 project.options.targetType = executable;
3182 else if(!strcmpi(buffer, "Target Directory"))
3183 project.options.targetDirectory = /*CopyString(*/equal/*)*/;
3184 else if(!strcmpi(buffer, "Console"))
3185 project.options.console = ParseTrueFalseValue(equal);
3186 else if(!strcmpi(buffer, "Libraries"))
3188 if(!project.options.libraries) project.options.libraries = { };
3189 ParseArrayValue(project.options.libraries, equal);
3191 else if(!strcmpi(buffer, "AllWarnings"))
3192 project.options.warnings = ParseTrueFalseValue(equal) ? all : unset;
3193 else if(!strcmpi(buffer, "Preprocessor Definitions"))
3195 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
3197 /*if(node && (node.type == NodeTypes::project || (node.type == file && !node.isInResources) || node.type == folder))
3198 ParseListValue(node.preprocessorDefs, equal);*/
3202 if(!project.options.preprocessorDefinitions) project.options.preprocessorDefinitions = { };
3203 ParseArrayValue(project.options.preprocessorDefinitions, equal);
3214 SplitPlatformLibraries(project);
3216 if(configurationsPresent)
3217 CombineIdenticalConfigOptions(project);
3221 void SplitPlatformLibraries(Project project)
3223 if(project && project.configurations)
3225 for(cfg : project.configurations)
3227 if(cfg.options.libraries && cfg.options.libraries.count)
3229 Iterator<String> it { cfg.options.libraries };
3233 char * platformName = strstr(l, ":");
3236 PlatformOptions platform = null;
3238 if(!cfg.platforms) cfg.platforms = { };
3239 for(p : cfg.platforms)
3241 if(!strcmpi(platformName, p.name))
3249 platform = { name = CopyString(platformName), options = { libraries = { } } };
3250 cfg.platforms.Add(platform);
3252 *(platformName-1) = 0;
3253 platform.options.libraries.Add(CopyString(l));
3255 cfg.options.libraries.Delete(it.pointer);
3264 void CombineIdenticalConfigOptions(Project project)
3266 if(project && project.configurations && project.configurations.count)
3269 ProjectOptions nullOptions { };
3270 ProjectConfig firstConfig = null;
3271 for(cfg : project.configurations)
3273 if(cfg.options.targetType != staticLibrary)
3280 firstConfig = project.configurations.firstIterator.data;
3282 for(member = class(ProjectOptions).membersAndProperties.first; member; member = member.next)
3284 if(!member.isProperty)
3286 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
3291 for(cfg : project.configurations)
3293 if(cfg != firstConfig)
3295 if(cfg.options.targetType != staticLibrary)
3299 if(type.type == noHeadClass || type.type == normalClass)
3301 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3302 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3303 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3307 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3308 (byte *)firstConfig.options + member.offset + member._class.offset,
3309 (byte *)cfg.options + member.offset + member._class.offset);
3321 if(type.type == noHeadClass || type.type == normalClass)
3323 if(!type._vTbl[__ecereVMethodID_class_OnCompare](type,
3324 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3325 *(void **)((byte *)nullOptions + member.offset + member._class.offset)))
3330 if(!type._vTbl[__ecereVMethodID_class_OnCompare](type,
3331 (byte *)firstConfig.options + member.offset + member._class.offset,
3332 (byte *)nullOptions + member.offset + member._class.offset))
3336 if(!project.options) project.options = { };
3338 /*if(type.type == noHeadClass || type.type == normalClass)
3340 type._vTbl[__ecereVMethodID_class_OnCopy](type,
3341 (byte *)project.options + member.offset + member._class.offset,
3342 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
3346 void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
3347 // TOFIX: ListBox::SetData / OnCopy mess
3348 type._vTbl[__ecereVMethodID_class_OnCopy](type,
3349 (byte *)project.options + member.offset + member._class.offset,
3350 (type.typeSize > 4) ? address :
3351 ((type.typeSize == 4) ? (void *)*(uint32 *)address :
3352 ((type.typeSize == 2) ? (void *)*(uint16*)address :
3353 (void *)*(byte *)address )));
3356 (byte *)project.options + member.offset + member._class.offset,
3357 (byte *)firstConfig.options + member.offset + member._class.offset, type.typeSize);
3359 for(cfg : project.configurations)
3361 if(cfg.options.targetType == staticLibrary)
3365 if(type.type == noHeadClass || type.type == normalClass)
3367 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3368 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3369 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3373 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3374 (byte *)firstConfig.options + member.offset + member._class.offset,
3375 (byte *)cfg.options + member.offset + member._class.offset);
3380 if(cfg != firstConfig)
3382 if(type.type == noHeadClass || type.type == normalClass)
3384 type._vTbl[__ecereVMethodID_class_OnFree](type,
3385 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3389 type._vTbl[__ecereVMethodID_class_OnFree](type,
3390 (byte *)cfg.options + member.offset + member._class.offset);
3392 memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
3395 memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
3402 // Compare Platform Specific Settings
3405 for(cfg : project.configurations)
3407 if(cfg != firstConfig && cfg.options.targetType != staticLibrary && (firstConfig.platforms || cfg.platforms) &&
3408 ((!firstConfig.platforms && cfg.platforms) || firstConfig.platforms.OnCompare(cfg.platforms)))
3414 if(same && firstConfig.platforms)
3416 for(cfg : project.configurations)
3418 if(cfg.options.targetType == staticLibrary && firstConfig.platforms.OnCompare(cfg.platforms))
3420 if(cfg != firstConfig)
3422 cfg.platforms.Free();
3423 delete cfg.platforms;
3426 project.platforms = firstConfig.platforms;
3427 firstConfig.platforms = null;
3431 // Static libraries can't contain libraries
3432 for(cfg : project.configurations)
3434 if(cfg.options.targetType == staticLibrary)
3436 if(!cfg.options.libraries) cfg.options.libraries = { };
3437 cfg.options.libraries.Free();
3443 Project LoadProject(char * filePath)
3445 Project project = null;
3446 File f = FileOpen(filePath, read);
3449 project = LegacyBinaryLoadProject(f, filePath);
3452 JSONParser parser { f = f };
3453 JSONResult result = parser.GetObject(class(Project), &project);
3456 char insidePath[MAX_LOCATION];
3458 delete project.topNode.files;
3459 if(!project.files) project.files = { };
3460 project.topNode.files = project.files;
3461 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
3462 delete project.resNode.path;
3463 project.resNode.path = project.resourcesPath;
3464 project.resourcesPath = null;
3465 project.resNode.nodeType = (ProjectNodeType)-1;
3466 delete project.resNode.files;
3467 project.resNode.files = project.resources;
3468 project.files = null;
3469 project.resources = null;
3470 if(!project.configurations) project.configurations = { };
3473 char topNodePath[MAX_LOCATION];
3474 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3475 MakeSlashPath(topNodePath);
3476 PathCatSlash(topNodePath, filePath);
3477 project.filePath = topNodePath;//filePath;
3480 project.topNode.FixupNode(insidePath);
3485 project = LegacyAsciiLoadProject(f, filePath);
3491 if(!project.options) project.options = { };
3492 if(!project.config && project.configurations)
3493 project.config = project.configurations.firstIterator.data;
3495 if(!project.resNode)
3497 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
3500 if(!project.moduleName)
3501 project.moduleName = CopyString(project.name);
3502 if(project.config &&
3503 (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
3504 (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
3506 //delete project.config.options.targetFileName;
3508 project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
3509 project.config.options.optimization = none;
3510 project.config.options.debug = true;
3511 //project.config.options.warnings = unset;
3512 project.config.options.memoryGuard = false;
3513 project.config.compilingModified = true;
3514 project.config.linkingModified = true;
3516 else if(!project.topNode.name && project.config)
3518 project.topNode.name = CopyString(project.config.options.targetFileName);
3521 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
3522 project.topNode.configurations = project.configurations;
3523 project.topNode.platforms = project.platforms;
3524 project.topNode.options = project.options;*/