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 =\n");
1909 f.Printf("CECFLAGS =\n");
1910 f.Printf("ECFLAGS =\n");
1911 f.Printf("OFLAGS =\n");
1912 f.Printf("LIBS =\n");
1915 if((compiler.includeDirs && compiler.includeDirs.count) ||
1916 (compiler.libraryDirs && compiler.libraryDirs.count))
1918 if(compiler.includeDirs && compiler.includeDirs.count)
1920 f.Printf("CFLAGS +=");
1921 OutputListOption(f, gccCompiler ? "isystem " : "I", compiler.includeDirs, lineEach, true);
1924 if(compiler.libraryDirs && compiler.libraryDirs.count)
1926 f.Printf("OFLAGS +=");
1927 OutputListOption(f, "L", compiler.libraryDirs, lineEach, true);
1933 if((config && config.options && config.options.libraries) ||
1934 (options && options.libraries))
1936 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
1937 f.Printf("LIBS +=");
1938 if(config && config.options && config.options.libraries)
1939 OutputLibraries(f, config.options.libraries);
1940 else if(options && options.libraries)
1941 OutputLibraries(f, options.libraries);
1943 f.Printf("endif\n");
1946 f.Printf("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n\n");
1948 if(platforms || (config && config.platforms))
1951 //for(platform = firstPlatform; platform <= lastPlatform; platform++)
1952 //for(platform = win32; platform <= apple; platform++)
1954 f.Printf("# PLATFORM-SPECIFIC OPTIONS\n\n");
1955 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
1957 PlatformOptions projectPlatformOptions, configPlatformOptions;
1958 MatchProjectAndConfigPlatformOptions(config, platform, &projectPlatformOptions, &configPlatformOptions);
1960 if(projectPlatformOptions || configPlatformOptions)
1966 f.Printf(PlatformToMakefileVariable(platform));
1969 if((projectPlatformOptions && projectPlatformOptions.options.preprocessorDefinitions && projectPlatformOptions.options.preprocessorDefinitions.count) ||
1970 (configPlatformOptions && configPlatformOptions.options.preprocessorDefinitions && configPlatformOptions.options.preprocessorDefinitions.count) ||
1971 (projectPlatformOptions && projectPlatformOptions.options.includeDirs && projectPlatformOptions.options.includeDirs.count) ||
1972 (configPlatformOptions && configPlatformOptions.options.includeDirs && configPlatformOptions.options.includeDirs.count))
1974 f.Printf("CFLAGS +=");
1975 if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
1977 f.Printf(" \\\n\t -Wl");
1978 for(s : projectPlatformOptions.options.linkerOptions)
1981 if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
1983 f.Printf(" \\\n\t -Wl");
1984 for(s : configPlatformOptions.options.linkerOptions)
1987 if(projectPlatformOptions && projectPlatformOptions.options.preprocessorDefinitions)
1988 OutputListOption(f, "D", projectPlatformOptions.options.preprocessorDefinitions, newLine, false);
1989 if(configPlatformOptions && configPlatformOptions.options.preprocessorDefinitions)
1990 OutputListOption(f, "D", configPlatformOptions.options.preprocessorDefinitions, newLine, false );
1991 if(configPlatformOptions && configPlatformOptions.options.includeDirs)
1992 OutputListOption(f, "I", configPlatformOptions.options.includeDirs, lineEach, true);
1993 if(projectPlatformOptions && projectPlatformOptions.options.includeDirs)
1994 OutputListOption(f, "I", projectPlatformOptions.options.includeDirs, lineEach, true);
1998 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
1999 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count) ||
2000 (projectPlatformOptions && projectPlatformOptions.options.libraries && projectPlatformOptions.options.libraries.count) ||
2001 (configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
2003 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2004 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
2005 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count))
2007 f.Printf("OFLAGS +=");
2008 if(configPlatformOptions && configPlatformOptions.options.libraryDirs)
2009 OutputListOption(f, "L", configPlatformOptions.options.libraryDirs, lineEach, true);
2010 if(projectPlatformOptions && projectPlatformOptions.options.libraryDirs)
2011 OutputListOption(f, "L", projectPlatformOptions.options.libraryDirs, lineEach, true);
2015 if(projectPlatformOptions && projectPlatformOptions.options.libraries &&
2016 projectPlatformOptions.options.libraries.count)
2018 f.Printf("LIBS +=");
2019 OutputLibraries(f, projectPlatformOptions.options.libraries);
2022 if((configPlatformOptions && configPlatformOptions.options.libraries &&
2023 configPlatformOptions.options.libraries.count))
2025 f.Printf("LIBS +=");
2026 OutputLibraries(f, configPlatformOptions.options.libraries);
2029 f.Printf("endif\n\n");
2035 for(c = 0; c < ifCount; c++)
2036 f.Printf("endif\n");
2041 f.Printf("CFLAGS +=");
2044 f.Printf(" -fmessage-length=0");
2045 switch(GetOptimization(config))
2049 f.Printf(" -ffast-math");
2055 //if(compiler.targetPlatform.is32Bits)
2057 //else if(compiler.targetPlatform.is64Bits)
2058 // f.Printf(" -m64");
2059 f.Printf(" $(FPIC)");
2060 //f.Printf(" -fpack-struct");
2062 switch(GetWarnings(config))
2064 case all: f.Printf(" -Wall"); break;
2065 case none: f.Printf(" -w"); break;
2067 if(GetDebug(config))
2069 if(GetProfile(config))
2071 if(options && options.linkerOptions && options.linkerOptions.count)
2073 f.Printf(" \\\n\t -Wl");
2074 for(s : options.linkerOptions)
2078 if(options && options.preprocessorDefinitions)
2079 OutputListOption(f, "D", options.preprocessorDefinitions, newLine, false);
2080 if(config && config.options && config.options.preprocessorDefinitions)
2081 OutputListOption(f, "D", config.options.preprocessorDefinitions, newLine, false);
2082 if(config && config.options && config.options.includeDirs)
2083 OutputListOption(f, "I", config.options.includeDirs, lineEach, true);
2084 if(options && options.includeDirs)
2085 OutputListOption(f, "I", options.includeDirs, lineEach, true);
2088 f.Printf("CECFLAGS +=%s%s%s%s", defaultPreprocessor ? "" : " -cpp ", defaultPreprocessor ? "" : compiler.cppCommand,
2089 crossCompiling ? " -t " : "", crossCompiling ? (char*)compiler.targetPlatform : "");
2092 f.Printf("ECFLAGS +=");
2093 if(GetMemoryGuard(config))
2094 f.Printf(" -memguard");
2095 if(GetStrictNameSpaces(config))
2096 f.Printf(" -strictns");
2097 if(GetNoLineNumbers(config))
2098 f.Printf(" -nolinenumbers");
2101 if((s = GetDefaultNameSpace(config)) && s[0])
2102 f.Printf(" -defaultns %s", s);
2106 f.Printf("OFLAGS +=\n");
2107 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2108 f.Printf("OFLAGS += -m32");
2109 if(GetProfile(config))
2111 if(config && config.options && config.options.libraryDirs)
2112 OutputListOption(f, "L", config.options.libraryDirs, lineEach, true);
2113 if(options && options.libraryDirs)
2114 OutputListOption(f, "L", options.libraryDirs, lineEach, true);
2116 f.Printf("endif\n\n");
2118 f.Printf("UPXFLAGS = -9\n\n"); // TOFEAT: Compression Level Option? Other UPX Options?
2120 f.Printf("# HARD CODED PLATFORM-SPECIFIC OPTIONS\n");
2121 f.Printf("ifdef %s\n", PlatformToMakefileVariable(tux));
2122 f.Printf("OFLAGS += -Wl,--no-undefined\n");
2123 f.Printf("endif\n\n");
2126 f.Printf("ifdef %s\n", PlatformToMakefileVariable(apple));
2127 f.Printf("OFLAGS += -framework cocoa -framework OpenGL\n");
2128 f.Printf("endif\n\n");
2130 f.Printf("# TARGETS\n\n");
2132 f.Printf("all: objdir%s $(TARGET)\n\n", sameObjTargetDirs ? "" : " targetdir");
2134 f.Printf("objdir:\n");
2135 f.Printf("\t$(if $(wildcard $(OBJ)),,$(call mkdirq,$(OBJ)))\n");
2136 //f.Printf("# PRE-BUILD COMMANDS\n");
2137 if(options && options.prebuildCommands)
2139 for(s : options.prebuildCommands)
2140 if(s && s[0]) f.Printf("\t%s\n", s);
2142 if(config && config.options && config.options.prebuildCommands)
2144 for(s : config.options.prebuildCommands)
2145 if(s && s[0]) f.Printf("\t%s\n", s);
2147 if(platforms || (config && config.platforms))
2150 //f.Printf("# PLATFORM-SPECIFIC PRE-BUILD COMMANDS\n");
2151 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2153 PlatformOptions projectPOs, configPOs;
2154 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2156 if((projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count) ||
2157 (configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count))
2163 f.Printf(PlatformToMakefileVariable(platform));
2166 if(projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count)
2168 for(s : projectPOs.options.prebuildCommands)
2169 if(s && s[0]) f.Printf("\t%s\n", s);
2171 if(configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count)
2173 for(s : configPOs.options.prebuildCommands)
2174 if(s && s[0]) f.Printf("\t%s\n", s);
2181 for(c = 0; c < ifCount; c++)
2182 f.Printf("endif\n");
2187 if(!sameObjTargetDirs)
2189 f.Printf("targetdir:\n");
2190 f.Printf("\t$(if $(wildcard %s),,$(call mkdirq,%s))\n\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
2195 // Main Module (Linking) for ECERE C modules
2196 f.Printf("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
2197 // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
2198 f.Printf("\t$(ECS)%s $(ECSLIBOPT) $(SYMBOLS) $(IMPORTS) -symbols %s -o $(OBJ)$(MODULE).main.ec\n\n",
2199 GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
2200 // Main Module (Linking) for ECERE C modules
2201 f.Printf("$(OBJ)$(MODULE).main.c: $(OBJ)$(MODULE).main.ec\n");
2202 f.Printf("\t$(ECP) $(CECFLAGS) $(ECFLAGS) $(CFLAGS)"
2203 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
2204 f.Printf("\t$(ECC) $(CECFLAGS) $(ECFLAGS) $(CFLAGS) $(FVISIBILITY)"
2205 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.c -symbols $(OBJ)\n\n");
2210 // This would not rebuild the target on updated objects
2211 // f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) | objdir $(SYMBOLS) $(OBJECTS)%s\n", sameObjTargetDirs ? "" : " targetdir");
2213 // This should fix it for good!
2214 f.Printf("$(SYMBOLS): | objdir\n");
2215 f.Printf("$(OBJECTS): | objdir\n");
2217 // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
2218 f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
2220 f.Printf("ifneq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(staticLibrary));
2221 f.Printf("\t$(CC) $(OFLAGS) $(OBJECTS) $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
2222 if(!GetDebug(config))
2224 f.Printf("ifndef NOSTRIP\n");
2225 f.Printf("\t$(STRIP) $(STRIPOPT) $(TARGET)\n");
2226 f.Printf("endif\n");
2228 if(GetCompress(config))
2230 f.Printf("ifndef WINDOWS\n");
2231 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(executable));
2232 f.Printf("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
2233 f.Printf("endif\n");
2235 f.Printf("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
2236 f.Printf("endif\n");
2239 if(resNode.files && resNode.files.count && !noResources)
2240 resNode.GenMakefileAddResources(f, resNode.path, config);
2242 f.Printf("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
2243 f.Printf("endif\n");
2245 //f.Printf("# POST-BUILD COMMANDS\n");
2246 if(options && options.postbuildCommands)
2248 for(s : options.postbuildCommands)
2249 if(s && s[0]) f.Printf("\t%s\n", s);
2251 if(config && config.options && config.options.postbuildCommands)
2253 for(s : config.options.postbuildCommands)
2254 if(s && s[0]) f.Printf("\t%s\n", s);
2256 if(platforms || (config && config.platforms))
2259 //f.Printf("# PLATFORM-SPECIFIC POST-BUILD COMMANDS\n");
2260 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2262 PlatformOptions projectPOs, configPOs;
2263 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2265 if((projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count) ||
2266 (configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count))
2272 f.Printf(PlatformToMakefileVariable(platform));
2275 if(projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count)
2277 for(s : projectPOs.options.postbuildCommands)
2278 if(s && s[0]) f.Printf("\t%s\n", s);
2280 if(configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count)
2282 for(s : configPOs.options.postbuildCommands)
2283 if(s && s[0]) f.Printf("\t%s\n", s);
2290 for(c = 0; c < ifCount; c++)
2291 f.Printf("endif\n");
2296 f.Printf("# SYMBOL RULES\n\n");
2298 Map<Platform, bool> excludedPlatforms { };
2299 topNode.GenMakefilePrintSymbolRules(f, this, compiler, config, excludedPlatforms);
2300 delete excludedPlatforms;
2303 f.Printf("# C OBJECT RULES\n\n");
2305 Map<Platform, bool> excludedPlatforms { };
2306 topNode.GenMakefilePrintCObjectRules(f, this, compiler, config, excludedPlatforms);
2307 delete excludedPlatforms;
2312 f.Printf("# IMPLICIT OBJECT RULE\n\n");
2314 f.Printf("$(OBJ)%%$(O) : $(OBJ)%%.c\n");
2315 f.Printf("\t$(CC) $(CFLAGS) $(FVISIBILITY) -c $< -o $@\n\n");
2318 f.Printf("# OBJECT RULES\n\n");
2319 // todo call this still but only generate rules whith specific options
2320 // see we-have-file-specific-options in ProjectNode.ec
2322 Map<Platform, bool> excludedPlatforms { };
2323 topNode.GenMakefilePrintObjectRules(f, this, namesInfo, compiler, config, excludedPlatforms);
2324 delete excludedPlatforms;
2328 GenMakefilePrintMainObjectRule(f, compiler, config);
2330 f.Printf("clean: objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
2331 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) " : "");
2332 OutputCleanActions(f, "OBJECTS", objectsParts);
2333 OutputCleanActions(f, "COBJECTS", cobjectsParts);
2336 OutputCleanActions(f, "IMPORTS", importsParts);
2337 OutputCleanActions(f, "SYMBOLS", symbolsParts);
2341 f.Printf("realclean: clean\n");
2342 f.Printf("\t$(call rmrq,$(OBJ))\n");
2343 if(!sameObjTargetDirs)
2344 f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
2350 varStringLenDiffs.Free();
2351 delete varStringLenDiffs;
2358 // ChangeWorkingDir(oldDirectory);
2359 // delete pathBackup;
2362 config.makingModified = false;
2366 void GenMakefilePrintMainObjectRule(File f, CompilerConfig compiler, ProjectConfig config)
2368 char extension[MAX_EXTENSION] = "c";
2369 char modulePath[MAX_LOCATION];
2370 char fixedModuleName[MAX_FILENAME];
2373 char objDirNoSpaces[MAX_LOCATION];
2374 DirExpression objDirExp = GetObjDir(compiler, config);
2376 ReplaceSpaces(objDirNoSpaces, objDirExp.dir);
2377 ReplaceSpaces(fixedModuleName, moduleName);
2379 //sprintf(fixedModuleName, "%s.main", fixedPrjName);
2380 //strcat(fixedModuleName, ".main");
2382 #if 0 // TODO: Fix nospaces stuff
2383 // *** Dependency command ***
2384 sprintf(command, "gcc -MT $(OBJ)%s$(O) -MM $(OBJ)%s.c", fixedModuleName, fixedModuleName);
2386 // System Includes (from global settings)
2387 for(item : compiler.dirs[Includes])
2389 strcat(command, " -isystem ");
2390 if(strchr(item.name, ' '))
2392 strcat(command, "\"");
2393 strcat(command, item);
2394 strcat(command, "\"");
2397 strcat(command, item);
2400 for(item = includeDirs.first; item; item = item.next)
2402 strcat(command, " -I");
2403 if(strchr(item.name, ' '))
2405 strcat(command, "\"");
2406 strcat(command, item.name);
2407 strcat(command, "\"");
2410 strcat(command, item.name);
2412 for(item = preprocessorDefs.first; item; item = item.next)
2414 strcat(command, " -D");
2415 strcat(command, item.name);
2419 if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
2423 bool firstLine = true;
2425 // To do some time: auto save external dependencies?
2428 if(dep.GetLine(line, sizeof(line)-1))
2432 char * colon = strstr(line, ":");
2433 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
2447 // If we failed to generate dependencies...
2451 f.Printf("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
2457 f.Printf("\t$(CC) $(CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(OBJ)$(MODULE).main$(O)\n\n", extension);
2462 void MatchProjectAndConfigPlatformOptions(ProjectConfig config, Platform platform,
2463 PlatformOptions * projectPlatformOptions, PlatformOptions * configPlatformOptions)
2465 *projectPlatformOptions = null;
2466 *configPlatformOptions = null;
2471 if(!strcmpi(p.name, platform))
2473 *projectPlatformOptions = p;
2478 if(config && config.platforms)
2480 for(p : config.platforms)
2482 if(!strcmpi(p.name, platform))
2484 *configPlatformOptions = p;
2492 Project LegacyBinaryLoadProject(File f, char * filePath)
2494 Project project = null;
2495 char signature[sizeof(epjSignature)];
2497 f.Read(signature, sizeof(signature), 1);
2498 if(!strncmp(signature, (char *)epjSignature, sizeof(epjSignature)))
2500 char topNodePath[MAX_LOCATION];
2501 /*ProjectConfig newConfig
2503 name = CopyString("Default");
2504 makingModified = true;
2505 compilingModified = true;
2506 linkingModified = true;
2510 project = Project { options = { } };
2511 LegacyBinaryLoadNode(project.topNode, f);
2512 delete project.topNode.path;
2513 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
2514 MakeSlashPath(topNodePath);
2516 PathCatSlash(topNodePath, filePath);
2517 project.filePath = topNodePath;
2519 /* THIS IS ALREADY DONE BY filePath property
2520 StripLastDirectory(topNodePath, topNodePath);
2521 project.topNode.path = CopyString(topNodePath);
2523 // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
2525 // newConfig.options.defaultNameSpace = "";
2526 /*newConfig.objDir.dir = "obj";
2527 newConfig.targetDir.dir = "";*/
2529 //project.configurations = { [ newConfig ] };
2530 //project.config = newConfig;
2537 String targetFileName, targetDirectory, objectsDirectory;
2539 // { executable = 0, sharedLibrary = 1, staticLibrary = 2 };
2540 f.Read(&temp, sizeof(int),1);
2543 case 0: project.options.targetType = executable; break;
2544 case 1: project.options.targetType = sharedLibrary; break;
2545 case 2: project.options.targetType = staticLibrary; break;
2548 f.Read(&len, sizeof(int),1);
2549 targetFileName = new char[len+1];
2550 f.Read(targetFileName, sizeof(char), len+1);
2551 project.options.targetFileName = targetFileName;
2552 delete targetFileName;
2554 f.Read(&len, sizeof(int),1);
2555 targetDirectory = new char[len+1];
2556 f.Read(targetDirectory, sizeof(char), len+1);
2557 project.options.targetDirectory = targetDirectory;
2558 delete targetDirectory;
2560 f.Read(&len, sizeof(int),1);
2561 objectsDirectory = new byte[len+1];
2562 f.Read(objectsDirectory, sizeof(char), len+1);
2563 project.options.objectsDirectory = objectsDirectory;
2564 delete objectsDirectory;
2566 f.Read(&temp, sizeof(int),1);
2567 project./*config.*/options.debug = temp ? true : false;
2568 f.Read(&temp, sizeof(int),1);
2569 project./*config.*/options.optimization = temp ? speed : none;
2570 f.Read(&temp, sizeof(int),1);
2571 project./*config.*/options.profile = temp ? true : false;
2572 f.Read(&temp, sizeof(int),1);
2573 project.options.warnings = temp ? all : unset;
2575 f.Read(&count, sizeof(int),1);
2578 project.options.includeDirs = { };
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.includeDirs.Add(name);
2589 f.Read(&count, sizeof(int),1);
2592 project.options.libraryDirs = { };
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.libraryDirs.Add(name);
2603 f.Read(&count, sizeof(int),1);
2606 project.options.libraries = { };
2607 for(c = 0; c < count; c++)
2610 f.Read(&len, sizeof(int),1);
2611 name = new char[len+1];
2612 f.Read(name, sizeof(char), len+1);
2613 project.options.libraries.Add(name);
2617 f.Read(&count, sizeof(int),1);
2620 project.options.preprocessorDefinitions = { };
2621 for(c = 0; c < count; c++)
2624 f.Read(&len, sizeof(int),1);
2625 name = new char[len+1];
2626 f.Read(name, sizeof(char), len+1);
2627 project.options.preprocessorDefinitions.Add(name);
2631 f.Read(&temp, sizeof(int),1);
2632 project.options.console = temp ? true : false;
2635 for(node : project.topNode.files)
2637 if(node.type == resources)
2639 project.resNode = node;
2649 void ProjectConfig::LegacyProjectConfigLoad(File f)
2657 char subSection[128];
2663 f.GetLine(buffer, 65536 - 1);
2664 TrimLSpaces(buffer, buffer);
2665 TrimRSpaces(buffer, buffer);
2668 if(buffer[0] == '-')
2672 TrimLSpaces(equal, equal);
2673 if(!strcmpi(subSection, "LibraryDirs"))
2675 if(!options.libraryDirs)
2676 options.libraryDirs = { [ CopyString(equal) ] };
2678 options.libraryDirs.Add(CopyString(equal));
2680 else if(!strcmpi(subSection, "IncludeDirs"))
2682 if(!options.includeDirs)
2683 options.includeDirs = { [ CopyString(equal) ] };
2685 options.includeDirs.Add(CopyString(equal));
2688 else if(buffer[0] == '+')
2699 TrimLSpaces(equal, equal);
2700 delete name; name = CopyString(equal); // property::name = equal;
2703 else if(!strcmpi(buffer, "Compiler Options"))
2704 strcpy(section, buffer);
2705 else if(!strcmpi(buffer, "IncludeDirs"))
2706 strcpy(subSection, buffer);
2707 else if(!strcmpi(buffer, "Linker Options"))
2708 strcpy(section, buffer);
2709 else if(!strcmpi(buffer, "LibraryDirs"))
2710 strcpy(subSection, buffer);
2711 else if(!strcmpi(buffer, "Files") || !strcmpi(buffer, "Resources"))
2718 equal = strstr(buffer, "=");
2722 TrimRSpaces(buffer, buffer);
2724 TrimLSpaces(equal, equal);
2725 if(!strcmpi(buffer, "Target Name"))
2726 options.targetFileName = /*CopyString(*/equal/*)*/;
2727 else if(!strcmpi(buffer, "Target Type"))
2729 if(!strcmpi(equal, "Executable"))
2730 options.targetType = executable;
2731 else if(!strcmpi(equal, "Shared"))
2732 options.targetType = sharedLibrary;
2733 else if(!strcmpi(equal, "Static"))
2734 options.targetType = staticLibrary;
2736 options.targetType = executable;
2738 else if(!strcmpi(buffer, "Target Directory"))
2739 options.targetDirectory = /*CopyString(*/equal/*)*/;
2740 else if(!strcmpi(buffer, "Console"))
2741 options.console = ParseTrueFalseValue(equal);
2742 else if(!strcmpi(buffer, "Libraries"))
2744 if(!options.libraries) options.libraries = { };
2745 ParseArrayValue(options.libraries, equal);
2747 else if(!strcmpi(buffer, "Intermediate Directory"))
2748 options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
2749 else if(!strcmpi(buffer, "Debug"))
2750 options.debug = ParseTrueFalseValue(equal);
2751 else if(!strcmpi(buffer, "Optimize"))
2753 if(!strcmpi(equal, "None"))
2754 options.optimization = none;
2755 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
2756 options.optimization = speed;
2757 else if(!strcmpi(equal, "Size"))
2758 options.optimization = size;
2760 options.optimization = none;
2762 else if(!strcmpi(buffer, "Compress"))
2763 options.compress = ParseTrueFalseValue(equal);
2764 else if(!strcmpi(buffer, "Profile"))
2765 options.profile = ParseTrueFalseValue(equal);
2766 else if(!strcmpi(buffer, "AllWarnings"))
2767 options.warnings = ParseTrueFalseValue(equal) ? all : unset;
2768 else if(!strcmpi(buffer, "MemoryGuard"))
2769 options.memoryGuard = ParseTrueFalseValue(equal);
2770 else if(!strcmpi(buffer, "Default Name Space"))
2771 options.defaultNameSpace = CopyString(equal);
2772 else if(!strcmpi(buffer, "Strict Name Spaces"))
2773 options.strictNameSpaces = ParseTrueFalseValue(equal);
2774 else if(!strcmpi(buffer, "Preprocessor Definitions"))
2776 if(!options.preprocessorDefinitions) options.preprocessorDefinitions = { };
2777 ParseArrayValue(options.preprocessorDefinitions, equal);
2783 if(!options.targetDirectory && options.objectsDirectory)
2784 options.targetDirectory = /*CopyString(*/options.objectsDirectory/*)*/;
2785 //if(!objDir.dir) objDir.dir = "obj";
2786 //if(!targetDir.dir) targetDir.dir = "";
2787 // if(!targetName) property::targetName = ""; // How can a targetFileName be nothing???
2788 // if(!defaultNameSpace) property::defaultNameSpace = "";
2789 makingModified = true;
2792 Project LegacyAsciiLoadProject(File f, char * filePath)
2794 Project project = null;
2795 ProjectNode node = null;
2797 char parentPath[MAX_LOCATION];
2798 char section[128] = "";
2799 char subSection[128] = "";
2801 bool configurationsPresent = false;
2811 f.GetLine(buffer, 65536 - 1);
2812 TrimLSpaces(buffer, buffer);
2813 TrimRSpaces(buffer, buffer);
2816 if(buffer[0] == '-' || buffer[0] == '=')
2818 bool simple = buffer[0] == '-';
2821 TrimLSpaces(equal, equal);
2822 if(!strcmpi(section, "Target") && !strcmpi(subSection, "LibraryDirs"))
2824 if(!project.config.options.libraryDirs) project.config.options.libraryDirs = { };
2825 project.config.options.libraryDirs.Add(CopyString(equal));
2827 else if(!strcmpi(section, "Target") && !strcmpi(subSection, "IncludeDirs"))
2829 if(!project.config.options.includeDirs) project.config.options.includeDirs = { };
2830 project.config.options.includeDirs.Add(CopyString(equal));
2832 else if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
2834 len = strlen(equal);
2837 char temp[MAX_LOCATION];
2838 ProjectNode child { };
2839 // We don't need to do this anymore, fileName is just a property that sets name & path
2840 // child.fileName = CopyString(equal);
2843 child.name = CopyString(equal);
2844 child.path = CopyString(parentPath);
2848 GetLastDirectory(equal, temp);
2849 child.name = CopyString(temp);
2850 StripLastDirectory(equal, temp);
2851 child.path = CopyString(temp);
2853 child.nodeType = file;
2854 child.parent = parent;
2855 child.indent = parent.indent + 1;
2857 child.icon = NodeIcons::SelectFileIcon(child.name);
2858 parent.files.Add(child);
2864 StripLastDirectory(parentPath, parentPath);
2865 parent = parent.parent;
2869 else if(buffer[0] == '+')
2873 TrimLSpaces(equal, equal);
2874 if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
2876 char temp[MAX_LOCATION];
2877 ProjectNode child { };
2878 // NEW: Folders now have a path set like files
2879 child.name = CopyString(equal);
2880 strcpy(temp, parentPath);
2881 PathCatSlash(temp, child.name);
2882 child.path = CopyString(temp);
2884 child.parent = parent;
2885 child.indent = parent.indent + 1;
2886 child.type = folder;
2887 child.nodeType = folder;
2889 child.icon = folder;
2890 PathCatSlash(parentPath, child.name);
2891 parent.files.Add(child);
2896 else if(!strcmpi(section, "Configurations"))
2898 ProjectConfig newConfig
2900 makingModified = true;
2904 LegacyProjectConfigLoad(newConfig, f);
2905 project.configurations.Add(newConfig);
2908 else if(!strcmpi(buffer, "ECERE Project File"));
2909 else if(!strcmpi(buffer, "Version 0a"))
2910 ; //strcpy(version, "0a");
2911 else if(!strcmpi(buffer, "Version 0.1a"))
2912 ; //strcpy(version, "0.1a");
2913 else if(!strcmpi(buffer, "Configurations"))
2915 project.configurations.Free();
2916 project.config = null;
2917 strcpy(section, buffer);
2918 configurationsPresent = true;
2920 else if(!strcmpi(buffer, "Target") || !strnicmp(buffer, "Target \"", strlen("Target \"")))
2922 ProjectConfig newConfig { name = CopyString("Default"), options = { } };
2923 char topNodePath[MAX_LOCATION];
2924 // newConfig.defaultNameSpace = "";
2925 //newConfig.objDir.dir = "obj";
2926 //newConfig.targetDir.dir = "";
2927 project = Project { /*options = { }*/ };
2928 project.configurations = { [ newConfig ] };
2929 project.config = newConfig;
2930 // if(project.topNode.path) delete project.topNode.path;
2931 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
2932 MakeSlashPath(topNodePath);
2933 PathCatSlash(topNodePath, filePath);
2934 project.filePath = topNodePath;
2935 parentPath[0] = '\0';
2936 parent = project.topNode;
2938 strcpy(section, "Target");
2943 if(equal[0] == '\"')
2945 StripQuotes(equal, equal);
2946 delete project.moduleName; project.moduleName = CopyString(equal);
2950 else if(!strcmpi(buffer, "Compiler Options"));
2951 else if(!strcmpi(buffer, "IncludeDirs"))
2952 strcpy(subSection, buffer);
2953 else if(!strcmpi(buffer, "Linker Options"));
2954 else if(!strcmpi(buffer, "LibraryDirs"))
2955 strcpy(subSection, buffer);
2956 else if(!strcmpi(buffer, "Files"))
2958 strcpy(section, "Target");
2959 strcpy(subSection, buffer);
2961 else if(!strcmpi(buffer, "Resources"))
2963 ProjectNode child { };
2964 parent.files.Add(child);
2965 child.parent = parent;
2966 child.indent = parent.indent + 1;
2967 child.name = CopyString(buffer);
2968 child.path = CopyString("");
2969 child.type = resources;
2971 child.icon = archiveFile;
2972 project.resNode = child;
2975 strcpy(subSection, buffer);
2979 equal = strstr(buffer, "=");
2983 TrimRSpaces(buffer, buffer);
2985 TrimLSpaces(equal, equal);
2987 if(!strcmpi(section, "Target"))
2989 if(!strcmpi(buffer, "Build Exclusions"))
2991 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
2993 /*if(node && node.type != NodeTypes::project)
2994 ParseListValue(node.buildExclusions, equal);*/
2997 else if(!strcmpi(buffer, "Path") && !strcmpi(subSection, "Resources"))
2999 delete project.resNode.path;
3000 project.resNode.path = CopyString(equal);
3001 PathCatSlash(parentPath, equal);
3005 else if(!strcmpi(buffer, "Intermediate Directory"))
3006 project.config.options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
3007 else if(!strcmpi(buffer, "Debug"))
3008 project.config.options.debug = ParseTrueFalseValue(equal);
3009 else if(!strcmpi(buffer, "Optimize"))
3011 if(!strcmpi(equal, "None"))
3012 project.config.options.optimization = none;
3013 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
3014 project.config.options.optimization = speed;
3015 else if(!strcmpi(equal, "Size"))
3016 project.config.options.optimization = size;
3018 project.config.options.optimization = none;
3020 else if(!strcmpi(buffer, "Profile"))
3021 project.config.options.profile = ParseTrueFalseValue(equal);
3022 else if(!strcmpi(buffer, "MemoryGuard"))
3023 project.config.options.memoryGuard = ParseTrueFalseValue(equal);
3026 if(!project.options) project.options = { };
3028 // Project Wide Settings (All configs)
3029 if(!strcmpi(buffer, "Target Name"))
3030 project.options.targetFileName = /*CopyString(*/equal/*)*/;
3031 else if(!strcmpi(buffer, "Target Type"))
3033 if(!strcmpi(equal, "Executable"))
3034 project.options.targetType = executable;
3035 else if(!strcmpi(equal, "Shared"))
3036 project.options.targetType = sharedLibrary;
3037 else if(!strcmpi(equal, "Static"))
3038 project.options.targetType = staticLibrary;
3040 project.options.targetType = executable;
3042 else if(!strcmpi(buffer, "Target Directory"))
3043 project.options.targetDirectory = /*CopyString(*/equal/*)*/;
3044 else if(!strcmpi(buffer, "Console"))
3045 project.options.console = ParseTrueFalseValue(equal);
3046 else if(!strcmpi(buffer, "Libraries"))
3048 if(!project.options.libraries) project.options.libraries = { };
3049 ParseArrayValue(project.options.libraries, equal);
3051 else if(!strcmpi(buffer, "AllWarnings"))
3052 project.options.warnings = ParseTrueFalseValue(equal) ? all : unset;
3053 else if(!strcmpi(buffer, "Preprocessor Definitions"))
3055 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
3057 /*if(node && (node.type == NodeTypes::project || (node.type == file && !node.isInResources) || node.type == folder))
3058 ParseListValue(node.preprocessorDefs, equal);*/
3062 if(!project.options.preprocessorDefinitions) project.options.preprocessorDefinitions = { };
3063 ParseArrayValue(project.options.preprocessorDefinitions, equal);
3074 SplitPlatformLibraries(project);
3076 if(configurationsPresent)
3077 CombineIdenticalConfigOptions(project);
3081 void SplitPlatformLibraries(Project project)
3083 if(project && project.configurations)
3085 for(cfg : project.configurations)
3087 if(cfg.options.libraries && cfg.options.libraries.count)
3089 Iterator<String> it { cfg.options.libraries };
3093 char * platformName = strstr(l, ":");
3096 PlatformOptions platform = null;
3098 if(!cfg.platforms) cfg.platforms = { };
3099 for(p : cfg.platforms)
3101 if(!strcmpi(platformName, p.name))
3109 platform = { name = CopyString(platformName), options = { libraries = { } } };
3110 cfg.platforms.Add(platform);
3112 *(platformName-1) = 0;
3113 platform.options.libraries.Add(CopyString(l));
3115 cfg.options.libraries.Delete(it.pointer);
3124 void CombineIdenticalConfigOptions(Project project)
3126 if(project && project.configurations && project.configurations.count)
3129 ProjectOptions nullOptions { };
3130 ProjectConfig firstConfig = null;
3131 for(cfg : project.configurations)
3133 if(cfg.options.targetType != staticLibrary)
3140 firstConfig = project.configurations.firstIterator.data;
3142 for(member = class(ProjectOptions).membersAndProperties.first; member; member = member.next)
3144 if(!member.isProperty)
3146 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
3151 for(cfg : project.configurations)
3153 if(cfg != firstConfig)
3155 if(cfg.options.targetType != staticLibrary)
3159 if(type.type == noHeadClass || type.type == normalClass)
3161 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3162 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3163 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3167 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3168 (byte *)firstConfig.options + member.offset + member._class.offset,
3169 (byte *)cfg.options + member.offset + member._class.offset);
3181 if(type.type == noHeadClass || type.type == normalClass)
3183 if(!type._vTbl[__ecereVMethodID_class_OnCompare](type,
3184 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3185 *(void **)((byte *)nullOptions + member.offset + member._class.offset)))
3190 if(!type._vTbl[__ecereVMethodID_class_OnCompare](type,
3191 (byte *)firstConfig.options + member.offset + member._class.offset,
3192 (byte *)nullOptions + member.offset + member._class.offset))
3196 if(!project.options) project.options = { };
3198 /*if(type.type == noHeadClass || type.type == normalClass)
3200 type._vTbl[__ecereVMethodID_class_OnCopy](type,
3201 (byte *)project.options + member.offset + member._class.offset,
3202 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
3206 void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
3207 // TOFIX: ListBox::SetData / OnCopy mess
3208 type._vTbl[__ecereVMethodID_class_OnCopy](type,
3209 (byte *)project.options + member.offset + member._class.offset,
3210 (type.typeSize > 4) ? address :
3211 ((type.typeSize == 4) ? (void *)*(uint32 *)address :
3212 ((type.typeSize == 2) ? (void *)*(uint16*)address :
3213 (void *)*(byte *)address )));
3216 (byte *)project.options + member.offset + member._class.offset,
3217 (byte *)firstConfig.options + member.offset + member._class.offset, type.typeSize);
3219 for(cfg : project.configurations)
3221 if(cfg.options.targetType == staticLibrary)
3225 if(type.type == noHeadClass || type.type == normalClass)
3227 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3228 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3229 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3233 result = type._vTbl[__ecereVMethodID_class_OnCompare](type,
3234 (byte *)firstConfig.options + member.offset + member._class.offset,
3235 (byte *)cfg.options + member.offset + member._class.offset);
3240 if(cfg != firstConfig)
3242 if(type.type == noHeadClass || type.type == normalClass)
3244 type._vTbl[__ecereVMethodID_class_OnFree](type,
3245 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3249 type._vTbl[__ecereVMethodID_class_OnFree](type,
3250 (byte *)cfg.options + member.offset + member._class.offset);
3252 memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
3255 memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
3262 // Compare Platform Specific Settings
3265 for(cfg : project.configurations)
3267 if(cfg != firstConfig && cfg.options.targetType != staticLibrary && (firstConfig.platforms || cfg.platforms) &&
3268 ((!firstConfig.platforms && cfg.platforms) || firstConfig.platforms.OnCompare(cfg.platforms)))
3274 if(same && firstConfig.platforms)
3276 for(cfg : project.configurations)
3278 if(cfg.options.targetType == staticLibrary && firstConfig.platforms.OnCompare(cfg.platforms))
3280 if(cfg != firstConfig)
3282 cfg.platforms.Free();
3283 delete cfg.platforms;
3286 project.platforms = firstConfig.platforms;
3287 firstConfig.platforms = null;
3291 // Static libraries can't contain libraries
3292 for(cfg : project.configurations)
3294 if(cfg.options.targetType == staticLibrary)
3296 if(!cfg.options.libraries) cfg.options.libraries = { };
3297 cfg.options.libraries.Free();
3303 Project LoadProject(char * filePath)
3305 Project project = null;
3306 File f = FileOpen(filePath, read);
3309 project = LegacyBinaryLoadProject(f, filePath);
3312 JSONParser parser { f = f };
3313 JSONResult result = parser.GetObject(class(Project), &project);
3316 char insidePath[MAX_LOCATION];
3318 delete project.topNode.files;
3319 if(!project.files) project.files = { };
3320 project.topNode.files = project.files;
3321 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
3322 delete project.resNode.path;
3323 project.resNode.path = project.resourcesPath;
3324 project.resourcesPath = null;
3325 project.resNode.nodeType = (ProjectNodeType)-1;
3326 delete project.resNode.files;
3327 project.resNode.files = project.resources;
3328 project.files = null;
3329 project.resources = null;
3330 if(!project.configurations) project.configurations = { };
3333 char topNodePath[MAX_LOCATION];
3334 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3335 MakeSlashPath(topNodePath);
3336 PathCatSlash(topNodePath, filePath);
3337 project.filePath = topNodePath;//filePath;
3340 project.topNode.FixupNode(insidePath);
3345 project = LegacyAsciiLoadProject(f, filePath);
3351 if(!project.options) project.options = { };
3352 if(!project.config && project.configurations)
3353 project.config = project.configurations.firstIterator.data;
3355 if(!project.resNode)
3357 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
3360 if(!project.moduleName)
3361 project.moduleName = CopyString(project.name);
3362 if(project.config &&
3363 (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
3364 (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
3366 //delete project.config.options.targetFileName;
3368 project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
3369 project.config.options.optimization = none;
3370 project.config.options.debug = true;
3371 //project.config.options.warnings = unset;
3372 project.config.options.memoryGuard = false;
3373 project.config.compilingModified = true;
3374 project.config.linkingModified = true;
3376 else if(!project.topNode.name && project.config)
3378 project.topNode.name = CopyString(project.config.options.targetFileName);
3381 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
3382 project.topNode.configurations = project.configurations;
3383 project.topNode.platforms = project.platforms;
3384 project.topNode.options = project.options;*/