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;
33 IDESettings ideSettings;
35 IDESettingsContainer settingsContainer
38 dataOwner = &ideSettings;
39 dataClass = class(IDESettings);
41 void OnLoad(GlobalSettingsData data)
43 IDESettings settings = (IDESettings)data;
44 #ifndef MAKEFILE_GENERATOR
45 globalSettingsDialog.ideSettings = settings;
46 ide.UpdateRecentMenus();
47 // ide.UpdateMakefiles(); -- can't really regenerate on Load since all recent menus changes will happen
52 #ifdef MAKEFILE_GENERATOR
53 CompilerConfig defaultCompiler;
56 // LEGACY BINARY EPJ LOADING
58 SetBool ParseTrueFalseValue(char * string)
60 if(!strcmpi(string, "True")) return true;
64 void ParseArrayValue(Array<String> array, char * equal)
66 char * start, * comma;
68 string = CopyString(equal);
72 comma = strstr(start, ",");
75 array.Add(CopyString(start));
85 void ProjectNode::LegacyBinaryLoadNode(File f)
90 f.Read(&len, sizeof(len), 1);
91 name = new char[len+1];
93 f.Read(name, sizeof(char), len+1);
94 f.Read(&len, sizeof(len), 1);
96 path = new char[len+1];
97 f.Read(path, sizeof(char), len+1);
100 fileName = new char[fileNameLen+2];
101 strcpy(fileName, path);
102 if(fileName[0]) strcat(fileName, "/");
103 strcat(fileName, name);
106 f.Read(&type, sizeof(type), 1);
107 f.Read(&count, sizeof(count), 1);
112 icon = NodeIcons::SelectFileIcon(name);
117 icon = NodeIcons::SelectNodeIcon(type);
120 if(count && !files) files = { };
121 for(c = 0; c < count; c++)
123 ProjectNode child { };
126 child.indent = indent + 1;
127 LegacyBinaryLoadNode(child, f);
131 /*void LegacyBinarySaveNode(File f)
136 f.Write(&len, sizeof(len), 1);
137 f.Write(name, sizeof(char), len+1);
141 // Projects Absolute Path Are Not Saved
143 f.Write(&len, sizeof(len), 1);
144 f.Write(&len, sizeof(char), 1);
149 f.Write(&len, sizeof(len), 1);
150 f.Write(path, sizeof(char), len+1);
152 f.Write(&type, sizeof(type), 1);
153 f.Write(&children.count, sizeof(children.count), 1);
154 for(child = children.first; child; child.next)
158 void ProjectNode::LegacyAsciiSaveNode(File f, char * indentation, char * insidePath)
161 char printPath[MAX_LOCATION];
163 if(type == project && (files.count /*|| preprocessorDefs.first*/))
165 f.Printf("\n Files\n");
167 else if(type == file)
169 if(!strcmp(path, insidePath))
170 f.Printf("%s - %s\n", indentation, name);
173 strcpy(printPath, path);
174 len = strlen(printPath);
176 if(printPath[len-1] != '/')
177 strcat(printPath, "/");
178 strcat(printPath, name);
179 f.Printf("%s = %s\n", indentation, printPath);
182 f.Printf("\nError\n\n");
184 else if(type == folder)
186 f.Printf("%s + %s\n", indentation, name);
188 else if(type == resources && files.count)
190 PathCatSlash(insidePath, path);
191 f.Printf("\n%sResources\n", indentation);
193 f.Printf("%s Path = %s\n", indentation, path);
196 /*if(buildExclusions.first && type != project)
198 for(item = buildExclusions.first; item; item = item.next)
200 if(item == buildExclusions.first)
201 f.Printf("%s Build Exclusions = %s", indentation, item.name);
203 f.Printf(", %s", item.name);
208 if(preprocessorDefs.first && (type == project || ((type == file || type == folder) && !isInResources)))
210 for(item = preprocessorDefs.first; item; item = item.next)
212 if(item == preprocessorDefs.first)
213 f.Printf("%s%s Preprocessor Definitions = %s", indentation, type == project ? "" : " ", item.name);
215 f.Printf(", %s", item.name);
221 if(type == project && (files.count /*|| preprocessorDefs.first*/))
225 LegacyAsciiSaveNode(child, f, indentation, insidePath);
227 else if(type == folder)
229 strcat(indentation, " ");
230 // WHAT WAS THIS: strcpy(printPath, path);
231 // TOCHECK: why is Unix/PathCat not used here
232 len = strlen(insidePath);
234 if(insidePath[len-1] != '/')
235 strcat(insidePath, "/");
236 strcat(insidePath, name);
239 LegacyAsciiSaveNode(child, f, indentation, insidePath);
240 f.Printf("%s -\n", indentation);
241 indentation[strlen(indentation) - 3] = '\0';
242 StripLastDirectory(insidePath, insidePath);
244 else if(type == resources && files.count)
248 LegacyAsciiSaveNode(child, f, indentation, insidePath);
249 StripLastDirectory(insidePath, insidePath);
254 void ProjectConfig::LegacyProjectConfigSave(File f)
256 char * indentation = " ";
258 //f.Printf("\n * Common\n");
260 f.Printf("\n + %s\n", name);
261 f.Printf("\n Compiler\n\n");
262 if(objDir.expression[0])
263 f.Printf("%sIntermediate Directory = %s\n", indentation, objDir.expression);
264 f.Printf("%sDebug = %s\n", indentation, (options.debug == true) ? "True" : "False");
265 switch(options.optimization)
267 // case none: f.Printf("%sOptimize = %s\n", indentation, "None"); break;
268 case speed: f.Printf("%sOptimize = %s\n", indentation, "Speed"); break;
269 case size: f.Printf("%sOptimize = %s\n", indentation, "Size"); break;
271 f.Printf("%sAllWarnings = %s\n", indentation, (options.warnings == all) ? "True" : "False");
273 f.Printf("%sProfile = %s\n", indentation, (options.profile == true) ? "True" : "False");
274 if(options.memoryGuard == true)
275 f.Printf("%sMemoryGuard = %s\n", indentation, (options.memoryGuard == true) ? "True" : "False");
276 if(options.strictNameSpaces == true)
277 f.Printf("%sStrict Name Spaces = %s\n", indentation, (options.strictNameSpaces == true) ? "True" : "False");
278 if(options.defaultNameSpace && strlen(options.defaultNameSpace))
279 f.Printf("%sDefault Name Space = %s\n", indentation, options.defaultNameSpace);
280 TOFIX: Compiler Bug {
281 if(options.preprocessorDefinitions.count)
284 for(item : options.preprocessorDefinitions)
288 f.Printf("\n%sPreprocessor Definitions = %s", indentation, item);
292 f.Printf(", %s", item);
297 if(options.includeDirs.count)
299 f.Printf("\n%sInclude Directories\n", indentation);
300 for(item : options.includeDirs)
301 f.Printf("%s - %s\n", indentation, name);
305 f.Printf("\n%sLinker\n\n", indentation);
306 f.Printf("%sTarget Name = %s\n", indentation, options.targetFileName);
307 switch(options.targetType)
309 case executable: f.Printf("%sTarget Type = %s\n", indentation, "Executable"); break;
310 case sharedLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Shared"); break;
311 case staticLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Static"); break;
313 if(targetDir.expression[0])
314 f.Printf("%sTarget Directory = %s\n", indentation, targetDir.expression);
316 f.Printf("%sConsole = %s\n", indentation, options.console ? "True" : "False");
318 f.Printf("%sCompress = %s\n", indentation, options.compress ? "True" : "False");
319 if(options.libraries.count)
322 for(item : options.libraries)
326 f.Printf("\n%sLibraries = %s", indentation, name);
330 f.Printf(", %s", item);
334 if(options.libraryDirs.count)
336 f.Printf("\n%sLibrary Directories\n\n", indentation);
337 for(item : options.libraryDirs)
338 f.Printf(" - %s\n", indentation, item);
342 void LegacyAsciiSaveProject(File f, Project project)
344 char indentation[128*3];
345 char path[MAX_LOCATION];
347 f.Printf("\nECERE Project File : Format Version 0.1b\n");
348 f.Printf("\nDescription\n%s\n.\n", project.description);
349 f.Printf("\nLicense\n%s\n.\n", project.license);
350 f.Printf("\nModule Name = %s\n", project.moduleName);
351 f.Printf("\n Configurations\n");
352 //////////////////////////////////////commonConfig.Save(f, true);
353 for(cfg : project.configurations)
354 LegacyProjectConfigSave(cfg, f);
356 strcpy(indentation, " ");
358 LegacyAsciiSaveNode(project.topNode, f, indentation, path);
364 // *** NEW JSON PROJECT FORMAT ***
365 public enum ProjectNodeType { file, folder };
367 // *******************************
369 define PEEK_RESOLUTION = (18.2 * 10);
375 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
377 enum GenMakefilePrintTypes { objects, cObjects, symbols, imports, sources, resources };
379 define WorkspaceExtension = "ews";
380 define ProjectExtension = "epj";
382 define stringInFileIncludedFrom = "In file included from ";
384 void ReplaceSpaces(char * output, char * source)
389 for(c = 0, dc = 0; (ch = source[c]); c++, dc++)
391 if(ch == ' ') output[dc++] = '\\';
394 if(ch == '(' || ch == ')') output[dc++] = '\\';
404 static void OutputNoSpace(File f, char * source)
406 char * output = new char[strlen(source)+1024];
407 ReplaceSpaces(output, source);
412 enum ListOutputMethod { inPlace, newLine, lineEach };
414 int OutputFileList(File f, char * name, Array<String> list, Map<String, int> varStringLenDiffs)
417 const int breakListLength = 1536;
418 const int breakLineLength = 78; // TODO: turn this into an option.
420 int c, len, itemCount = 0;
421 Array<int> breaks { };
425 MapNode<String, int> mn;
426 for(c=0; c<list.count; c++)
428 len = strlen(list[c]) + 3;
429 if(strstr(list[c], "$(") && varStringLenDiffs && varStringLenDiffs.count)
431 for(mn = varStringLenDiffs.root.minimum; mn; mn = mn.next)
433 if(strstr(list[c], mn.key))
437 if(charCount + len > breakListLength)
439 breaks.Add(itemCount);
447 breaks.Add(itemCount);
448 numOfBreaks = breaks.count;
453 f.Printf("%s =", name);
454 for(c=0; c<numOfBreaks; c++)
455 f.Printf(" $(%s%d)", name, c+1);
459 f.Printf("%s =", name);
465 for(c=0; c<numOfBreaks; c++)
468 f.Printf("%s%d =", name, c+1);
471 itemCount = breaks[c];
472 for(n=offset; n<offset+itemCount; n++)
474 if(false) // TODO: turn this into an option.
476 int itemLen = strlen(list[n]);
477 if(len > 3 && len + itemLen > breakLineLength)
479 f.Printf(" \\\n\t%s", list[n]);
485 f.Printf(" %s", list[n]);
489 f.Printf(" \\\n\t%s", list[n]);
504 void OutputCleanActions(File f, char * name, int parts)
509 for(c=0; c<parts; c++)
510 f.Printf("\t$(call rmq,$(%s%d))\n", name, c+1);
513 f.Printf("\t$(call rmq,$(%s))\n", name);
516 void OutputListOption(File f, char * option, Array<String> list, ListOutputMethod method, bool noSpace)
520 if(method == newLine)
524 if(method == lineEach)
526 f.Printf(" -%s", option);
528 OutputNoSpace(f, item);
530 f.Printf("%s", item);
535 static void OutputLibraries(File f, Array<String> libraries)
537 for(item : libraries)
539 char ext[MAX_EXTENSION];
540 char temp[MAX_LOCATION];
542 GetExtension(item, ext);
543 if(!strcmp(ext, "o") || !strcmp(ext, "a"))
547 if(!strcmp(ext, "so") || !strcmp(ext, "dylib"))
549 if(!strncmp(item, "lib", 3))
550 strcpy(temp, item + 3);
553 StripExtension(temp);
562 void CamelCase(char * string)
564 int c, len = strlen(string);
565 for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
566 string[c] = (char)tolower(string[c]);
569 CompilerConfig GetCompilerConfig()
571 #ifndef MAKEFILE_GENERATOR
572 CompilerConfig compiler = null;
573 if(ide && ide.workspace)
574 compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
577 incref defaultCompiler;
578 return defaultCompiler;
582 define localTargetType = config && config.options && config.options.targetType ?
583 config.options.targetType : options && options.targetType ?
584 options.targetType : TargetTypes::executable;
585 define localWarnings = config && config.options && config.options.warnings ?
586 config.options.warnings : options && options.warnings ?
587 options.warnings : WarningsOption::unset;
588 define localDebug = config && config.options && config.options.debug ?
589 config.options.debug : options && options.debug ?
590 options.debug : SetBool::unset;
591 define localMemoryGuard = config && config.options && config.options.memoryGuard ?
592 config.options.memoryGuard : options && options.memoryGuard ?
593 options.memoryGuard : SetBool::unset;
594 define localNoLineNumbers = config && config.options && config.options.noLineNumbers ?
595 config.options.noLineNumbers : options && options.noLineNumbers ?
596 options.noLineNumbers : SetBool::unset;
597 define localProfile = config && config.options && config.options.profile ?
598 config.options.profile : options && options.profile ?
599 options.profile : SetBool::unset;
600 define localOptimization = config && config.options && config.options.optimization ?
601 config.options.optimization : options && options.optimization ?
602 options.optimization : OptimizationStrategy::none;
603 define localDefaultNameSpace = config && config.options && config.options.defaultNameSpace ?
604 config.options.defaultNameSpace : options && options.defaultNameSpace ?
605 options.defaultNameSpace : null;
606 define localStrictNameSpaces = config && config.options && config.options.strictNameSpaces ?
607 config.options.strictNameSpaces : options && options.strictNameSpaces ?
608 options.strictNameSpaces : SetBool::unset;
609 // TODO: I would rather have null here, check if it'll be ok, have the property return "" if required
610 define localTargetFileName = config && config.options && config.options.targetFileName ?
611 config.options.targetFileName : options && options.targetFileName ?
612 options.targetFileName : "";
613 define localTargetDirectory = config && config.options && config.options.targetDirectory && config.options.targetDirectory[0] ?
614 config.options.targetDirectory : options && options.targetDirectory && options.targetDirectory[0] ?
615 options.targetDirectory : null;
616 define settingsTargetDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
617 ideSettings.projectDefaultIntermediateObjDir[0] ?
618 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
619 define localObjectsDirectory = config && config.options && config.options.objectsDirectory && config.options.objectsDirectory[0] ?
620 config.options.objectsDirectory : options && options.objectsDirectory && options.objectsDirectory[0] ?
621 options.objectsDirectory : null;
622 define settingsObjectsDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
623 ideSettings.projectDefaultIntermediateObjDir[0] ?
624 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
625 define localConsole = config && config.options && config.options.console ?
626 config.options.console : options && options.console ?
627 options.console : SetBool::unset;
628 define localCompress = config && config.options && config.options.compress ?
629 config.options.compress : options && options.compress ?
630 options.compress : SetBool::unset;
632 define platformTargetType =
633 configPOs && configPOs.options && configPOs.options.targetType && configPOs.options.targetType != localTargetType ?
634 configPOs.options.targetType :
635 projectPOs && projectPOs.options && projectPOs.options.targetType && projectPOs.options.targetType != localTargetType ?
636 projectPOs.options.targetType : TargetTypes::unset;
639 // we should have some kind of direct mapping between a platform and it's makefile variable
640 char * PlatformToMakefileVariable(Platform platform)
642 return platform == win32 ? "WINDOWS" :
643 platform == tux ? "LINUX" :
644 platform == apple ? "OSX"/*"APPLE"*/ :
648 char * TargetTypeToMakefileVariable(TargetTypes targetType)
650 return targetType == executable ? "executable" :
651 targetType == sharedLibrary ? "sharedlib" :
652 targetType == staticLibrary ? "staticlib" :
656 // Move this to ProjectConfig? null vs Common to consider...
657 char * GetConfigName(ProjectConfig config)
659 return config ? config.name : "Common";
662 class Project : struct
664 class_no_expansion; // To use Find on the Container<Project> in Workspace::projects
665 // We might want to tweak this default behavior of regular classes ?
666 // Expansion/the current default kind of Find matching we want for things like BitmapResource, FontResource (Also regular classes)
671 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
672 property Array<PlatformOptions> platforms
674 get { return platforms; }
677 if(platforms) { platforms.Free(); delete platforms; }
680 List<PlatformOptions> empty { };
681 Iterator<PlatformOptions> it { value };
683 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
684 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
694 if(p.options && !p.options.isEmpty)
701 List<ProjectConfig> configurations;
702 LinkList<ProjectNode> files;
703 String resourcesPath;
704 LinkList<ProjectNode> resources;
706 property char * description
708 set { delete description; if(value && value[0]) description = CopyString(value); }
709 get { return description ? description : ""; }
710 isset { return description != null && description[0]; }
713 property char * license
715 set { delete license; if(value && value[0]) license = CopyString(value); }
716 get { return license ? license : ""; }
717 isset { return license != null && license[0]; }
721 // topNode.name holds the file name (.epj)
722 ProjectOptions options;
723 Array<PlatformOptions> platforms;
724 ProjectNode topNode { type = project, icon = epjFile, files = LinkList<ProjectNode>{ }, project = this };
727 ProjectConfig config;
729 // This is the file name stripped of the epj extension
730 // It should NOT be edited, saved or loaded anywhere
738 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
739 topNode.configurations = null;
740 topNode.platforms = null;
741 topNode.options = null;
744 if(platforms) { platforms.Free(); delete platforms; }
745 if(configurations) { configurations.Free(); delete configurations; }
746 if(files) { files.Free(); delete files; }
747 if(resources) { resources.Free(); delete resources; }
749 delete resourcesPath;
759 property ProjectConfig config
765 topNode.info = CopyString(GetConfigName(config));
768 property char * filePath
774 char string[MAX_LOCATION];
775 GetLastDirectory(value, string);
777 topNode.name = CopyString(string);
778 StripExtension(string);
780 name = CopyString(string);
781 StripLastDirectory(value, string);
783 topNode.path = CopyString(string);
785 filePath = CopyString(value);
790 TargetTypes GetTargetType(ProjectConfig config)
792 TargetTypes targetType = localTargetType;
796 bool GetTargetTypeIsSetByPlatform(ProjectConfig config)
799 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
801 PlatformOptions projectPOs, configPOs;
802 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
803 if(platformTargetType)
810 char * GetObjDirExpression(CompilerConfig compiler, ProjectConfig config)
812 // TODO: Support platform options
813 char * expression = localObjectsDirectory;
815 expression = settingsObjectsDirectory;
819 DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config)
821 char * expression = GetObjDirExpression(compiler, config);
822 DirExpression objDir { type = intermediateObjectsDir };
823 objDir.Evaluate(expression, this, compiler, config);
827 char * GetTargetDirExpression(CompilerConfig compiler, ProjectConfig config)
829 // TODO: Support platform options
830 char * expression = localTargetDirectory;
832 expression = settingsTargetDirectory;
836 DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config)
838 char * expression = GetTargetDirExpression(compiler, config);
839 DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
840 targetDir.Evaluate(expression, this, compiler, config);
844 WarningsOption GetWarnings(ProjectConfig config)
846 WarningsOption warnings = localWarnings;
850 bool GetDebug(ProjectConfig config)
852 SetBool debug = localDebug;
853 return debug == true;
856 bool GetMemoryGuard(ProjectConfig config)
858 SetBool memoryGuard = localMemoryGuard;
859 return memoryGuard == true;
862 bool GetNoLineNumbers(ProjectConfig config)
864 SetBool noLineNumbers = localNoLineNumbers;
865 return noLineNumbers == true;
868 bool GetProfile(ProjectConfig config)
870 SetBool profile = localProfile;
871 return profile == true;
874 OptimizationStrategy GetOptimization(ProjectConfig config)
876 OptimizationStrategy optimization = localOptimization;
880 String GetDefaultNameSpace(ProjectConfig config)
882 String defaultNameSpace = localDefaultNameSpace;
883 return defaultNameSpace;
886 bool GetStrictNameSpaces(ProjectConfig config)
888 SetBool strictNameSpaces = localStrictNameSpaces;
889 return strictNameSpaces == true;
892 String GetTargetFileName(ProjectConfig config)
894 String targetFileName = localTargetFileName;
895 return targetFileName;
898 //String targetDirectory;
899 //String objectsDirectory;
900 bool GetConsole(ProjectConfig config)
902 SetBool console = localConsole;
903 return console == true;
906 bool GetCompress(ProjectConfig config)
908 SetBool compress = localCompress;
909 return compress == true;
911 //SetBool excludeFromBuild;
913 bool GetConfigIsInActiveDebugSession(ProjectConfig config)
915 #ifndef MAKEFILE_GENERATOR
916 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
920 bool GetConfigIsInDebugSession(ProjectConfig config)
922 #ifndef MAKEFILE_GENERATOR
923 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
927 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config)
929 #ifndef MAKEFILE_GENERATOR
930 ide.SetPath(projectsDirs, compiler, config);
934 #ifndef MAKEFILE_GENERATOR
935 bool Save(char * fileName)
938 /*char output[MAX_LOCATION];
939 ChangeExtension(fileName, "json", output);
940 f = FileOpen(output, write);*/
941 f = FileOpen(fileName, write);
944 files = topNode.files;
945 resources = resNode.files;
946 resourcesPath = resNode.path;
948 files.Remove(resNode);
951 WriteJSONObject(f, class(Project), this, 0);
957 resourcesPath = null;
964 #ifndef MAKEFILE_GENERATOR
965 bool GetRelativePath(char * filePath, char * relativePath)
968 char moduleName[MAX_FILENAME];
969 GetLastDirectory(filePath, moduleName);
970 // try with workspace dir first?
971 if((node = topNode.Find(moduleName, false)))
973 strcpy(relativePath, strcmp(node.path, ".") ? node.path : "");
974 PathCatSlash(relativePath, node.name);
977 // WARNING: On failure, relative path is uninitialized
982 void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
984 TargetTypes targetType = GetTargetType(config);
985 String targetFileName = GetTargetFileName(config);
986 if(targetType == staticLibrary)
988 PathCatSlash(string, "lib");
989 strcat(string, targetFileName);
991 else if(compiler.targetPlatform != win32 && targetType == sharedLibrary)
993 PathCatSlash(string, "lib");
994 strcat(string, targetFileName);
997 PathCatSlash(string, targetFileName);
1002 if(compiler.targetPlatform == win32)
1003 strcat(string, ".exe");
1006 if(compiler.targetPlatform == win32)
1007 strcat(string, ".dll");
1008 else if(compiler.targetPlatform == apple)
1009 strcat(string, ".dylib");
1011 strcat(string, ".so");
1014 strcat(string, ".a");
1019 void CatMakeFileName(char * string, CompilerConfig compiler, ProjectConfig config)
1021 char projectName[MAX_LOCATION];
1022 strcpy(projectName, name);
1023 if(strcmpi(compiler.name, defaultCompilerName))
1024 sprintf(string, "%s-%s-%s.Makefile", projectName, compiler.name, config.name);
1026 sprintf(string, "%s%s%s.Makefile", projectName, config ? "-" : "", config ? config.name : "");
1029 #ifndef MAKEFILE_GENERATOR
1030 void MarkChanges(ProjectNode node)
1032 for(cfg : topNode.configurations)
1034 ProjectConfig c = null;
1035 for(i : node.configurations; !strcmpi(i.name, cfg.name)) { c = i; break; }
1037 if(c && ((c.options && cfg.options && cfg.options.console != c.options.console) ||
1038 (!c.options || !cfg.options)))
1039 cfg.symbolGenModified = true;
1041 cfg.makingModified = true;
1045 void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
1047 for(cfg : configurations)
1050 cfg.makingModified = true;
1052 cfg.compilingModified = true;
1054 cfg.linkingModified = true;
1056 cfg.symbolGenModified = true;
1058 if(compiling || linking)
1060 ide.projectView.modifiedDocument = true;
1061 ide.workspace.modified = true;
1065 void RotateActiveConfig(bool forward)
1067 if(configurations.first && configurations.last != configurations.first)
1069 Iterator<ProjectConfig> cfg { configurations };
1070 while(forward ? cfg.Next() : cfg.Prev())
1071 if(cfg.data == config)
1085 property::config = cfg.data;
1086 ide.workspace.modified = true;
1087 ide.projectView.Update(null);
1091 void ProcessPipeOutputRaw(DualPipe f)
1094 while(!f.Eof() && !ide.ShouldStopBuild())
1097 double lastTime = GetTime();
1101 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1103 ide.outputView.buildBox.Logf("%s\n", line);
1105 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1107 //printf("Processing Input...\n");
1108 if(app.ProcessInput(true))
1110 app.UpdateDisplay();
1113 //printf("Waiting...\n");
1116 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1118 if(ide.ShouldStopBuild())
1120 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1125 bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, bool isARun, ProjectNode onlyNode,
1126 CompilerConfig compiler, ProjectConfig config)
1129 bool compiling = false, linking = false, precompiling = false;
1130 int compilingEC = 0;
1131 int numErrors = 0, numWarnings = 0;
1132 bool loggedALine = false;
1133 char * configName = config.name;
1134 int lenMakeCommand = strlen(compiler.makeCommand);
1136 char cppCommand[MAX_LOCATION];
1137 char ccCommand[MAX_LOCATION];
1138 char ecpCommand[MAX_LOCATION];
1139 char eccCommand[MAX_LOCATION];
1140 char ecsCommand[MAX_LOCATION];
1141 char earCommand[MAX_LOCATION];
1143 char * cc = compiler.ccCommand;
1144 char * cpp = compiler.cppCommand;
1145 sprintf(cppCommand, "%s%s%s%s ",
1146 compiler.ccacheEnabled ? "ccache " : "",
1147 compiler.ccacheEnabled && !compiler.distccEnabled ? " " : "",
1148 compiler.distccEnabled ? "distcc " : "",
1149 compiler.cppCommand);
1150 sprintf(ccCommand, "%s%s%s%s ",
1151 compiler.ccacheEnabled ? "ccache " : "",
1152 compiler.ccacheEnabled && !compiler.distccEnabled ? " " : "",
1153 compiler.distccEnabled ? "distcc " : "",
1154 compiler.ccCommand);
1155 sprintf(ecpCommand, "%s ", compiler.ecpCommand);
1156 sprintf(eccCommand, "%s ", compiler.eccCommand);
1157 sprintf(ecsCommand, "%s ", compiler.ecsCommand);
1158 sprintf(earCommand, "%s ", compiler.earCommand);
1160 while(!f.Eof() && !ide.ShouldStopBuild())
1163 double lastTime = GetTime();
1167 //printf("Peeking and GetLine...\n");
1168 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1170 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1171 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
1173 char * module = strstr(line, "No rule to make target `");
1177 module = strchr(module, '`') + 1;
1178 end = strchr(module, '\'');
1182 ide.outputView.buildBox.Logf($" %s: No such file or directory\n", module);
1183 // ide.outputView.buildBox.Logf("error: %s\n No such file or directory\n", module);
1189 //ide.outputView.buildBox.Logf("error: %s\n", line);
1193 else if(strstr(line, "ear ") == line);
1194 else if(strstr(line, "strip ") == line);
1195 else if(strstr(line, ccCommand) == line || strstr(line, ecpCommand) == line || strstr(line, eccCommand) == line)
1197 char moduleName[MAX_FILENAME];
1200 bool isPrecomp = false;
1202 if(strstr(line, ccCommand) == line)
1204 module = strstr(line, " -c ");
1205 if(module) module += 4;
1207 else if(strstr(line, eccCommand) == line)
1209 module = strstr(line, " -c ");
1210 if(module) module += 4;
1211 //module = line + 3;
1212 // Don't show GCC warnings about generated C code because it does not compile clean yet...
1213 compilingEC = 3;//2;
1215 else if(strstr(line, ecpCommand) == line)
1217 // module = line + 8;
1218 module = strstr(line, " -c ");
1219 if(module) module += 4;
1228 if(!compiling && !isPrecomp)
1230 ide.outputView.buildBox.Logf($"Compiling...\n");
1233 else if(!precompiling && isPrecomp)
1235 ide.outputView.buildBox.Logf($"Generating symbols...\n");
1236 precompiling = true;
1238 // Changed escapeBackSlashes here to handle paths with spaces
1239 Tokenize(module, 1, tokens, true); // false);
1240 GetLastDirectory(module, moduleName);
1241 ide.outputView.buildBox.Logf("%s\n", moduleName);
1243 else if((module = strstr(line, " -o ")))
1246 precompiling = false;
1248 ide.outputView.buildBox.Logf($"Linking...\n");
1252 ide.outputView.buildBox.Logf("%s\n", line);
1256 if(compilingEC) compilingEC--;
1258 else if(strstr(line, "ar rcs") == line)
1259 ide.outputView.buildBox.Logf($"Building library...\n");
1260 else if(strstr(line, ecsCommand) == line)
1261 ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
1264 if(linking || compiling || precompiling)
1266 char * colon = strstr(line, ":"); //, * bracket;
1267 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1268 colon = strstr(colon + 1, ":");
1271 char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
1274 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1275 int len = (int)(colon - start);
1276 len = Min(len, MAX_LOCATION-1);
1277 // Don't be mistaken by the drive letter colon
1279 // TODO: need to fix colon - line gives char *
1280 // warning: incompatible expression colon - line (char *); expected int
1282 strncpy(moduleName, line, (int)(colon - line));
1283 moduleName[colon - line] = '\0';
1285 strncpy(moduleName, start, len);
1286 moduleName[len] = '\0';
1287 // Remove stuff in brackets
1288 //bracket = strstr(moduleName, "(");
1289 //if(bracket) *bracket = '\0';
1291 GetLastDirectory(moduleName, temp);
1292 if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
1295 strcpy(moduleName, $"Linker Error");
1299 strcpy(temp, topNode.path);
1300 PathCatSlash(temp, moduleName);
1301 MakePathRelative(temp, topNode.path, moduleName);
1303 if(strstr(line, "error:"))
1307 // Silence warnings for compiled EC
1308 char * objDir = strstr(moduleName, objDirExp.dir);
1312 if((pointer = strstr(line, "undefined")) ||
1313 (pointer = strstr(line, "No such file")) ||
1314 (pointer = strstr(line, "token")))
1316 strncat(moduleName, colon, pointer - colon);
1317 strcat(moduleName, "error: ");
1322 else if((pointer = strstr(line, "No such file")))
1324 strncat(moduleName, colon, pointer - colon);
1325 strcat(moduleName, "error: ");
1329 else if(compilingEC == 1 || (objDir && objDir == moduleName))
1331 else if(strstr(line, "warning:"))
1336 if(this == ide.workspace.projects.firstIterator.data)
1337 ide.outputView.buildBox.Logf(" %s%s\n", moduleName, colon);
1340 char fullModuleName[MAX_LOCATION];
1341 strcpy(fullModuleName, topNode.path);
1342 PathCat(fullModuleName, moduleName);
1343 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
1344 MakeSystemPath(fullModuleName);
1345 ide.outputView.buildBox.Logf(" %s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : "", fullModuleName, colon);
1350 ide.outputView.buildBox.Logf("%s\n", line);
1351 linking = compiling = precompiling = false;
1355 ide.outputView.buildBox.Logf("%s\n", line);
1359 //printf("Done getting line\n");
1360 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1362 //printf("Processing Input...\n");
1363 if(app.ProcessInput(true))
1365 app.UpdateDisplay();
1368 //printf("Waiting...\n");
1371 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1373 if(ide.ShouldStopBuild())
1375 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1378 else if(loggedALine || !isARun)
1380 if(f.GetExitCode() && !numErrors)
1382 bool result = f.GetLine(line, sizeof(line)-1);
1383 ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
1388 ide.outputView.buildBox.Logf("\n%s (%s) - ", GetTargetFileName(config), configName);
1390 ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
1392 ide.outputView.buildBox.Logf($"no error, ");
1395 ide.outputView.buildBox.Logf("%d %s\n", numWarnings, (numWarnings > 1) ? $"warnings" : $"warning");
1397 ide.outputView.buildBox.Logf($"no warning\n");
1400 return numErrors == 0;
1403 void ProcessCleanPipeOutput(DualPipe f, CompilerConfig compiler, ProjectConfig config)
1406 int lenMakeCommand = strlen(compiler.makeCommand);
1411 double lastTime = GetTime();
1414 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1416 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':');
1417 else if(strstr(line, "del") == line);
1418 else if(strstr(line, "rm") == line);
1419 else if(strstr(line, "Could Not Find") == line);
1422 ide.outputView.buildBox.Logf(line);
1423 ide.outputView.buildBox.Logf("\n");
1427 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1429 if(app.ProcessInput(true))
1431 app.UpdateDisplay();
1434 //Sleep(1.0 / PEEK_RESOLUTION);
1438 bool Build(bool isARun, ProjectNode onlyNode, CompilerConfig compiler, ProjectConfig config)
1440 bool result = false;
1442 char targetFileName[MAX_LOCATION] = "";
1443 char makeTarget[MAX_LOCATION] = "";
1444 char makeFile[MAX_LOCATION];
1445 char makeFilePath[MAX_LOCATION];
1446 char configName[MAX_LOCATION];
1447 DirExpression objDirExp = GetObjDir(compiler, config);
1448 PathBackup pathBackup { };
1450 int numJobs = compiler.numJobs;
1451 char command[MAX_LOCATION];
1453 strcpy(configName, config ? config.name : "Common");
1455 SetPath(false, compiler, config); //true
1456 CatTargetFileName(targetFileName, compiler, config);
1458 strcpy(makeFilePath, topNode.path);
1459 CatMakeFileName(makeFile, compiler, config);
1460 PathCatSlash(makeFilePath, makeFile);
1462 // TODO: TEST ON UNIX IF \" around makeTarget is ok
1465 if(compiler.type.isVC)
1467 PrintLn("compiling a single file is not yet supported");
1472 char pushD[MAX_LOCATION];
1473 GetWorkingDir(pushD, sizeof(pushD));
1474 ChangeWorkingDir(topNode.path);
1475 // Create object dir if it does not exist already
1476 if(!FileExists(objDirExp.dir).isDirectory)
1477 Execute("%s objdir -C \"%s\" -f \"%s\"", compiler.makeCommand, topNode.path, makeFilePath);
1478 ChangeWorkingDir(pushD);
1480 PathCatSlash(makeTarget+1, objDirExp.dir);
1481 PathCatSlash(makeTarget+1, onlyNode.name);
1482 StripExtension(makeTarget+1);
1483 strcat(makeTarget+1, ".o");
1484 makeTarget[0] = '\"';
1485 len = strlen(makeTarget);
1486 makeTarget[len++] = '\"';
1487 makeTarget[len++] = '\0';
1491 if(compiler.type.isVC)
1493 bool result = false;
1494 char oldwd[MAX_LOCATION];
1495 GetWorkingDir(oldwd, sizeof(oldwd));
1496 ChangeWorkingDir(topNode.path);
1498 sprintf(command, "%s /useenv /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
1499 ide.outputView.buildBox.Logf("command: %s\n", command);
1500 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
1502 ProcessPipeOutputRaw(f);
1506 ChangeWorkingDir(oldwd);
1510 sprintf(command, "%s -j%d %s%s%s -C \"%s\" -f \"%s\"", compiler.makeCommand, numJobs,
1511 compiler.ccacheEnabled ? "CCACHE=y " : "",
1512 compiler.distccEnabled ? "DISTCC=y " : "",
1513 makeTarget, topNode.path, makeFilePath);
1514 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
1516 result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNode, compiler, config);
1520 ide.outputView.buildBox.Logf($"Error executing make (%s) command\n", compiler.makeCommand);
1529 void Clean(CompilerConfig compiler, ProjectConfig config, bool realclean)
1531 char makeFile[MAX_LOCATION];
1532 char makeFilePath[MAX_LOCATION];
1533 char command[MAX_LOCATION];
1535 PathBackup pathBackup { };
1537 SetPath(false, compiler, config);
1539 strcpy(makeFilePath, topNode.path);
1540 CatMakeFileName(makeFile, compiler, config);
1541 PathCatSlash(makeFilePath, makeFile);
1543 if(compiler.type.isVC)
1545 bool result = false;
1546 char oldwd[MAX_LOCATION];
1547 GetWorkingDir(oldwd, sizeof(oldwd));
1548 ChangeWorkingDir(topNode.path);
1550 sprintf(command, "%s /useenv /clean /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
1551 ide.outputView.buildBox.Logf("command: %s\n", command);
1552 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
1554 ProcessPipeOutputRaw(f);
1558 ChangeWorkingDir(oldwd);
1563 sprintf(command, "%s %sclean -C \"%s\" -f \"%s\"", compiler.makeCommand, realclean ? "real" : "", topNode.path, makeFilePath);
1564 if((f = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
1566 ide.outputView.buildBox.Tell($"Deleting target and object files...");
1567 ProcessCleanPipeOutput(f, compiler, config);
1570 ide.outputView.buildBox.Logf($"Target and object files deleted\n");
1577 void Run(char * args, CompilerConfig compiler, ProjectConfig config)
1579 String target = new char[maxPathLen];
1580 char oldDirectory[MAX_LOCATION];
1581 DirExpression targetDirExp = GetTargetDir(compiler, config);
1582 PathBackup pathBackup { };
1584 // Build(project, ideMain, true, null);
1586 #if defined(__WIN32__)
1587 strcpy(target, topNode.path);
1591 PathCatSlash(target, targetDirExp.dir);
1592 CatTargetFileName(target, compiler, config);
1593 sprintf(target, "%s %s", target, args);
1594 GetWorkingDir(oldDirectory, MAX_LOCATION);
1596 if(strlen(ide.workspace.debugDir))
1598 char temp[MAX_LOCATION];
1599 strcpy(temp, topNode.path);
1600 PathCatSlash(temp, ide.workspace.debugDir);
1601 ChangeWorkingDir(temp);
1604 ChangeWorkingDir(topNode.path);
1605 // ChangeWorkingDir(topNode.path);
1606 SetPath(true, compiler, config);
1607 if(compiler.execPrefixCommand)
1609 char * prefixedTarget = new char[strlen(compiler.execPrefixCommand) + strlen(target) + 2];
1610 prefixedTarget[0] = '\0';
1611 strcat(prefixedTarget, compiler.execPrefixCommand);
1612 strcat(prefixedTarget, " ");
1613 strcat(prefixedTarget, target);
1614 Execute(prefixedTarget);
1615 delete prefixedTarget;
1620 ChangeWorkingDir(oldDirectory);
1623 delete targetDirExp;
1627 void Compile(ProjectNode node, CompilerConfig compiler, ProjectConfig config)
1629 Build(false, node, compiler, config);
1633 void GetMakefileTargetFileName(TargetTypes targetType, char * fileName, ProjectConfig config)
1636 if(targetType == staticLibrary || targetType == sharedLibrary)
1637 strcat(fileName, "$(LP)");
1638 // !!! ReplaceSpaces must be done after all PathCat calls !!!
1639 // ReplaceSpaces(s, GetTargetFileName(config));
1640 strcat(fileName, GetTargetFileName(config));
1644 strcat(fileName, "$(E)");
1647 strcat(fileName, "$(SO)");
1650 strcat(fileName, "$(A)");
1655 bool GenerateMakefile(char * altMakefilePath, bool noResources, char * includemkPath,
1656 CompilerConfig compiler, ProjectConfig config)
1658 bool result = false;
1659 char filePath[MAX_LOCATION];
1660 char makeFile[MAX_LOCATION];
1661 // PathBackup pathBackup { };
1662 // char oldDirectory[MAX_LOCATION];
1665 if(!altMakefilePath)
1667 strcpy(filePath, topNode.path);
1668 CatMakeFileName(makeFile, compiler, config);
1669 PathCatSlash(filePath, makeFile);
1672 #if defined(__WIN32__) && !defined(MAKEFILE_GENERATOR)
1673 if(compiler.type.isVC)
1675 GenerateVSSolutionFile(this, compiler);
1676 GenerateVCProjectFile(this, compiler);
1680 f = FileOpen(altMakefilePath ? altMakefilePath : filePath, write);
1682 /*SetPath(false, compiler, config);
1683 GetWorkingDir(oldDirectory, MAX_LOCATION);
1684 ChangeWorkingDir(topNode.path);*/
1691 char targetDir[MAX_LOCATION];
1692 char objDirExpNoSpaces[MAX_LOCATION];
1693 char objDirNoSpaces[MAX_LOCATION];
1694 char resDirNoSpaces[MAX_LOCATION];
1695 char targetDirExpNoSpaces[MAX_LOCATION];
1696 char fixedModuleName[MAX_FILENAME];
1697 char fixedConfigName[MAX_FILENAME];
1698 char fixedCompilerName[MAX_FILENAME];
1700 int numCObjects = 0;
1701 bool sameObjTargetDirs;
1702 DirExpression objDirExp = GetObjDir(compiler, config);
1703 TargetTypes targetType = GetTargetType(config);
1705 bool crossCompiling = compiler.targetPlatform != GetRuntimePlatform();
1706 bool gccCompiler = compiler.ccCommand && strstr(compiler.ccCommand, "gcc") != null;
1707 bool tccCompiler = compiler.ccCommand && strstr(compiler.ccCommand, "tcc") != null;
1708 bool defaultPreprocessor = compiler.cppCommand && (strstr(compiler.cppCommand, "gcc") != null || compiler.cppCommand && strstr(compiler.cppCommand, "cpp") != null);
1710 int objectsParts, cobjectsParts, symbolsParts, importsParts;
1711 Array<String> listItems { };
1712 Map<String, int> varStringLenDiffs { };
1713 Map<String, NameCollisionInfo> namesInfo { };
1715 ReplaceSpaces(objDirNoSpaces, objDirExp.dir);
1716 strcpy(targetDir, GetTargetDirExpression(compiler, config));
1717 ReplaceSpaces(targetDirExpNoSpaces, targetDir);
1719 strcpy(objDirExpNoSpaces, GetObjDirExpression(compiler, config));
1720 ChangeCh(objDirExpNoSpaces, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
1721 ReplaceSpaces(objDirExpNoSpaces, objDirExpNoSpaces);
1722 ReplaceSpaces(resDirNoSpaces, resNode.path ? resNode.path : "");
1723 //ReplaceSpaces(fixedPrjName, name);
1724 ReplaceSpaces(fixedModuleName, moduleName);
1725 ReplaceSpaces(fixedConfigName, GetConfigName(config));
1726 ReplaceSpaces(fixedCompilerName, compiler.name);
1727 //CamelCase(fixedModuleName); // case is important for static linking
1728 CamelCase(fixedConfigName);
1729 CamelCase(fixedCompilerName);
1731 sameObjTargetDirs = !fstrcmp(objDirExpNoSpaces, targetDirExpNoSpaces);
1733 f.Printf(".PHONY: all objdir%s clean realclean\n\n", sameObjTargetDirs ? "" : " targetdir");
1735 f.Printf("# CONTENT\n\n");
1737 f.Printf("MODULE := %s\n", fixedModuleName);
1738 //f.Printf("VERSION = %s\n", version);
1739 f.Printf("CONFIG := %s\n", fixedConfigName);
1740 f.Printf("COMPILER := %s\n", fixedCompilerName);
1742 f.Printf("PLATFORM = %s\n", (char *)compiler.targetPlatform);
1743 test = GetTargetTypeIsSetByPlatform(config);
1747 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
1749 TargetTypes targetType;
1750 PlatformOptions projectPOs, configPOs;
1751 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
1752 targetType = platformTargetType;
1758 f.Printf("ifdef %s\n", PlatformToMakefileVariable(platform));
1760 f.Printf("TARGET_TYPE = ");
1761 f.Printf(TargetTypeToMakefileVariable(targetType));
1765 f.Printf("else\n"); // ifCount should always be > 0
1767 f.Printf("TARGET_TYPE = ");
1768 f.Printf(TargetTypeToMakefileVariable(targetType));
1774 for(c = 0; c < ifCount; c++)
1775 f.Printf("endif\n");
1780 f.Printf("OBJ = %s%s\n\n", objDirExpNoSpaces, objDirExpNoSpaces[0] ? "/" : "");
1782 f.Printf("RES = %s%s\n\n", resDirNoSpaces, resDirNoSpaces[0] ? "/" : "");
1784 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(executable));
1785 f.Printf("CONSOLE = %s\n", GetConsole(config) ? "-mconsole" : "-mwindows");
1786 f.Printf("endif\n\n");
1788 // test = GetTargetTypeIsSetByPlatform(config);
1790 char target[MAX_LOCATION];
1791 char targetNoSpaces[MAX_LOCATION];
1796 for(type = (TargetTypes)1; type < TargetTypes::enumSize; type++)
1798 if(type != targetType)
1803 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(type));
1805 GetMakefileTargetFileName(type, target, config);
1806 strcpy(targetNoSpaces, targetDir);
1807 PathCatSlash(targetNoSpaces, target);
1808 ReplaceSpaces(targetNoSpaces, targetNoSpaces);
1809 f.Printf("TARGET = %s\n", targetNoSpaces);
1812 f.Printf("else\n"); // ifCount should always be > 0
1814 GetMakefileTargetFileName(targetType, target, config);
1815 strcpy(targetNoSpaces, targetDir);
1816 PathCatSlash(targetNoSpaces, target);
1817 ReplaceSpaces(targetNoSpaces, targetNoSpaces);
1818 f.Printf("TARGET = %s\n", targetNoSpaces);
1823 for(c = 0; c < ifCount; c++)
1824 f.Printf("endif\n");
1830 varStringLenDiffs["$(OBJ)"] = strlen(objDirNoSpaces) - 6;
1832 topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1834 numCObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config);
1836 listItems.Add(CopyString("$(OBJ)$(MODULE).main$(O)"));
1837 objectsParts = OutputFileList(f, "OBJECTS", listItems, varStringLenDiffs);
1839 topNode.GenMakefilePrintNode(f, this, cObjects, namesInfo, listItems, config);
1840 cobjectsParts = OutputFileList(f, "COBJECTS", listItems, varStringLenDiffs);
1842 topNode.GenMakefilePrintNode(f, this, symbols, null, listItems, config);
1843 symbolsParts = OutputFileList(f, "SYMBOLS", listItems, varStringLenDiffs);
1845 topNode.GenMakefilePrintNode(f, this, imports, null, listItems, config);
1846 importsParts = OutputFileList(f, "IMPORTS", listItems, varStringLenDiffs);
1848 topNode.GenMakefilePrintNode(f, this, sources, null, listItems, config);
1849 OutputFileList(f, "SOURCES", listItems, varStringLenDiffs);
1852 resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config);
1853 OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs);
1857 f.Printf("# CROSS-PLATFORM MAGIC\n\n");
1859 f.Printf("include %s\n\n", includemkPath);
1863 File include = FileOpen(":include.mk", read);
1866 for(; !include.Eof(); )
1869 int count = include.Read(buffer, 1, 4096);
1870 f.Write(buffer, 1, count);
1878 if(strcmpi(compiler.cppCommand, "cpp") ||
1879 strcmpi(compiler.ccCommand, "gcc") ||
1880 strcmpi(compiler.ecpCommand, "ecp") ||
1881 strcmpi(compiler.eccCommand, "ecc") ||
1882 strcmpi(compiler.ecsCommand, "ecs") || crossCompiling ||
1883 strcmpi(compiler.earCommand, "ear"))
1885 f.Printf("# TOOLCHAIN\n\n");
1887 //f.Printf("SHELL := %s\n", "ar"/*compiler.arCommand*/); // is this really needed?
1888 if(strcmpi(compiler.cppCommand, "cpp"))
1889 f.Printf("CPP := $(CCACHE_COMPILE) $(DISTCC_COMPILE) %s\n", compiler.cppCommand);
1890 if(strcmpi(compiler.ccCommand, "gcc"))
1891 f.Printf("CC := $(CCACHE_COMPILE) $(DISTCC_COMPILE) %s\n", compiler.ccCommand);
1892 if(strcmpi(compiler.ecpCommand, "ecp"))
1893 f.Printf("ECP := %s\n", compiler.ecpCommand);
1894 if(strcmpi(compiler.eccCommand, "ecc"))
1895 f.Printf("ECC := %s\n", compiler.eccCommand);
1896 if(strcmpi(compiler.ecsCommand, "ecs") || crossCompiling)
1898 f.Printf("ECS := %s%s%s\n", compiler.ecsCommand,
1899 crossCompiling ? " -t " : "", crossCompiling ? (char*)compiler.targetPlatform : "");
1901 if(strcmpi(compiler.earCommand, "ear"))
1902 f.Printf("EAR := %s\n", compiler.earCommand);
1906 f.Printf("# FLAGS\n\n");
1908 f.Printf("CFLAGS =");
1911 f.Printf(" -fmessage-length=0");
1912 switch(GetOptimization(config))
1916 f.Printf(" -ffast-math");
1922 //if(compiler.targetPlatform.is32Bits)
1924 //else if(compiler.targetPlatform.is64Bits)
1925 // f.Printf(" -m64");
1926 f.Printf(" $(FPIC)");
1927 //f.Printf(" -fpack-struct");
1929 switch(GetWarnings(config))
1931 case all: f.Printf(" -Wall"); break;
1932 case none: f.Printf(" -w"); break;
1934 if(GetDebug(config))
1936 if(GetProfile(config))
1938 if(options && options.linkerOptions && options.linkerOptions.count)
1940 f.Printf(" \\\n\t -Wl");
1941 for(s : options.linkerOptions)
1945 if(options && options.preprocessorDefinitions)
1946 OutputListOption(f, "D", options.preprocessorDefinitions, newLine, false);
1947 if(config && config.options && config.options.preprocessorDefinitions)
1948 OutputListOption(f, "D", config.options.preprocessorDefinitions, newLine, false);
1949 if(compiler.includeDirs)
1950 OutputListOption(f, gccCompiler ? "isystem " : "I", compiler.includeDirs, lineEach, true);
1951 if(options && options.includeDirs)
1952 OutputListOption(f, "I", options.includeDirs, lineEach, true);
1953 if(config && config.options && config.options.includeDirs)
1954 OutputListOption(f, "I", config.options.includeDirs, lineEach, true);
1957 f.Printf("CECFLAGS =%s%s%s%s", defaultPreprocessor ? "" : " -cpp ", defaultPreprocessor ? "" : compiler.cppCommand,
1958 crossCompiling ? " -t " : "", crossCompiling ? (char*)compiler.targetPlatform : "");
1961 f.Printf("ECFLAGS =");
1962 if(GetMemoryGuard(config))
1963 f.Printf(" -memguard");
1964 if(GetStrictNameSpaces(config))
1965 f.Printf(" -strictns");
1966 if(GetNoLineNumbers(config))
1967 f.Printf(" -nolinenumbers");
1970 if((s = GetDefaultNameSpace(config)) && s[0])
1971 f.Printf(" -defaultns %s", s);
1975 f.Printf("OFLAGS =\n");
1976 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
1977 f.Printf("OFLAGS += -m32");
1978 if(GetProfile(config))
1981 if(compiler.libraryDirs)
1982 OutputListOption(f, "L", compiler.libraryDirs, lineEach, true);
1983 if(options && options.libraryDirs)
1984 OutputListOption(f, "L", options.libraryDirs, lineEach, true);
1985 if(config && config.options && config.options.libraryDirs)
1986 OutputListOption(f, "L", config.options.libraryDirs, lineEach, true);
1988 f.Printf("endif\n\n");
1990 if((config && config.options && config.options.libraries) ||
1991 (options && options.libraries))
1993 f.Printf("LIBS =\n");
1994 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
1995 f.Printf("LIBS +=");
1996 if(config && config.options && config.options.libraries)
1997 OutputLibraries(f, config.options.libraries);
1998 else if(options && options.libraries)
1999 OutputLibraries(f, options.libraries);
2001 f.Printf("endif\n");
2002 f.Printf("LIBS +=");
2007 f.Printf(" $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n\n");
2009 f.Printf("UPXFLAGS = -9\n\n"); // TOFEAT: Compression Level Option? Other UPX Options?
2011 f.Printf("# HARD CODED PLATFORM-SPECIFIC OPTIONS\n");
2012 f.Printf("ifdef %s\n", PlatformToMakefileVariable(tux));
2013 f.Printf("OFLAGS += -Wl,--no-undefined\n");
2014 f.Printf("endif\n\n");
2017 f.Printf("ifdef %s\n", PlatformToMakefileVariable(apple));
2018 f.Printf("OFLAGS += -framework cocoa -framework OpenGL\n");
2019 f.Printf("endif\n\n");
2021 if(platforms || (config && config.platforms))
2024 //for(platform = firstPlatform; platform <= lastPlatform; platform++)
2025 //for(platform = win32; platform <= apple; platform++)
2027 f.Printf("# PLATFORM-SPECIFIC OPTIONS\n\n");
2028 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2030 PlatformOptions projectPlatformOptions, configPlatformOptions;
2031 MatchProjectAndConfigPlatformOptions(config, platform, &projectPlatformOptions, &configPlatformOptions);
2033 if(projectPlatformOptions || configPlatformOptions)
2039 f.Printf(PlatformToMakefileVariable(platform));
2042 if((projectPlatformOptions && projectPlatformOptions.options.preprocessorDefinitions && projectPlatformOptions.options.preprocessorDefinitions.count) ||
2043 (configPlatformOptions && configPlatformOptions.options.preprocessorDefinitions && configPlatformOptions.options.preprocessorDefinitions.count) ||
2044 (projectPlatformOptions && projectPlatformOptions.options.includeDirs && projectPlatformOptions.options.includeDirs.count) ||
2045 (configPlatformOptions && configPlatformOptions.options.includeDirs && configPlatformOptions.options.includeDirs.count))
2047 f.Printf("CFLAGS +=");
2048 if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
2050 f.Printf(" \\\n\t -Wl");
2051 for(s : projectPlatformOptions.options.linkerOptions)
2054 if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
2056 f.Printf(" \\\n\t -Wl");
2057 for(s : configPlatformOptions.options.linkerOptions)
2060 if(projectPlatformOptions && projectPlatformOptions.options.preprocessorDefinitions)
2061 OutputListOption(f, "D", projectPlatformOptions.options.preprocessorDefinitions, newLine, false);
2062 if(configPlatformOptions && configPlatformOptions.options.preprocessorDefinitions)
2063 OutputListOption(f, "D", configPlatformOptions.options.preprocessorDefinitions, newLine, false );
2064 if(projectPlatformOptions && projectPlatformOptions.options.includeDirs)
2065 OutputListOption(f, "I", projectPlatformOptions.options.includeDirs, lineEach, true);
2066 if(configPlatformOptions && configPlatformOptions.options.includeDirs)
2067 OutputListOption(f, "I", configPlatformOptions.options.includeDirs, lineEach, true);
2071 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
2072 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count) ||
2073 (projectPlatformOptions && projectPlatformOptions.options.libraries && projectPlatformOptions.options.libraries.count) ||
2074 (configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
2076 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2077 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
2078 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count))
2080 f.Printf("OFLAGS +=");
2081 if(projectPlatformOptions && projectPlatformOptions.options.libraryDirs)
2082 OutputListOption(f, "L", projectPlatformOptions.options.libraryDirs, lineEach, true);
2083 if(configPlatformOptions && configPlatformOptions.options.libraryDirs)
2084 OutputListOption(f, "L", configPlatformOptions.options.libraryDirs, lineEach, true);
2088 if(projectPlatformOptions && projectPlatformOptions.options.libraries &&
2089 projectPlatformOptions.options.libraries.count/* &&
2090 (!config || !config.options || !config.options.libraries)*/)
2092 f.Printf("LIBS +=");
2093 OutputLibraries(f, projectPlatformOptions.options.libraries);
2096 {/*TOFIX: EXTRA CURLIES FOR NASTY WARNING*/if((configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
2098 f.Printf("LIBS +=");
2099 OutputLibraries(f, configPlatformOptions.options.libraries);
2102 f.Printf("endif\n\n");
2108 for(c = 0; c < ifCount; c++)
2109 f.Printf("endif\n");
2114 f.Printf("# TARGETS\n\n");
2116 f.Printf("all: objdir%s $(TARGET)\n\n", sameObjTargetDirs ? "" : " targetdir");
2118 f.Printf("objdir:\n");
2119 f.Printf("\t$(if $(wildcard $(OBJ)),,$(call mkdirq,$(OBJ)))\n");
2120 //f.Printf("# PRE-BUILD COMMANDS\n");
2121 if(options && options.prebuildCommands)
2123 for(s : options.prebuildCommands)
2124 if(s && s[0]) f.Printf("\t%s\n", s);
2126 if(config && config.options && config.options.prebuildCommands)
2128 for(s : config.options.prebuildCommands)
2129 if(s && s[0]) f.Printf("\t%s\n", s);
2131 if(platforms || (config && config.platforms))
2134 //f.Printf("# PLATFORM-SPECIFIC PRE-BUILD COMMANDS\n");
2135 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2137 PlatformOptions projectPOs, configPOs;
2138 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2140 if((projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count) ||
2141 (configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count))
2147 f.Printf(PlatformToMakefileVariable(platform));
2150 if(projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count)
2152 for(s : projectPOs.options.prebuildCommands)
2153 if(s && s[0]) f.Printf("\t%s\n", s);
2155 if(configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count)
2157 for(s : configPOs.options.prebuildCommands)
2158 if(s && s[0]) f.Printf("\t%s\n", s);
2165 for(c = 0; c < ifCount; c++)
2166 f.Printf("endif\n");
2171 if(!sameObjTargetDirs)
2173 f.Printf("targetdir:\n");
2174 f.Printf("\t$(if $(wildcard %s),,$(call mkdirq,%s))\n\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
2179 // Main Module (Linking) for ECERE C modules
2180 f.Printf("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
2181 // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
2182 f.Printf("\t$(ECS)%s $(ECSLIBOPT) $(SYMBOLS) $(IMPORTS) -symbols %s -o $(OBJ)$(MODULE).main.ec\n\n",
2183 GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
2184 // Main Module (Linking) for ECERE C modules
2185 f.Printf("$(OBJ)$(MODULE).main.c: $(OBJ)$(MODULE).main.ec\n");
2186 f.Printf("\t$(ECP) $(CECFLAGS) $(ECFLAGS) $(CFLAGS)"
2187 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
2188 f.Printf("\t$(ECC) $(CECFLAGS) $(ECFLAGS) $(CFLAGS) $(FVISIBILITY)"
2189 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.c -symbols $(OBJ)\n\n");
2194 // This would not rebuild the target on updated objects
2195 // f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) | objdir $(SYMBOLS) $(OBJECTS)%s\n", sameObjTargetDirs ? "" : " targetdir");
2197 // This should fix it for good!
2198 f.Printf("$(SYMBOLS): | objdir\n");
2199 f.Printf("$(OBJECTS): | objdir\n");
2201 // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
2202 f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
2204 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2205 f.Printf("\t$(CC) $(OFLAGS) $(OBJECTS) $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
2206 if(!GetDebug(config))
2208 f.Printf("ifndef NOSTRIP\n");
2209 f.Printf("\t$(STRIP) $(STRIPOPT) $(TARGET)\n");
2210 f.Printf("endif\n");
2212 if(GetCompress(config))
2214 f.Printf("ifndef WINDOWS\n");
2215 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(executable));
2216 f.Printf("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
2217 f.Printf("endif\n");
2219 f.Printf("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
2220 f.Printf("endif\n");
2223 if(resNode.files && resNode.files.count && !noResources)
2224 resNode.GenMakefileAddResources(f, resNode.path, config);
2226 f.Printf("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
2227 f.Printf("endif\n");
2229 //f.Printf("# POST-BUILD COMMANDS\n");
2230 if(options && options.postbuildCommands)
2232 for(s : options.postbuildCommands)
2233 if(s && s[0]) f.Printf("\t%s\n", s);
2235 if(config && config.options && config.options.postbuildCommands)
2237 for(s : config.options.postbuildCommands)
2238 if(s && s[0]) f.Printf("\t%s\n", s);
2240 if(platforms || (config && config.platforms))
2243 //f.Printf("# PLATFORM-SPECIFIC POST-BUILD COMMANDS\n");
2244 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2246 PlatformOptions projectPOs, configPOs;
2247 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2249 if((projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count) ||
2250 (configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count))
2256 f.Printf(PlatformToMakefileVariable(platform));
2259 if(projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count)
2261 for(s : projectPOs.options.postbuildCommands)
2262 if(s && s[0]) f.Printf("\t%s\n", s);
2264 if(configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count)
2266 for(s : configPOs.options.postbuildCommands)
2267 if(s && s[0]) f.Printf("\t%s\n", s);
2274 for(c = 0; c < ifCount; c++)
2275 f.Printf("endif\n");
2280 f.Printf("# SYMBOL RULES\n\n");
2281 topNode.GenMakefilePrintSymbolRules(f, this, compiler, config);
2283 f.Printf("# C OBJECT RULES\n\n");
2284 topNode.GenMakefilePrintCObjectRules(f, this, compiler, config);
2288 f.Printf("# IMPLICIT OBJECT RULE\n\n");
2290 f.Printf("$(OBJ)%%$(O) : $(OBJ)%%.c\n");
2291 f.Printf("\t$(CC) $(CFLAGS) $(FVISIBILITY) -c $< -o $@\n\n");
2294 f.Printf("# OBJECT RULES\n\n");
2295 // todo call this still but only generate rules whith specific options
2296 // see we-have-file-specific-options in ProjectNode.ec
2297 topNode.GenMakefilePrintObjectRules(f, this, namesInfo, compiler, config);
2300 GenMakefilePrintMainObjectRule(f, compiler, config);
2302 f.Printf("clean: objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
2303 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) " : "");
2304 OutputCleanActions(f, "OBJECTS", objectsParts);
2305 OutputCleanActions(f, "COBJECTS", cobjectsParts);
2308 OutputCleanActions(f, "IMPORTS", importsParts);
2309 OutputCleanActions(f, "SYMBOLS", symbolsParts);
2313 f.Printf("realclean: clean\n");
2314 f.Printf("\t$(call rmrq,$(OBJ))\n");
2315 if(!sameObjTargetDirs)
2316 f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
2322 varStringLenDiffs.Free();
2323 delete varStringLenDiffs;
2330 // ChangeWorkingDir(oldDirectory);
2331 // delete pathBackup;
2334 config.makingModified = false;
2338 void GenMakefilePrintMainObjectRule(File f, CompilerConfig compiler, ProjectConfig config)
2340 char extension[MAX_EXTENSION] = "c";
2341 char modulePath[MAX_LOCATION];
2342 char fixedModuleName[MAX_FILENAME];
2345 char objDirNoSpaces[MAX_LOCATION];
2346 DirExpression objDirExp = GetObjDir(compiler, config);
2348 ReplaceSpaces(objDirNoSpaces, objDirExp.dir);
2349 ReplaceSpaces(fixedModuleName, moduleName);
2351 //sprintf(fixedModuleName, "%s.main", fixedPrjName);
2352 //strcat(fixedModuleName, ".main");
2354 #if 0 // TODO: Fix nospaces stuff
2355 // *** Dependency command ***
2356 sprintf(command, "gcc -MT $(OBJ)%s$(O) -MM $(OBJ)%s.c", fixedModuleName, fixedModuleName);
2358 // System Includes (from global settings)
2359 for(item : compiler.dirs[Includes])
2361 strcat(command, " -isystem ");
2362 if(strchr(item.name, ' '))
2364 strcat(command, "\"");
2365 strcat(command, item);
2366 strcat(command, "\"");
2369 strcat(command, item);
2372 for(item = includeDirs.first; item; item = item.next)
2374 strcat(command, " -I");
2375 if(strchr(item.name, ' '))
2377 strcat(command, "\"");
2378 strcat(command, item.name);
2379 strcat(command, "\"");
2382 strcat(command, item.name);
2384 for(item = preprocessorDefs.first; item; item = item.next)
2386 strcat(command, " -D");
2387 strcat(command, item.name);
2391 if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
2395 bool firstLine = true;
2397 // To do some time: auto save external dependencies?
2400 if(dep.GetLine(line, sizeof(line)-1))
2404 char * colon = strstr(line, ":");
2405 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
2419 // If we failed to generate dependencies...
2423 f.Printf("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
2429 f.Printf("\t$(CC) $(CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(OBJ)$(MODULE).main$(O)\n\n", extension);
2434 void MatchProjectAndConfigPlatformOptions(ProjectConfig config, Platform platform,
2435 PlatformOptions * projectPlatformOptions, PlatformOptions * configPlatformOptions)
2437 *projectPlatformOptions = null;
2438 *configPlatformOptions = null;
2443 if(!strcmpi(p.name, platform))
2445 *projectPlatformOptions = p;
2450 if(config && config.platforms)
2452 for(p : config.platforms)
2454 if(!strcmpi(p.name, platform))
2456 *configPlatformOptions = p;
2464 Project LegacyBinaryLoadProject(File f, char * filePath)
2466 Project project = null;
2467 char signature[sizeof(epjSignature)];
2469 f.Read(signature, sizeof(signature), 1);
2470 if(!strncmp(signature, (char *)epjSignature, sizeof(epjSignature)))
2472 char topNodePath[MAX_LOCATION];
2473 /*ProjectConfig newConfig
2475 name = CopyString("Default");
2476 makingModified = true;
2477 compilingModified = true;
2478 linkingModified = true;
2482 project = Project { options = { } };
2483 LegacyBinaryLoadNode(project.topNode, f);
2484 delete project.topNode.path;
2485 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
2486 MakeSlashPath(topNodePath);
2488 PathCatSlash(topNodePath, filePath);
2489 project.filePath = topNodePath;
2491 /* THIS IS ALREADY DONE BY filePath property
2492 StripLastDirectory(topNodePath, topNodePath);
2493 project.topNode.path = CopyString(topNodePath);
2495 // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
2497 // newConfig.options.defaultNameSpace = "";
2498 /*newConfig.objDir.dir = "obj";
2499 newConfig.targetDir.dir = "";*/
2501 //project.configurations = { [ newConfig ] };
2502 //project.config = newConfig;
2509 String targetFileName, targetDirectory, objectsDirectory;
2511 // { executable = 0, sharedLibrary = 1, staticLibrary = 2 };
2512 f.Read(&temp, sizeof(int),1);
2515 case 0: project.options.targetType = executable; break;
2516 case 1: project.options.targetType = sharedLibrary; break;
2517 case 2: project.options.targetType = staticLibrary; break;
2520 f.Read(&len, sizeof(int),1);
2521 targetFileName = new char[len+1];
2522 f.Read(targetFileName, sizeof(char), len+1);
2523 project.options.targetFileName = targetFileName;
2524 delete targetFileName;
2526 f.Read(&len, sizeof(int),1);
2527 targetDirectory = new char[len+1];
2528 f.Read(targetDirectory, sizeof(char), len+1);
2529 project.options.targetDirectory = targetDirectory;
2530 delete targetDirectory;
2532 f.Read(&len, sizeof(int),1);
2533 objectsDirectory = new byte[len+1];
2534 f.Read(objectsDirectory, sizeof(char), len+1);
2535 project.options.objectsDirectory = objectsDirectory;
2536 delete objectsDirectory;
2538 f.Read(&temp, sizeof(int),1);
2539 project./*config.*/options.debug = temp ? true : false;
2540 f.Read(&temp, sizeof(int),1);
2541 project./*config.*/options.optimization = temp ? speed : none;
2542 f.Read(&temp, sizeof(int),1);
2543 project./*config.*/options.profile = temp ? true : false;
2544 f.Read(&temp, sizeof(int),1);
2545 project.options.warnings = temp ? all : unset;
2547 f.Read(&count, sizeof(int),1);
2550 project.options.includeDirs = { };
2551 for(c = 0; c < count; c++)
2554 f.Read(&len, sizeof(int),1);
2555 name = new char[len+1];
2556 f.Read(name, sizeof(char), len+1);
2557 project.options.includeDirs.Add(name);
2561 f.Read(&count, sizeof(int),1);
2564 project.options.libraryDirs = { };
2565 for(c = 0; c < count; c++)
2568 f.Read(&len, sizeof(int),1);
2569 name = new char[len+1];
2570 f.Read(name, sizeof(char), len+1);
2571 project.options.libraryDirs.Add(name);
2575 f.Read(&count, sizeof(int),1);
2578 project.options.libraries = { };
2579 for(c = 0; c < count; c++)
2582 f.Read(&len, sizeof(int),1);
2583 name = new char[len+1];
2584 f.Read(name, sizeof(char), len+1);
2585 project.options.libraries.Add(name);
2589 f.Read(&count, sizeof(int),1);
2592 project.options.preprocessorDefinitions = { };
2593 for(c = 0; c < count; c++)
2596 f.Read(&len, sizeof(int),1);
2597 name = new char[len+1];
2598 f.Read(name, sizeof(char), len+1);
2599 project.options.preprocessorDefinitions.Add(name);
2603 f.Read(&temp, sizeof(int),1);
2604 project.options.console = temp ? true : false;
2607 for(node : project.topNode.files)
2609 if(node.type == resources)
2611 project.resNode = node;
2621 void ProjectConfig::LegacyProjectConfigLoad(File f)
2629 char subSection[128];
2635 f.GetLine(buffer, 65536 - 1);
2636 TrimLSpaces(buffer, buffer);
2637 TrimRSpaces(buffer, buffer);
2640 if(buffer[0] == '-')
2644 TrimLSpaces(equal, equal);
2645 if(!strcmpi(subSection, "LibraryDirs"))
2647 if(!options.libraryDirs)
2648 options.libraryDirs = { [ CopyString(equal) ] };
2650 options.libraryDirs.Add(CopyString(equal));
2652 else if(!strcmpi(subSection, "IncludeDirs"))
2654 if(!options.includeDirs)
2655 options.includeDirs = { [ CopyString(equal) ] };
2657 options.includeDirs.Add(CopyString(equal));
2660 else if(buffer[0] == '+')
2671 TrimLSpaces(equal, equal);
2672 delete name; name = CopyString(equal); // property::name = equal;
2675 else if(!strcmpi(buffer, "Compiler Options"))
2676 strcpy(section, buffer);
2677 else if(!strcmpi(buffer, "IncludeDirs"))
2678 strcpy(subSection, buffer);
2679 else if(!strcmpi(buffer, "Linker Options"))
2680 strcpy(section, buffer);
2681 else if(!strcmpi(buffer, "LibraryDirs"))
2682 strcpy(subSection, buffer);
2683 else if(!strcmpi(buffer, "Files") || !strcmpi(buffer, "Resources"))
2690 equal = strstr(buffer, "=");
2694 TrimRSpaces(buffer, buffer);
2696 TrimLSpaces(equal, equal);
2697 if(!strcmpi(buffer, "Target Name"))
2698 options.targetFileName = /*CopyString(*/equal/*)*/;
2699 else if(!strcmpi(buffer, "Target Type"))
2701 if(!strcmpi(equal, "Executable"))
2702 options.targetType = executable;
2703 else if(!strcmpi(equal, "Shared"))
2704 options.targetType = sharedLibrary;
2705 else if(!strcmpi(equal, "Static"))
2706 options.targetType = staticLibrary;
2708 options.targetType = executable;
2710 else if(!strcmpi(buffer, "Target Directory"))
2711 options.targetDirectory = /*CopyString(*/equal/*)*/;
2712 else if(!strcmpi(buffer, "Console"))
2713 options.console = ParseTrueFalseValue(equal);
2714 else if(!strcmpi(buffer, "Libraries"))
2716 if(!options.libraries) options.libraries = { };
2717 ParseArrayValue(options.libraries, equal);
2719 else if(!strcmpi(buffer, "Intermediate Directory"))
2720 options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
2721 else if(!strcmpi(buffer, "Debug"))
2722 options.debug = ParseTrueFalseValue(equal);
2723 else if(!strcmpi(buffer, "Optimize"))
2725 if(!strcmpi(equal, "None"))
2726 options.optimization = none;
2727 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
2728 options.optimization = speed;
2729 else if(!strcmpi(equal, "Size"))
2730 options.optimization = size;
2732 options.optimization = none;
2734 else if(!strcmpi(buffer, "Compress"))
2735 options.compress = ParseTrueFalseValue(equal);
2736 else if(!strcmpi(buffer, "Profile"))
2737 options.profile = ParseTrueFalseValue(equal);
2738 else if(!strcmpi(buffer, "AllWarnings"))
2739 options.warnings = ParseTrueFalseValue(equal) ? all : unset;
2740 else if(!strcmpi(buffer, "MemoryGuard"))
2741 options.memoryGuard = ParseTrueFalseValue(equal);
2742 else if(!strcmpi(buffer, "Default Name Space"))
2743 options.defaultNameSpace = CopyString(equal);
2744 else if(!strcmpi(buffer, "Strict Name Spaces"))
2745 options.strictNameSpaces = ParseTrueFalseValue(equal);
2746 else if(!strcmpi(buffer, "Preprocessor Definitions"))
2748 if(!options.preprocessorDefinitions) options.preprocessorDefinitions = { };
2749 ParseArrayValue(options.preprocessorDefinitions, equal);
2755 if(!options.targetDirectory && options.objectsDirectory)
2756 options.targetDirectory = /*CopyString(*/options.objectsDirectory/*)*/;
2757 //if(!objDir.dir) objDir.dir = "obj";
2758 //if(!targetDir.dir) targetDir.dir = "";
2759 // if(!targetName) property::targetName = ""; // How can a targetFileName be nothing???
2760 // if(!defaultNameSpace) property::defaultNameSpace = "";
2761 makingModified = true;
2764 Project LegacyAsciiLoadProject(File f, char * filePath)
2766 Project project = null;
2767 ProjectNode node = null;
2769 char parentPath[MAX_LOCATION];
2770 char section[128] = "";
2771 char subSection[128] = "";
2773 bool configurationsPresent = false;
2783 f.GetLine(buffer, 65536 - 1);
2784 TrimLSpaces(buffer, buffer);
2785 TrimRSpaces(buffer, buffer);
2788 if(buffer[0] == '-' || buffer[0] == '=')
2790 bool simple = buffer[0] == '-';
2793 TrimLSpaces(equal, equal);
2794 if(!strcmpi(section, "Target") && !strcmpi(subSection, "LibraryDirs"))
2796 if(!project.config.options.libraryDirs) project.config.options.libraryDirs = { };
2797 project.config.options.libraryDirs.Add(CopyString(equal));
2799 else if(!strcmpi(section, "Target") && !strcmpi(subSection, "IncludeDirs"))
2801 if(!project.config.options.includeDirs) project.config.options.includeDirs = { };
2802 project.config.options.includeDirs.Add(CopyString(equal));
2804 else if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
2806 len = strlen(equal);
2809 char temp[MAX_LOCATION];
2810 ProjectNode child { };
2811 // We don't need to do this anymore, fileName is just a property that sets name & path
2812 // child.fileName = CopyString(equal);
2815 child.name = CopyString(equal);
2816 child.path = CopyString(parentPath);
2820 GetLastDirectory(equal, temp);
2821 child.name = CopyString(temp);
2822 StripLastDirectory(equal, temp);
2823 child.path = CopyString(temp);
2825 child.nodeType = file;
2826 child.parent = parent;
2827 child.indent = parent.indent + 1;
2829 child.icon = NodeIcons::SelectFileIcon(child.name);
2830 parent.files.Add(child);
2836 StripLastDirectory(parentPath, parentPath);
2837 parent = parent.parent;
2841 else if(buffer[0] == '+')
2845 TrimLSpaces(equal, equal);
2846 if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
2848 char temp[MAX_LOCATION];
2849 ProjectNode child { };
2850 // NEW: Folders now have a path set like files
2851 child.name = CopyString(equal);
2852 strcpy(temp, parentPath);
2853 PathCatSlash(temp, child.name);
2854 child.path = CopyString(temp);
2856 child.parent = parent;
2857 child.indent = parent.indent + 1;
2858 child.type = folder;
2859 child.nodeType = folder;
2861 child.icon = folder;
2862 PathCatSlash(parentPath, child.name);
2863 parent.files.Add(child);
2868 else if(!strcmpi(section, "Configurations"))
2870 ProjectConfig newConfig
2872 makingModified = true;
2876 LegacyProjectConfigLoad(newConfig, f);
2877 project.configurations.Add(newConfig);
2880 else if(!strcmpi(buffer, "ECERE Project File"));
2881 else if(!strcmpi(buffer, "Version 0a"))
2882 ; //strcpy(version, "0a");
2883 else if(!strcmpi(buffer, "Version 0.1a"))
2884 ; //strcpy(version, "0.1a");
2885 else if(!strcmpi(buffer, "Configurations"))
2887 project.configurations.Free();
2888 project.config = null;
2889 strcpy(section, buffer);
2890 configurationsPresent = true;
2892 else if(!strcmpi(buffer, "Target") || !strnicmp(buffer, "Target \"", strlen("Target \"")))
2894 ProjectConfig newConfig { name = CopyString("Default"), options = { } };
2895 char topNodePath[MAX_LOCATION];
2896 // newConfig.defaultNameSpace = "";
2897 //newConfig.objDir.dir = "obj";
2898 //newConfig.targetDir.dir = "";
2899 project = Project { /*options = { }*/ };
2900 project.configurations = { [ newConfig ] };
2901 project.config = newConfig;
2902 // if(project.topNode.path) delete project.topNode.path;
2903 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
2904 MakeSlashPath(topNodePath);
2905 PathCatSlash(topNodePath, filePath);
2906 project.filePath = topNodePath;
2907 parentPath[0] = '\0';
2908 parent = project.topNode;
2910 strcpy(section, "Target");
2915 if(equal[0] == '\"')
2917 StripQuotes(equal, equal);
2918 delete project.moduleName; project.moduleName = CopyString(equal);
2922 else if(!strcmpi(buffer, "Compiler Options"));
2923 else if(!strcmpi(buffer, "IncludeDirs"))
2924 strcpy(subSection, buffer);
2925 else if(!strcmpi(buffer, "Linker Options"));
2926 else if(!strcmpi(buffer, "LibraryDirs"))
2927 strcpy(subSection, buffer);
2928 else if(!strcmpi(buffer, "Files"))
2930 strcpy(section, "Target");
2931 strcpy(subSection, buffer);
2933 else if(!strcmpi(buffer, "Resources"))
2935 ProjectNode child { };
2936 parent.files.Add(child);
2937 child.parent = parent;
2938 child.indent = parent.indent + 1;
2939 child.name = CopyString(buffer);
2940 child.path = CopyString("");
2941 child.type = resources;
2943 child.icon = archiveFile;
2944 project.resNode = child;
2947 strcpy(subSection, buffer);
2951 equal = strstr(buffer, "=");
2955 TrimRSpaces(buffer, buffer);
2957 TrimLSpaces(equal, equal);
2959 if(!strcmpi(section, "Target"))
2961 if(!strcmpi(buffer, "Build Exclusions"))
2963 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
2965 /*if(node && node.type != NodeTypes::project)
2966 ParseListValue(node.buildExclusions, equal);*/
2969 else if(!strcmpi(buffer, "Path") && !strcmpi(subSection, "Resources"))
2971 delete project.resNode.path;
2972 project.resNode.path = CopyString(equal);
2973 PathCatSlash(parentPath, equal);
2977 else if(!strcmpi(buffer, "Intermediate Directory"))
2978 project.config.options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
2979 else if(!strcmpi(buffer, "Debug"))
2980 project.config.options.debug = ParseTrueFalseValue(equal);
2981 else if(!strcmpi(buffer, "Optimize"))
2983 if(!strcmpi(equal, "None"))
2984 project.config.options.optimization = none;
2985 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
2986 project.config.options.optimization = speed;
2987 else if(!strcmpi(equal, "Size"))
2988 project.config.options.optimization = size;
2990 project.config.options.optimization = none;
2992 else if(!strcmpi(buffer, "Profile"))
2993 project.config.options.profile = ParseTrueFalseValue(equal);
2994 else if(!strcmpi(buffer, "MemoryGuard"))
2995 project.config.options.memoryGuard = ParseTrueFalseValue(equal);
2998 if(!project.options) project.options = { };
3000 // Project Wide Settings (All configs)
3001 if(!strcmpi(buffer, "Target Name"))
3002 project.options.targetFileName = /*CopyString(*/equal/*)*/;
3003 else if(!strcmpi(buffer, "Target Type"))
3005 if(!strcmpi(equal, "Executable"))
3006 project.options.targetType = executable;
3007 else if(!strcmpi(equal, "Shared"))
3008 project.options.targetType = sharedLibrary;
3009 else if(!strcmpi(equal, "Static"))
3010 project.options.targetType = staticLibrary;
3012 project.options.targetType = executable;
3014 else if(!strcmpi(buffer, "Target Directory"))
3015 project.options.targetDirectory = /*CopyString(*/equal/*)*/;
3016 else if(!strcmpi(buffer, "Console"))
3017 project.options.console = ParseTrueFalseValue(equal);
3018 else if(!strcmpi(buffer, "Libraries"))
3020 if(!project.options.libraries) project.options.libraries = { };
3021 ParseArrayValue(project.options.libraries, equal);
3023 else if(!strcmpi(buffer, "AllWarnings"))
3024 project.options.warnings = ParseTrueFalseValue(equal) ? all : unset;
3025 else if(!strcmpi(buffer, "Preprocessor Definitions"))
3027 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
3029 /*if(node && (node.type == NodeTypes::project || (node.type == file && !node.isInResources) || node.type == folder))
3030 ParseListValue(node.preprocessorDefs, equal);*/
3034 if(!project.options.preprocessorDefinitions) project.options.preprocessorDefinitions = { };
3035 ParseArrayValue(project.options.preprocessorDefinitions, equal);
3046 SplitPlatformLibraries(project);
3048 if(configurationsPresent)
3049 CombineIdenticalConfigOptions(project);
3053 void SplitPlatformLibraries(Project project)
3055 if(project && project.configurations)
3057 for(cfg : project.configurations)
3059 if(cfg.options.libraries && cfg.options.libraries.count)
3061 Iterator<String> it { cfg.options.libraries };
3065 char * platformName = strstr(l, ":");
3068 PlatformOptions platform = null;
3070 if(!cfg.platforms) cfg.platforms = { };
3071 for(p : cfg.platforms)
3073 if(!strcmpi(platformName, p.name))
3081 platform = { name = CopyString(platformName), options = { libraries = { } } };
3082 cfg.platforms.Add(platform);
3084 *(platformName-1) = 0;
3085 platform.options.libraries.Add(CopyString(l));
3087 cfg.options.libraries.Delete(it.pointer);
3096 void CombineIdenticalConfigOptions(Project project)
3098 if(project && project.configurations && project.configurations.count)
3101 ProjectOptions nullOptions { };
3102 ProjectConfig firstConfig = null;
3103 for(cfg : project.configurations)
3105 if(cfg.options.targetType != staticLibrary)
3112 firstConfig = project.configurations.firstIterator.data;
3114 for(member = class(ProjectOptions).membersAndProperties.first; member; member = member.next)
3116 if(!member.isProperty)
3118 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
3123 for(cfg : project.configurations)
3125 if(cfg != firstConfig)
3127 if(cfg.options.targetType != staticLibrary)
3131 if(type.type == noHeadClass || type.type == normalClass)
3133 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3134 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3135 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3139 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3140 (byte *)firstConfig.options + member.offset + member._class.offset,
3141 (byte *)cfg.options + member.offset + member._class.offset);
3153 if(type.type == noHeadClass || type.type == normalClass)
3155 if(!type._vTbl[__ecereVMethodID_class_OnCompare](type,
3156 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3157 *(void **)((byte *)nullOptions + member.offset + member._class.offset)))
3162 if(!type._vTbl[__ecereVMethodID_class_OnCompare](type,
3163 (byte *)firstConfig.options + member.offset + member._class.offset,
3164 (byte *)nullOptions + member.offset + member._class.offset))
3168 if(!project.options) project.options = { };
3170 /*if(type.type == noHeadClass || type.type == normalClass)
3172 type._vTbl[__ecereVMethodID_class_OnCopy](type,
3173 (byte *)project.options + member.offset + member._class.offset,
3174 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
3178 void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
3179 // TOFIX: ListBox::SetData / OnCopy mess
3180 type._vTbl[__ecereVMethodID_class_OnCopy](type,
3181 (byte *)project.options + member.offset + member._class.offset,
3182 (type.typeSize > 4) ? address :
3183 ((type.typeSize == 4) ? (void *)*(uint32 *)address :
3184 ((type.typeSize == 2) ? (void *)*(uint16*)address :
3185 (void *)*(byte *)address )));
3188 (byte *)project.options + member.offset + member._class.offset,
3189 (byte *)firstConfig.options + member.offset + member._class.offset, type.typeSize);
3191 for(cfg : project.configurations)
3193 if(cfg.options.targetType == staticLibrary)
3197 if(type.type == noHeadClass || type.type == normalClass)
3199 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3200 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3201 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3205 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3206 (byte *)firstConfig.options + member.offset + member._class.offset,
3207 (byte *)cfg.options + member.offset + member._class.offset);
3212 if(cfg != firstConfig)
3214 if(type.type == noHeadClass || type.type == normalClass)
3216 type._vTbl[__ecereVMethodID_class_OnFree](type,
3217 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3221 type._vTbl[__ecereVMethodID_class_OnFree](type,
3222 (byte *)cfg.options + member.offset + member._class.offset);
3224 memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
3227 memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
3234 // Compare Platform Specific Settings
3237 for(cfg : project.configurations)
3239 if(cfg != firstConfig && cfg.options.targetType != staticLibrary && (firstConfig.platforms || cfg.platforms) &&
3240 ((!firstConfig.platforms && cfg.platforms) || firstConfig.platforms.OnCompare(cfg.platforms)))
3246 if(same && firstConfig.platforms)
3248 for(cfg : project.configurations)
3250 if(cfg.options.targetType == staticLibrary && firstConfig.platforms.OnCompare(cfg.platforms))
3252 if(cfg != firstConfig)
3254 cfg.platforms.Free();
3255 delete cfg.platforms;
3258 project.platforms = firstConfig.platforms;
3259 firstConfig.platforms = null;
3263 // Static libraries can't contain libraries
3264 for(cfg : project.configurations)
3266 if(cfg.options.targetType == staticLibrary)
3268 if(!cfg.options.libraries) cfg.options.libraries = { };
3269 cfg.options.libraries.Free();
3275 Project LoadProject(char * filePath)
3277 Project project = null;
3278 File f = FileOpen(filePath, read);
3281 project = LegacyBinaryLoadProject(f, filePath);
3284 JSONParser parser { f = f };
3285 JSONResult result = parser.GetObject(class(Project), &project);
3288 char insidePath[MAX_LOCATION];
3290 delete project.topNode.files;
3291 if(!project.files) project.files = { };
3292 project.topNode.files = project.files;
3293 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
3294 delete project.resNode.path;
3295 project.resNode.path = project.resourcesPath;
3296 project.resourcesPath = null;
3297 project.resNode.nodeType = (ProjectNodeType)-1;
3298 delete project.resNode.files;
3299 project.resNode.files = project.resources;
3300 project.files = null;
3301 project.resources = null;
3302 if(!project.configurations) project.configurations = { };
3305 char topNodePath[MAX_LOCATION];
3306 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3307 MakeSlashPath(topNodePath);
3308 PathCatSlash(topNodePath, filePath);
3309 project.filePath = topNodePath;//filePath;
3312 project.topNode.FixupNode(insidePath);
3317 project = LegacyAsciiLoadProject(f, filePath);
3323 if(!project.options) project.options = { };
3324 if(!project.config && project.configurations)
3325 project.config = project.configurations.firstIterator.data;
3327 if(!project.resNode)
3329 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
3332 if(!project.moduleName)
3333 project.moduleName = CopyString(project.name);
3334 if(project.config &&
3335 (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
3336 (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
3338 //delete project.config.options.targetFileName;
3340 project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
3341 project.config.options.optimization = none;
3342 project.config.options.debug = true;
3343 //project.config.options.warnings = unset;
3344 project.config.options.memoryGuard = false;
3345 project.config.compilingModified = true;
3346 project.config.linkingModified = true;
3348 else if(!project.topNode.name && project.config)
3350 project.topNode.name = CopyString(project.config.options.targetFileName);
3353 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
3354 project.topNode.configurations = project.configurations;
3355 project.topNode.platforms = project.platforms;
3356 project.topNode.options = project.options;*/