2 public import static "ecere"
9 #ifndef MAKEFILE_GENERATOR
11 // We should have the .sln/.vcproj generation even on other platforms
12 // e.g. detect from an environment variable pointing to a Windows drive
18 import "ProjectConfig"
24 static void DummyFunction()
32 extern int __ecereVMethodID_class_OnCompare;
33 extern int __ecereVMethodID_class_OnFree;
35 IDESettings ideSettings;
37 IDESettingsContainer settingsContainer
40 dataOwner = &ideSettings;
41 dataClass = class(IDESettings);
43 void OnLoad(GlobalSettingsData data)
45 IDESettings settings = (IDESettings)data;
46 #ifndef MAKEFILE_GENERATOR
47 globalSettingsDialog.ideSettings = settings;
48 ide.UpdateRecentMenus();
49 ide.UpdateCompilerConfigs(true);
54 #ifdef MAKEFILE_GENERATOR
55 CompilerConfig defaultCompiler;
58 // LEGACY BINARY EPJ LOADING
60 SetBool ParseTrueFalseValue(char * string)
62 if(!strcmpi(string, "True")) return true;
66 void ParseArrayValue(Array<String> array, char * equal)
68 char * start, * comma;
70 string = CopyString(equal);
74 comma = strstr(start, ",");
77 array.Add(CopyString(start));
87 void ProjectNode::LegacyBinaryLoadNode(File f)
92 f.Read(&len, sizeof(len), 1);
93 name = new char[len+1];
95 f.Read(name, sizeof(char), len+1);
96 f.Read(&len, sizeof(len), 1);
98 path = new char[len+1];
99 f.Read(path, sizeof(char), len+1);
102 fileName = new char[fileNameLen+2];
103 strcpy(fileName, path);
104 if(fileName[0]) strcat(fileName, "/");
105 strcat(fileName, name);
108 f.Read(&type, sizeof(type), 1);
109 f.Read(&count, sizeof(count), 1);
114 icon = NodeIcons::SelectFileIcon(name);
119 icon = NodeIcons::SelectNodeIcon(type);
122 if(count && !files) files = { };
123 for(c = 0; c < count; c++)
125 ProjectNode child { };
128 child.indent = indent + 1;
129 LegacyBinaryLoadNode(child, f);
133 /*void LegacyBinarySaveNode(File f)
138 f.Write(&len, sizeof(len), 1);
139 f.Write(name, sizeof(char), len+1);
143 // Projects Absolute Path Are Not Saved
145 f.Write(&len, sizeof(len), 1);
146 f.Write(&len, sizeof(char), 1);
151 f.Write(&len, sizeof(len), 1);
152 f.Write(path, sizeof(char), len+1);
154 f.Write(&type, sizeof(type), 1);
155 f.Write(&children.count, sizeof(children.count), 1);
156 for(child = children.first; child; child.next)
160 void ProjectNode::LegacyAsciiSaveNode(File f, char * indentation, char * insidePath)
163 char printPath[MAX_LOCATION];
165 if(type == project && (files.count /*|| preprocessorDefs.first*/))
167 f.Printf("\n Files\n");
169 else if(type == file)
171 if(!strcmp(path, insidePath))
172 f.Printf("%s - %s\n", indentation, name);
175 strcpy(printPath, path);
176 len = strlen(printPath);
178 if(printPath[len-1] != '/')
179 strcat(printPath, "/");
180 strcat(printPath, name);
181 f.Printf("%s = %s\n", indentation, printPath);
184 f.Printf("\nError\n\n");
186 else if(type == folder)
188 f.Printf("%s + %s\n", indentation, name);
190 else if(type == resources && files.count)
192 PathCatSlash(insidePath, path);
193 f.Printf("\n%sResources\n", indentation);
195 f.Printf("%s Path = %s\n", indentation, path);
198 /*if(buildExclusions.first && type != project)
200 for(item = buildExclusions.first; item; item = item.next)
202 if(item == buildExclusions.first)
203 f.Printf("%s Build Exclusions = %s", indentation, item.name);
205 f.Printf(", %s", item.name);
210 if(preprocessorDefs.first && (type == project || ((type == file || type == folder) && !isInResources)))
212 for(item = preprocessorDefs.first; item; item = item.next)
214 if(item == preprocessorDefs.first)
215 f.Printf("%s%s Preprocessor Definitions = %s", indentation, type == project ? "" : " ", item.name);
217 f.Printf(", %s", item.name);
223 if(type == project && (files.count /*|| preprocessorDefs.first*/))
227 LegacyAsciiSaveNode(child, f, indentation, insidePath);
229 else if(type == folder)
231 strcat(indentation, " ");
232 // WHAT WAS THIS: strcpy(printPath, path);
233 // TOCHECK: why is Unix/PathCat not used here
234 len = strlen(insidePath);
236 if(insidePath[len-1] != '/')
237 strcat(insidePath, "/");
238 strcat(insidePath, name);
241 LegacyAsciiSaveNode(child, f, indentation, insidePath);
242 f.Printf("%s -\n", indentation);
243 indentation[strlen(indentation) - 3] = '\0';
244 StripLastDirectory(insidePath, insidePath);
246 else if(type == resources && files.count)
250 LegacyAsciiSaveNode(child, f, indentation, insidePath);
251 StripLastDirectory(insidePath, insidePath);
256 void ProjectConfig::LegacyProjectConfigSave(File f)
258 char * indentation = " ";
260 //f.Printf("\n * Common\n");
262 f.Printf("\n + %s\n", name);
263 f.Printf("\n Compiler\n\n");
264 if(objDir.expression[0])
265 f.Printf("%sIntermediate Directory = %s\n", indentation, objDir.expression);
266 f.Printf("%sDebug = %s\n", indentation, (options.debug == true) ? "True" : "False");
267 switch(options.optimization)
269 // case none: f.Printf("%sOptimize = %s\n", indentation, "None"); break;
270 case speed: f.Printf("%sOptimize = %s\n", indentation, "Speed"); break;
271 case size: f.Printf("%sOptimize = %s\n", indentation, "Size"); break;
273 f.Printf("%sAllWarnings = %s\n", indentation, (options.warnings == all) ? "True" : "False");
275 f.Printf("%sProfile = %s\n", indentation, (options.profile == true) ? "True" : "False");
276 if(options.memoryGuard == true)
277 f.Printf("%sMemoryGuard = %s\n", indentation, (options.memoryGuard == true) ? "True" : "False");
278 if(options.strictNameSpaces == true)
279 f.Printf("%sStrict Name Spaces = %s\n", indentation, (options.strictNameSpaces == true) ? "True" : "False");
280 if(options.defaultNameSpace && strlen(options.defaultNameSpace))
281 f.Printf("%sDefault Name Space = %s\n", indentation, options.defaultNameSpace);
282 TOFIX: Compiler Bug {
283 if(options.preprocessorDefinitions.count)
286 for(item : options.preprocessorDefinitions)
290 f.Printf("\n%sPreprocessor Definitions = %s", indentation, item);
294 f.Printf(", %s", item);
299 if(options.includeDirs.count)
301 f.Printf("\n%sInclude Directories\n", indentation);
302 for(item : options.includeDirs)
303 f.Printf("%s - %s\n", indentation, name);
307 f.Printf("\n%sLinker\n\n", indentation);
308 f.Printf("%sTarget Name = %s\n", indentation, options.targetFileName);
309 switch(options.targetType)
311 case executable: f.Printf("%sTarget Type = %s\n", indentation, "Executable"); break;
312 case sharedLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Shared"); break;
313 case staticLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Static"); break;
315 if(targetDir.expression[0])
316 f.Printf("%sTarget Directory = %s\n", indentation, targetDir.expression);
318 f.Printf("%sConsole = %s\n", indentation, options.console ? "True" : "False");
320 f.Printf("%sCompress = %s\n", indentation, options.compress ? "True" : "False");
321 if(options.libraries.count)
324 for(item : options.libraries)
328 f.Printf("\n%sLibraries = %s", indentation, name);
332 f.Printf(", %s", item);
336 if(options.libraryDirs.count)
338 f.Printf("\n%sLibrary Directories\n\n", indentation);
339 for(item : options.libraryDirs)
340 f.Printf(" - %s\n", indentation, item);
344 void LegacyAsciiSaveProject(File f, Project project)
346 char indentation[128*3];
347 char path[MAX_LOCATION];
349 f.Printf("\nECERE Project File : Format Version 0.1b\n");
350 f.Printf("\nDescription\n%s\n.\n", project.description);
351 f.Printf("\nLicense\n%s\n.\n", project.license);
352 f.Printf("\nModule Name = %s\n", project.moduleName);
353 f.Printf("\n Configurations\n");
354 //////////////////////////////////////commonConfig.Save(f, true);
355 for(cfg : project.configurations)
356 LegacyProjectConfigSave(cfg, f);
358 strcpy(indentation, " ");
360 LegacyAsciiSaveNode(project.topNode, f, indentation, path);
366 // *** NEW JSON PROJECT FORMAT ***
367 public enum ProjectNodeType { file, folder };
369 // *******************************
371 define PEEK_RESOLUTION = (18.2 * 10);
377 static Array<String> notLinkerOptions
399 static bool IsLinkerOption(String s)
401 for(i : notLinkerOptions)
402 if(strstr(s, "-Wl,") || !strcmp(s, i))
407 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
409 enum GenMakefilePrintTypes { objects, cObjects, symbols, imports, sources, resources, eCsources };
411 define WorkspaceExtension = "ews";
412 define ProjectExtension = "epj";
414 define stringInFileIncludedFrom = "In file included from ";
415 define stringFrom = " from ";
417 // This function cannot accept same pointer for source and output
418 void ReplaceSpaces(char * output, char * source)
423 for(c = 0, dc = 0; (ch = source[c]); c++, dc++)
425 if(ch == ' ') output[dc++] = '\\';
428 if(ch == '(' || ch == ')') output[dc++] = '\\';
438 // This function cannot accept same pointer for source and output
439 void ReplaceUnwantedMakeChars(char * output, char * source)
444 for(c = 0, dc = 0; (ch = source[c]); c++, dc++)
448 if(ch == '(' || ch == ')') output[dc++] = '\\';
461 static void OutputNoSpace(File f, char * source)
463 char * output = new char[strlen(source)+1024];
464 ReplaceSpaces(output, source);
469 enum ListOutputMethod { inPlace, newLine, lineEach };
471 int OutputFileList(File f, char * name, Array<String> list, Map<String, int> varStringLenDiffs, char * prefix)
474 const int breakListLength = 1536;
475 const int breakLineLength = 78; // TODO: turn this into an option.
477 int c, len, itemCount = 0;
478 Array<int> breaks { };
482 MapNode<String, int> mn;
483 for(c=0; c<list.count; c++)
485 len = strlen(list[c]) + 3;
486 if(strstr(list[c], "$(") && varStringLenDiffs && varStringLenDiffs.count)
488 for(mn = varStringLenDiffs.root.minimum; mn; mn = mn.next)
490 if(strstr(list[c], mn.key))
494 if(charCount + len > breakListLength)
496 breaks.Add(itemCount);
504 breaks.Add(itemCount);
505 numOfBreaks = breaks.count;
510 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
511 for(c=0; c<numOfBreaks; c++)
512 f.Printf(" $(%s%d)", name, c+1);
516 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
522 for(c=0; c<numOfBreaks; c++)
525 f.Printf("%s%d =", name, c+1);
528 itemCount = breaks[c];
529 for(n=offset; n<offset+itemCount; n++)
531 if(false) // TODO: turn this into an option.
533 int itemLen = strlen(list[n]);
534 if(len > 3 && len + itemLen > breakLineLength)
536 f.Printf(" \\\n\t%s", list[n]);
542 f.Printf(" %s", list[n]);
546 f.Printf(" \\\n\t%s", list[n]);
561 void OutputLinkObjectActions(File f, char * name, int parts)
566 for(c=0; c<parts; c++)
567 f.Printf("\t@$(call echo,$(%s%d)) >> $(OBJ)linkobjects.lst\n", name, c+1);
569 f.Printf("\t@$(call echo,$(%s)) >> $(OBJ)linkobjects.lst\n", name);
573 void OutputCleanActions(File f, char * name, int parts)
578 for(c=0; c<parts; c++)
579 f.Printf("\t$(call rmq,$(%s%d))\n", name, c+1);
582 f.Printf("\t$(call rmq,$(%s))\n", name);
585 void OutputListOption(File f, char * option, Array<String> list, ListOutputMethod method, bool noSpace)
589 if(method == newLine)
593 if(method == lineEach)
595 f.Printf(" -%s", option);
597 OutputNoSpace(f, item);
599 f.Printf("%s", item);
604 void StringNoSpaceToDynamicString(DynamicString s, char * path)
606 char * output = new char[strlen(path)+1024];
607 ReplaceSpaces(output, path);
612 static void OutputLibraries(File f, Array<String> libraries)
614 for(item : libraries)
616 char ext[MAX_EXTENSION];
617 char temp[MAX_LOCATION];
619 bool usedFunction = false;
620 GetExtension(item, ext);
621 if(!strcmp(ext, "o") || !strcmp(ext, "a"))
625 if(!strcmp(ext, "so") || !strcmp(ext, "dylib"))
627 if(!strncmp(item, "lib", 3))
628 strcpy(temp, item + 3);
631 StripExtension(temp);
634 f.Puts(" \\\n\t$(call _L,");
643 void CamelCase(char * string)
645 int c, len = strlen(string);
646 for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
647 string[c] = (char)tolower(string[c]);
650 CompilerConfig GetCompilerConfig()
652 #ifndef MAKEFILE_GENERATOR
653 CompilerConfig compiler = null;
654 if(ide && ide.workspace)
655 compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
658 incref defaultCompiler;
659 return defaultCompiler;
663 define localTargetType = config && config.options && config.options.targetType ?
664 config.options.targetType : options && options.targetType ?
665 options.targetType : TargetTypes::executable;
666 define localWarnings = config && config.options && config.options.warnings ?
667 config.options.warnings : options && options.warnings ?
668 options.warnings : WarningsOption::unset;
669 define localDebug = config && config.options && config.options.debug ?
670 config.options.debug : options && options.debug ?
671 options.debug : SetBool::unset;
672 define localMemoryGuard = config && config.options && config.options.memoryGuard ?
673 config.options.memoryGuard : options && options.memoryGuard ?
674 options.memoryGuard : SetBool::unset;
675 define localNoLineNumbers = config && config.options && config.options.noLineNumbers ?
676 config.options.noLineNumbers : options && options.noLineNumbers ?
677 options.noLineNumbers : SetBool::unset;
678 define localProfile = config && config.options && config.options.profile ?
679 config.options.profile : options && options.profile ?
680 options.profile : SetBool::unset;
681 define localOptimization = config && config.options && config.options.optimization ?
682 config.options.optimization : options && options.optimization ?
683 options.optimization : OptimizationStrategy::none;
684 define localFastMath = config && config.options && config.options.fastMath ?
685 config.options.fastMath : options && options.fastMath ?
686 options.fastMath : SetBool::unset;
687 define localDefaultNameSpace = config && config.options && config.options.defaultNameSpace ?
688 config.options.defaultNameSpace : options && options.defaultNameSpace ?
689 options.defaultNameSpace : null;
690 define localStrictNameSpaces = config && config.options && config.options.strictNameSpaces ?
691 config.options.strictNameSpaces : options && options.strictNameSpaces ?
692 options.strictNameSpaces : SetBool::unset;
693 // TODO: I would rather have null here, check if it'll be ok, have the property return "" if required
694 define localTargetFileName = config && config.options && config.options.targetFileName ?
695 config.options.targetFileName : options && options.targetFileName ?
696 options.targetFileName : "";
697 define localTargetDirectory = config && config.options && config.options.targetDirectory && config.options.targetDirectory[0] ?
698 config.options.targetDirectory : options && options.targetDirectory && options.targetDirectory[0] ?
699 options.targetDirectory : null;
700 define settingsTargetDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
701 ideSettings.projectDefaultIntermediateObjDir[0] ?
702 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
703 define localObjectsDirectory = config && config.options && config.options.objectsDirectory && config.options.objectsDirectory[0] ?
704 config.options.objectsDirectory : options && options.objectsDirectory && options.objectsDirectory[0] ?
705 options.objectsDirectory : null;
706 define settingsObjectsDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
707 ideSettings.projectDefaultIntermediateObjDir[0] ?
708 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
709 define localConsole = config && config.options && config.options.console ?
710 config.options.console : options && options.console ?
711 options.console : SetBool::unset;
712 define localCompress = config && config.options && config.options.compress ?
713 config.options.compress : options && options.compress ?
714 options.compress : SetBool::unset;
716 define platformTargetType =
717 configPOs && configPOs.options && configPOs.options.targetType && configPOs.options.targetType != localTargetType ?
718 configPOs.options.targetType :
719 projectPOs && projectPOs.options && projectPOs.options.targetType && projectPOs.options.targetType != localTargetType ?
720 projectPOs.options.targetType : TargetTypes::unset;
723 char * PlatformToMakefileTargetVariable(Platform platform)
725 return platform == win32 ? "WINDOWS_TARGET" :
726 platform == tux ? "LINUX_TARGET" :
727 platform == apple ? "OSX_TARGET" :
731 char * TargetTypeToMakefileVariable(TargetTypes targetType)
733 return targetType == executable ? "executable" :
734 targetType == sharedLibrary ? "sharedlib" :
735 targetType == staticLibrary ? "staticlib" :
739 // Move this to ProjectConfig? null vs Common to consider...
740 char * GetConfigName(ProjectConfig config)
742 return config ? config.name : "Common";
745 public enum SingleFileCompileMode { normal, debugPrecompile, debugCompile, debugGenerateSymbols, cObject };
747 class Project : struct
749 class_no_expansion; // To use Find on the Container<Project> in Workspace::projects
750 // We might want to tweak this default behavior of regular classes ?
751 // Expansion/the current default kind of Find matching we want for things like BitmapResource, FontResource (Also regular classes)
756 property char * moduleVersion
758 set { delete moduleVersion; if(value && value[0]) moduleVersion = CopyString(value); } // TODO: use CopyString function that filters chars
759 get { return moduleVersion ? moduleVersion : ""; } // version number should only use digits and dots
760 isset { return moduleVersion != null && moduleVersion[0]; } // add leading/trailing 0 if value start/ends with dot(s)
763 property char * description
765 set { delete description; if(value && value[0]) description = CopyString(value); }
766 get { return description ? description : ""; }
767 isset { return description != null && description[0]; }
770 property char * license
772 set { delete license; if(value && value[0]) license = CopyString(value); }
773 get { return license ? license : ""; }
774 isset { return license != null && license[0]; }
777 property char * compilerConfigsDir
779 set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
780 get { return compilerConfigsDir ? compilerConfigsDir : ""; }
781 isset { return compilerConfigsDir && compilerConfigsDir[0]; }
784 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
785 property Array<PlatformOptions> platforms
787 get { return platforms; }
790 if(platforms) { platforms.Free(); delete platforms; }
793 List<PlatformOptions> empty { };
794 Iterator<PlatformOptions> it { value };
796 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
797 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
807 if(p.options && !p.options.isEmpty)
814 List<ProjectConfig> configurations;
815 LinkList<ProjectNode> files;
816 String resourcesPath;
817 LinkList<ProjectNode> resources;
820 // topNode.name holds the file name (.epj)
821 ProjectOptions options;
822 Array<PlatformOptions> platforms;
823 ProjectNode topNode { type = project, icon = epjFile, files = LinkList<ProjectNode>{ }, project = this };
826 ProjectConfig config;
828 // This is the file name stripped of the epj extension
829 // It should NOT be edited, saved or loaded anywhere
834 String compilerConfigsDir;
835 String moduleVersion;
837 #ifndef MAKEFILE_GENERATOR
838 FileMonitor fileMonitor
840 this, FileChange { modified = true };
841 bool OnFileNotify(FileChange action, char * param)
843 fileMonitor.StopMonitoring();
844 if(OnProjectModified(action, param))
845 fileMonitor.StartMonitoring();
850 bool StartMonitoring()
852 fileMonitor.fileName = filePath;
853 fileMonitor.StartMonitoring();
857 bool StopMonitoring()
859 fileMonitor.StopMonitoring();
863 bool OnProjectModified(FileChange fileChange, char * param)
866 sprintf(temp, $"The project %s was modified by another application.\n"
867 "Would you like to reload it and lose your changes?", name);
868 if(MessageBox { type = yesNo, master = ide,
869 text = $"Project has been modified", contents = temp }.Modal() == yes)
871 Project project = LoadProject(filePath, config.name);
874 ProjectView projectView = ide.projectView;
875 DataRow prev = topNode.row ? topNode.row.previous : null;
876 FileMonitor fm = fileMonitor;
877 bool confirmation = true;
881 if(projectView.projectSettingsDialog)
883 confirmation = projectView.projectSettingsDialog.CloseConfirmation(true);
885 projectView.projectSettingsDialog.Destroy(0);
888 projectView.DeleteNode(topNode);
895 topNode.project = this;
899 CompilerConfig compiler = ideSettings.GetCompilerConfig(projectView.workspace.compiler);
900 projectView.AddNode(topNode, null);
901 topNode.row.Move(prev);
903 projectView.ShowOutputBuildLog(true);
904 projectView.DisplayCompiler(compiler, false);
905 projectView.ProjectUpdateMakefileForAllConfigs(this);
908 eSystem_Delete(project);
920 // This frees contents without freeing the instance
921 // For use from destructor and for file monitor reloading
922 // (To work around JSON loader (LoadProject) always returning a new instance)
925 if(platforms) { platforms.Free(); delete platforms; }
926 if(configurations) { configurations.Free(); delete configurations; }
927 if(files) { files.Free(); delete files; }
928 if(resources) { resources.Free(); delete resources; }
930 delete resourcesPath;
934 delete compilerConfigsDir;
936 delete moduleVersion;
944 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
945 topNode.configurations = null;
946 topNode.platforms = null;
947 topNode.options = null;
952 property ProjectConfig config
958 topNode.info = CopyString(GetConfigName(config));
961 property char * filePath
967 char string[MAX_LOCATION];
968 GetLastDirectory(value, string);
970 topNode.name = CopyString(string);
971 StripExtension(string);
973 name = CopyString(string);
974 StripLastDirectory(value, string);
976 topNode.path = CopyString(string);
978 filePath = CopyString(value);
983 TargetTypes GetTargetType(ProjectConfig config)
985 TargetTypes targetType = localTargetType;
989 bool GetTargetTypeIsSetByPlatform(ProjectConfig config)
992 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
994 PlatformOptions projectPOs, configPOs;
995 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
996 if(platformTargetType)
1003 char * GetObjDirExpression(ProjectConfig config)
1005 // TODO: Support platform options
1006 char * expression = localObjectsDirectory;
1008 expression = settingsObjectsDirectory;
1012 DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1014 char * expression = GetObjDirExpression(config);
1015 DirExpression objDir { type = intermediateObjectsDir };
1016 objDir.Evaluate(expression, this, compiler, config, bitDepth);
1020 char * GetTargetDirExpression(ProjectConfig config)
1022 // TODO: Support platform options
1023 char * expression = localTargetDirectory;
1025 expression = settingsTargetDirectory;
1029 DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1031 char * expression = GetTargetDirExpression(config);
1032 DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
1033 targetDir.Evaluate(expression, this, compiler, config, bitDepth);
1037 WarningsOption GetWarnings(ProjectConfig config)
1039 WarningsOption warnings = localWarnings;
1043 bool GetDebug(ProjectConfig config)
1045 SetBool debug = localDebug;
1046 return debug == true;
1049 bool GetMemoryGuard(ProjectConfig config)
1051 SetBool memoryGuard = localMemoryGuard;
1052 return memoryGuard == true;
1055 bool GetNoLineNumbers(ProjectConfig config)
1057 SetBool noLineNumbers = localNoLineNumbers;
1058 return noLineNumbers == true;
1061 bool GetProfile(ProjectConfig config)
1063 SetBool profile = localProfile;
1064 return profile == true;
1067 OptimizationStrategy GetOptimization(ProjectConfig config)
1069 OptimizationStrategy optimization = localOptimization;
1070 return optimization;
1073 bool GetFastMath(ProjectConfig config)
1075 SetBool fastMath = localFastMath;
1076 return fastMath == true;
1079 String GetDefaultNameSpace(ProjectConfig config)
1081 String defaultNameSpace = localDefaultNameSpace;
1082 return defaultNameSpace;
1085 bool GetStrictNameSpaces(ProjectConfig config)
1087 SetBool strictNameSpaces = localStrictNameSpaces;
1088 return strictNameSpaces == true;
1091 String GetTargetFileName(ProjectConfig config)
1093 String targetFileName = localTargetFileName;
1094 return targetFileName;
1097 //String targetDirectory;
1098 //String objectsDirectory;
1099 bool GetConsole(ProjectConfig config)
1101 SetBool console = localConsole;
1102 return console == true;
1105 bool GetCompress(ProjectConfig config)
1107 SetBool compress = localCompress;
1108 return compress == true;
1110 //SetBool excludeFromBuild;
1112 bool GetConfigIsInActiveDebugSession(ProjectConfig config)
1114 #ifndef MAKEFILE_GENERATOR
1115 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
1119 bool GetConfigIsInDebugSession(ProjectConfig config)
1121 #ifndef MAKEFILE_GENERATOR
1122 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
1126 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
1128 #ifndef MAKEFILE_GENERATOR
1129 ide.SetPath(projectsDirs, compiler, config, bitDepth);
1133 #ifndef MAKEFILE_GENERATOR
1134 bool Save(char * fileName)
1137 /*char output[MAX_LOCATION];
1138 ChangeExtension(fileName, "json", output);
1139 f = FileOpen(output, write);*/
1140 f = FileOpen(fileName, write);
1143 files = topNode.files;
1144 resources = resNode.files;
1145 resourcesPath = resNode.path;
1147 files.Remove(resNode);
1150 WriteJSONObject(f, class(Project), this, 0);
1156 resourcesPath = null;
1163 // This method is only called from Debugger, should be moved to Debugger class?
1164 #ifndef MAKEFILE_GENERATOR
1165 bool GetRelativePath(char * filePath, char * relativePath)
1168 char moduleName[MAX_FILENAME];
1169 GetLastDirectory(filePath, moduleName);
1170 // try with workspace dir first?
1171 if((node = topNode.Find(moduleName, false)))
1173 strcpy(relativePath, strcmp(node.path, ".") ? node.path : "");
1174 PathCatSlash(relativePath, node.name);
1179 // Tweak for automatically resolving symbol loader modules
1180 char * sl = strstr(moduleName, ".main.ec");
1181 if(sl && (*sl = 0, !strcmpi(moduleName, name)))
1183 char objDir[MAX_LOCATION];
1184 DirExpression objDirExp;
1185 CompilerConfig compiler = ide.debugger.currentCompiler;
1186 ProjectConfig config = ide.debugger.prjConfig;
1187 int bitDepth = ide.debugger.bitDepth;
1188 // This is not perfect, as multiple source files exist for the symbol loader module...
1189 // We try to set it in the debug config object directory.
1190 if(!compiler || !config)
1192 // If we're not currently debugging, set a breakpoint in the active compiler/config
1193 compiler = GetCompilerConfig();
1194 config = this.config;
1195 // If the current config is not debuggable, set it in the first debuggable config found
1196 if(config && !config.options.debug)
1198 for(c : configurations; c.options.debug)
1205 objDirExp = GetObjDir(compiler, config, bitDepth);
1206 strcpy(objDir, objDirExp.dir);
1208 ChangeCh(objDir, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
1209 ReplaceSpaces(relativePath, objDir);
1211 PathCatSlash(relativePath, moduleName);
1215 // WARNING: On failure, relative path is uninitialized
1220 void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
1222 TargetTypes targetType = GetTargetType(config);
1223 String targetFileName = GetTargetFileName(config);
1224 if(targetType == staticLibrary)
1226 PathCatSlash(string, "lib");
1227 strcat(string, targetFileName);
1229 else if(compiler.targetPlatform != win32 && targetType == sharedLibrary)
1231 PathCatSlash(string, "lib");
1232 strcat(string, targetFileName);
1235 PathCatSlash(string, targetFileName);
1240 if(compiler.targetPlatform == win32)
1241 strcat(string, ".exe");
1244 if(compiler.targetPlatform == win32)
1245 strcat(string, ".dll");
1246 else if(compiler.targetPlatform == apple)
1247 strcat(string, ".dylib");
1249 strcat(string, ".so");
1250 if(compiler.targetPlatform == tux && GetRuntimePlatform() == tux && moduleVersion && moduleVersion[0])
1252 strcat(string, ".");
1253 strcat(string, moduleVersion);
1257 strcat(string, ".a");
1262 bool GetProjectCompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1264 bool result = false;
1265 char temp[MAX_LOCATION];
1266 strcpy(cfDir, topNode.path);
1267 if(compilerConfigsDir && compilerConfigsDir[0])
1269 PathCatSlash(cfDir, compilerConfigsDir);
1274 strcpy(temp, cfDir);
1275 // Using a relative path makes it less likely to run into spaces issues
1276 // Even with escaped spaces, there still seems to be issues including a config file
1277 // in a path containing spaces
1279 MakePathRelative(temp, topNode.path, cfDir);
1282 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1286 strcpy(temp, cfDir);
1287 ReplaceSpaces(cfDir, temp);
1292 bool GetIDECompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1294 char temp[MAX_LOCATION];
1295 bool result = false;
1296 strcpy(cfDir, topNode.path);
1297 if(ideSettings && ideSettings.compilerConfigsDir && ideSettings.compilerConfigsDir[0])
1299 PathCatSlash(cfDir, ideSettings.compilerConfigsDir);
1304 // Default to <ProjectDir>/.configs if unset
1305 PathCatSlash(cfDir, ".configs");
1310 strcpy(temp, cfDir);
1311 // Using a relative path makes it less likely to run into spaces issues
1312 // Even with escaped spaces, there still seems to be issues including a config file
1313 // in a path containing spaces
1314 if(IsPathInsideOf(cfDir, topNode.path))
1315 MakePathRelative(temp, topNode.path, cfDir);
1317 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1321 strcpy(temp, cfDir);
1322 ReplaceSpaces(cfDir, temp);
1327 void CatMakeFileName(char * string, ProjectConfig config)
1329 char projectName[MAX_LOCATION];
1330 strcpy(projectName, name);
1331 sprintf(string, "%s%s%s.Makefile", projectName, config ? "-" : "", config ? config.name : "");
1334 #ifndef MAKEFILE_GENERATOR
1335 void MarkChanges(ProjectNode node)
1337 for(cfg : topNode.configurations)
1339 ProjectConfig c = null;
1340 for(i : node.configurations; !strcmpi(i.name, cfg.name)) { c = i; break; }
1342 if(c && ((c.options && cfg.options && cfg.options.console != c.options.console) ||
1343 (!c.options || !cfg.options)))
1344 cfg.symbolGenModified = true;
1345 if(c && ((c.options && cfg.options &&
1346 ( (cfg.options.libraries && c.options.libraries && cfg.options.libraries.OnCompare(c.options.libraries)) || (!cfg.options.libraries || !c.options.libraries)) )
1347 || (!c.options || !cfg.options)))
1348 cfg.linkingModified = true;
1350 cfg.makingModified = true;
1354 void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
1356 for(cfg : configurations)
1359 cfg.makingModified = true;
1361 cfg.compilingModified = true;
1363 cfg.linkingModified = true;
1365 cfg.symbolGenModified = true;
1367 if(compiling || linking)
1369 ide.projectView.modifiedDocument = true;
1370 ide.workspace.modified = true;
1374 void RotateActiveConfig(bool forward)
1376 if(configurations.first && configurations.last != configurations.first)
1378 Iterator<ProjectConfig> cfg { configurations };
1379 while(forward ? cfg.Next() : cfg.Prev())
1380 if(cfg.data == config)
1394 property::config = cfg.data;
1395 ide.UpdateToolBarActiveConfigs(true);
1396 ide.workspace.modified = true;
1397 ide.projectView.Update(null);
1401 void ProcessPipeOutputRaw(DualPipe f)
1404 while(!f.Eof() && !ide.ShouldStopBuild())
1407 double lastTime = GetTime();
1411 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1413 ide.outputView.buildBox.Logf("%s\n", line);
1415 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1417 //printf("Processing Input...\n");
1418 if(app.ProcessInput(true))
1420 app.UpdateDisplay();
1423 //printf("Waiting...\n");
1426 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1428 if(ide.ShouldStopBuild())
1430 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1435 bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, bool isARun, List<ProjectNode> onlyNodes,
1436 CompilerConfig compiler, ProjectConfig config, int bitDepth)
1439 bool compiling = false, linking = false, precompiling = false;
1440 int compilingEC = 0;
1441 int numErrors = 0, numWarnings = 0;
1442 bool loggedALine = false;
1443 char * configName = config ? config.name : "Common";
1444 int lenMakeCommand = strlen(compiler.makeCommand);
1447 char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
1449 DynamicString test { };
1450 DynamicString ecp { };
1451 DynamicString ecc { };
1452 DynamicString ecs { };
1453 DynamicString ear { };
1454 DynamicString prefix { };
1455 DynamicString cpp { };
1456 DynamicString cc { };
1457 DynamicString cxx { };
1458 DynamicString strip { };
1459 DynamicString ar { };
1461 if(bitDepth == 64 && compiler.targetPlatform == win32)
1462 gnuToolchainPrefix = "x86_64-w64-mingw32-";
1463 else if(bitDepth == 32 && compiler.targetPlatform == win32)
1464 gnuToolchainPrefix = "i686-w64-mingw32-";
1466 ecp.concatx(compiler.ecpCommand, " ");
1467 ecc.concatx(compiler.eccCommand, " ");
1468 ecs.concatx(compiler.ecsCommand, " ");
1469 ear.concatx(compiler.earCommand, " ");
1472 compiler.ccacheEnabled ? "ccache " : "",
1473 compiler.distccEnabled ? "distcc " : "",
1474 gnuToolchainPrefix);
1476 cpp.concatx((String)prefix, compiler.cppCommand, " ");
1477 cc.concatx((String)prefix, compiler.ccCommand, " ");
1478 cxx.concatx((String)prefix, compiler.cxxCommand, " ");
1480 strip.concatx(gnuToolchainPrefix, "strip ");
1481 ar.concatx(gnuToolchainPrefix, "ar rcs");
1483 testLen = Max(testLen, ecp.size);
1484 testLen = Max(testLen, ecc.size);
1485 testLen = Max(testLen, ecs.size);
1486 testLen = Max(testLen, ear.size);
1487 testLen = Max(testLen, cpp.size);
1488 testLen = Max(testLen, cc.size);
1489 testLen = Max(testLen, cxx.size);
1490 testLen = Max(testLen, strip.size);
1491 testLen = Max(testLen, ar.size);
1494 while(!f.Eof() && !ide.ShouldStopBuild())
1497 double lastTime = GetTime();
1501 //printf("Peeking and GetLine...\n");
1502 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1504 char * message = null;
1505 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1506 char * from = strstr(line, stringFrom);
1507 test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
1508 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
1510 char * module = strstr(line, "No rule to make target `");
1514 module = strchr(module, '`') + 1;
1515 end = strchr(module, '\'');
1519 ide.outputView.buildBox.Logf($" %s: No such file or directory\n", module);
1520 // ide.outputView.buildBox.Logf("error: %s\n No such file or directory\n", module);
1526 //ide.outputView.buildBox.Logf("error: %s\n", line);
1530 else if(strstr(test, ear) == test);
1531 else if(strstr(test, strip) == test);
1532 else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
1534 char moduleName[MAX_FILENAME];
1537 bool isPrecomp = false;
1540 if(strstr(test, cc) == test || strstr(test, cxx) == test)
1542 module = strstr(line, " -c ");
1543 if(module) module += 4;
1546 else if(strstr(test, ecc) == test)
1548 module = strstr(line, " -c ");
1549 if(module) module += 4;
1550 //module = line + 3;
1551 // Don't show GCC warnings about generated C code because it does not compile clean yet...
1552 compilingEC = 3;//2;
1555 else if(strstr(test, ecp) == test)
1557 // module = line + 8;
1558 module = strstr(line, " -c ");
1559 if(module) module += 4;
1569 if(!compiling && !isPrecomp)
1571 ide.outputView.buildBox.Logf($"Compiling...\n");
1574 else if(!precompiling && isPrecomp)
1576 ide.outputView.buildBox.Logf($"Generating symbols...\n");
1577 precompiling = true;
1579 // Changed escapeBackSlashes here to handle paths with spaces
1580 Tokenize(module, 1, tokens, true); // false);
1581 GetLastDirectory(module, moduleName);
1582 ide.outputView.buildBox.Logf("%s\n", moduleName);
1584 else if((module = strstr(line, " -o ")))
1587 precompiling = false;
1589 ide.outputView.buildBox.Logf($"Linking...\n");
1593 ide.outputView.buildBox.Logf("%s\n", line);
1594 if(strstr(line, "warning:") || strstr(line, "note:"))
1596 else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
1600 if(compilingEC) compilingEC--;
1602 else if(strstr(test, ar) == test)
1603 ide.outputView.buildBox.Logf($"Building library...\n");
1604 else if(strstr(test, ecs) == test)
1605 ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
1608 if(linking || compiling || precompiling)
1610 char * colon = strstr(line, ":"); //, * bracket;
1611 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1612 colon = strstr(colon + 1, ":");
1615 char * sayError = "";
1616 char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
1619 char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
1620 int len = (int)(colon - start);
1621 char ext[MAX_EXTENSION];
1622 len = Min(len, MAX_LOCATION-1);
1623 // Don't be mistaken by the drive letter colon
1625 // TODO: need to fix colon - line gives char *
1626 // warning: incompatible expression colon - line (char *); expected int
1628 strncpy(moduleName, line, (int)(colon - line));
1629 moduleName[colon - line] = '\0';
1631 strncpy(moduleName, start, len);
1632 moduleName[len] = '\0';
1633 // Remove stuff in brackets
1634 //bracket = strstr(moduleName, "(");
1635 //if(bracket) *bracket = '\0';
1637 GetLastDirectory(moduleName, temp);
1638 GetExtension(temp, ext);
1640 if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
1642 char * cColon = strstr(colon+1, ":");
1643 if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
1644 cColon = strstr(cColon + 1, ":");
1647 int len = (int)(cColon - (colon+1));
1648 char mName[MAX_LOCATION];
1649 len = Min(len, MAX_LOCATION-1);
1650 strncpy(mName, colon+1, len);
1652 GetLastDirectory(mName, temp);
1653 GetExtension(temp, ext);
1654 if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
1657 strcpy(moduleName, mName);
1661 if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
1664 if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
1666 message = $"Linker Message: ";
1672 message = $"Linker Error";
1675 else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
1679 if(!strstr(line, "error:"))
1681 message = $"Linker Error: ";
1687 strcpy(temp, topNode.path);
1688 PathCatSlash(temp, moduleName);
1689 MakePathRelative(temp, topNode.path, moduleName);
1691 error = strstr(line, "error:");
1692 if(!message && error && error > colon)
1696 // Silence warnings for compiled eC
1697 char * objDir = strstr(moduleName, objDirExp.dir);
1701 if((pointer = strstr(line, "undefined")) ||
1702 (pointer = strstr(line, "multiple definition")) ||
1703 (pointer = strstr(line, "No such file")) ||
1704 (pointer = strstr(line, "token")))
1706 strncat(moduleName, colon, pointer - colon);
1707 sayError = "error: ";
1712 else if((pointer = strstr(line, "No such file")))
1714 strncat(moduleName, colon, pointer - colon);
1715 sayError = "error: ";
1719 else if(compilingEC == 1 || (objDir && objDir == moduleName))
1721 else if(strstr(line, "warning:"))
1727 ide.outputView.buildBox.Logf(" %s%s\n", message, colon);
1728 /*else if(this == ide.workspace.projects.firstIterator.data)
1729 ide.outputView.buildBox.Logf(" %s%s%s\n", moduleName, sayError, colon);*/
1732 char fullModuleName[MAX_LOCATION];
1733 FileAttribs found = 0;
1734 Project foundProject = this;
1737 char * loc = strstr(moduleName, ":");
1739 strcpy(fullModuleName, topNode.path);
1740 PathCat(fullModuleName, moduleName);
1741 found = FileExists(fullModuleName);
1742 if(!found && !strcmp(ext, "c"))
1744 char ecName[MAX_LOCATION];
1745 ChangeExtension(fullModuleName, "ec", ecName);
1746 found = FileExists(ecName);
1750 char path[MAX_LOCATION];
1751 if(ide && ide.workspace)
1753 for(prj : ide.workspace.projects)
1756 MakePathRelative(fullModuleName, prj.topNode.path, path);
1758 if((node = prj.topNode.FindWithPath(path, false)))
1760 strcpy(fullModuleName, prj.topNode.path);
1761 PathCatSlash(fullModuleName, node.path);
1762 PathCatSlash(fullModuleName, node.name);
1763 found = FileExists(fullModuleName);
1771 if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
1773 for(prj : ide.workspace.projects)
1776 if((node = prj.topNode.Find(moduleName, false)))
1778 strcpy(fullModuleName, prj.topNode.path);
1779 PathCatSlash(fullModuleName, node.path);
1780 PathCatSlash(fullModuleName, node.name);
1781 found = FileExists(fullModuleName);
1794 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
1795 MakeSystemPath(fullModuleName);
1798 strcpy(fullModuleName, moduleName);
1801 strcat(fullModuleName, ":");
1802 strcat(fullModuleName, loc + 1);
1806 fullModuleName[0] = 0;
1807 ide.outputView.buildBox.Logf(" %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
1812 ide.outputView.buildBox.Logf("%s\n", line);
1813 linking = compiling = precompiling = false;
1817 ide.outputView.buildBox.Logf("%s\n", line);
1821 //printf("Done getting line\n");
1822 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1824 //printf("Processing Input...\n");
1825 if(app.ProcessInput(true))
1827 app.UpdateDisplay();
1830 //printf("Waiting...\n");
1833 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1835 if(ide.ShouldStopBuild())
1837 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1840 else if(loggedALine || !isARun)
1842 if(f.GetExitCode() && !numErrors)
1844 bool result = f.GetLine(line, sizeof(line)-1);
1845 ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
1851 char targetFileName[MAX_LOCATION];
1852 targetFileName[0] = '\0';
1853 CatTargetFileName(targetFileName, compiler, config);
1854 ide.outputView.buildBox.Logf("\n%s (%s) - ", targetFileName, configName);
1857 ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
1859 ide.outputView.buildBox.Logf($"no error, ");
1862 ide.outputView.buildBox.Logf("%d %s\n", numWarnings, (numWarnings > 1) ? $"warnings" : $"warning");
1864 ide.outputView.buildBox.Logf($"no warning\n");
1880 return numErrors == 0;
1883 void ProcessCleanPipeOutput(DualPipe f, CompilerConfig compiler, ProjectConfig config)
1886 int lenMakeCommand = strlen(compiler.makeCommand);
1891 double lastTime = GetTime();
1894 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1896 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':');
1897 else if(strstr(line, "del") == line);
1898 else if(strstr(line, "rm") == line);
1899 else if(strstr(line, "Could Not Find") == line);
1902 ide.outputView.buildBox.Logf(line);
1903 ide.outputView.buildBox.Logf("\n");
1907 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1909 if(app.ProcessInput(true))
1911 app.UpdateDisplay();
1914 //Sleep(1.0 / PEEK_RESOLUTION);
1918 bool Build(bool isARun, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
1920 bool result = false;
1922 char targetFileName[MAX_LOCATION] = "";
1923 DynamicString makeTargets { };
1924 char makeFile[MAX_LOCATION];
1925 char makeFilePath[MAX_LOCATION];
1926 char configName[MAX_LOCATION];
1927 DirExpression objDirExp = GetObjDir(compiler, config, bitDepth);
1928 PathBackup pathBackup { };
1929 bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
1930 char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
1932 int numJobs = compiler.numJobs;
1933 char command[MAX_F_STRING];
1934 char * compilerName;
1936 compilerName = CopyString(compiler.name);
1937 CamelCase(compilerName);
1939 strcpy(configName, config ? config.name : "Common");
1941 SetPath(false, compiler, config, bitDepth); //true
1942 CatTargetFileName(targetFileName, compiler, config);
1944 strcpy(makeFilePath, topNode.path);
1945 CatMakeFileName(makeFile, config);
1946 PathCatSlash(makeFilePath, makeFile);
1948 // TODO: TEST ON UNIX IF \" around makeTarget is ok
1951 if(compiler.type.isVC)
1953 PrintLn("compiling a single file is not yet supported");
1958 char pushD[MAX_LOCATION];
1959 char cfDir[MAX_LOCATION];
1960 Map<String, NameCollisionInfo> namesInfo { };
1961 GetIDECompilerConfigsDir(cfDir, true, true);
1962 GetWorkingDir(pushD, sizeof(pushD));
1963 ChangeWorkingDir(topNode.path);
1964 // Create object dir if it does not exist already
1965 if(!FileExists(objDirExp.dir).isDirectory)
1967 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s objdir -C \"%s\"%s -f \"%s\"",
1968 compiler.makeCommand, cfDir,
1969 crossCompiling ? " TARGET_PLATFORM=" : "",
1971 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
1972 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" : */"",
1974 compilerName, topNode.path, justPrint ? " -n" : "", makeFilePath);
1976 ide.outputView.buildBox.Logf("%s\n", command);
1980 ChangeWorkingDir(pushD);
1982 topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1983 for(node : onlyNodes)
1985 if(node.GetIsExcluded(config))
1986 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1989 node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, mode == cObject ? true : false);
1990 node.GetTargets(config, namesInfo, objDirExp.dir, makeTargets);
1998 if(compiler.type.isVC)
2000 bool result = false;
2001 char oldwd[MAX_LOCATION];
2002 GetWorkingDir(oldwd, sizeof(oldwd));
2003 ChangeWorkingDir(topNode.path);
2005 // TODO: support justPrint
2006 sprintf(command, "%s /useenv /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2008 ide.outputView.buildBox.Logf("%s\n", command);
2009 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2011 ProcessPipeOutputRaw(f);
2015 ChangeWorkingDir(oldwd);
2019 char cfDir[MAX_LOCATION];
2020 GetIDECompilerConfigsDir(cfDir, true, true);
2021 sprintf(command, "%s %sCF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s -j%d %s%s%s -C \"%s\"%s -f \"%s\"",
2022 compiler.makeCommand,
2023 mode == debugPrecompile ? "ECP_DEBUG=y " : mode == debugCompile ? "ECC_DEBUG=y " : mode == debugGenerateSymbols ? "ECS_DEBUG=y " : "",
2025 crossCompiling ? " TARGET_PLATFORM=" : "",
2027 bitDepth ? " ARCH=" : "",
2028 bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2029 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
2030 compilerName, numJobs,
2031 compiler.ccacheEnabled ? "CCACHE=y " : "",
2032 compiler.distccEnabled ? "DISTCC=y " : "",
2033 (String)makeTargets, topNode.path, (justPrint || (mode != normal && mode != cObject)) ? " -n" : "", makeFilePath);
2035 ide.outputView.buildBox.Logf("%s\n", command);
2037 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2042 ProcessPipeOutputRaw(f);
2045 else if(mode != normal && mode != cObject)
2053 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
2055 if(!found && strstr(line, "ide ") == line)
2057 strcpy(command, line);
2065 result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNodes, compiler, config, bitDepth);
2071 ide.outputView.buildBox.Logf($"Error executing make (%s) command\n", compiler.makeCommand);
2076 delete compilerName;
2081 void Clean(CompilerConfig compiler, ProjectConfig config, int bitDepth, CleanType cleanType, bool justPrint)
2083 char makeFile[MAX_LOCATION];
2084 char makeFilePath[MAX_LOCATION];
2085 char command[MAX_LOCATION];
2086 char * compilerName;
2088 PathBackup pathBackup { };
2089 bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
2090 char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
2092 compilerName = CopyString(compiler.name);
2093 CamelCase(compilerName);
2095 SetPath(false, compiler, config, bitDepth);
2097 strcpy(makeFilePath, topNode.path);
2098 CatMakeFileName(makeFile, config);
2099 PathCatSlash(makeFilePath, makeFile);
2101 if(compiler.type.isVC)
2103 bool result = false;
2104 char oldwd[MAX_LOCATION];
2105 GetWorkingDir(oldwd, sizeof(oldwd));
2106 ChangeWorkingDir(topNode.path);
2108 // TODO: justPrint support
2109 sprintf(command, "%s /useenv /clean /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2111 ide.outputView.buildBox.Logf("%s\n", command);
2112 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2114 ProcessPipeOutputRaw(f);
2118 ChangeWorkingDir(oldwd);
2123 char cfDir[MAX_LOCATION];
2124 GetIDECompilerConfigsDir(cfDir, true, true);
2125 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s %sclean%s -C \"%s\"%s -f \"%s\"",
2126 compiler.makeCommand, cfDir,
2127 crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
2128 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2130 cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
2131 topNode.path, justPrint ? " -n": "", makeFilePath);
2133 ide.outputView.buildBox.Logf("%s\n", command);
2134 if((f = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
2136 ide.outputView.buildBox.Tell($"Deleting target and object files...");
2138 ProcessPipeOutputRaw(f);
2140 ProcessCleanPipeOutput(f, compiler, config);
2143 ide.outputView.buildBox.Logf($"Target and object files deleted\n");
2148 delete compilerName;
2151 void Run(char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2153 String target = new char[maxPathLen];
2154 char oldDirectory[MAX_LOCATION];
2155 char * executableLauncher = compiler.executableLauncher;
2156 DirExpression targetDirExp = GetTargetDir(compiler, config, bitDepth);
2157 PathBackup pathBackup { };
2159 // Build(project, ideMain, true, null, false);
2161 #if defined(__WIN32__)
2162 strcpy(target, topNode.path);
2166 PathCatSlash(target, targetDirExp.dir);
2167 CatTargetFileName(target, compiler, config);
2168 sprintf(target, "%s %s", target, args);
2169 GetWorkingDir(oldDirectory, MAX_LOCATION);
2171 if(strlen(ide.workspace.debugDir))
2173 char temp[MAX_LOCATION];
2174 strcpy(temp, topNode.path);
2175 PathCatSlash(temp, ide.workspace.debugDir);
2176 ChangeWorkingDir(temp);
2179 ChangeWorkingDir(topNode.path);
2180 // ChangeWorkingDir(topNode.path);
2181 SetPath(true, compiler, config, bitDepth);
2182 if(executableLauncher)
2184 char * prefixedTarget = new char[strlen(executableLauncher) + strlen(target) + 2];
2185 prefixedTarget[0] = '\0';
2186 strcat(prefixedTarget, executableLauncher);
2187 strcat(prefixedTarget, " ");
2188 strcat(prefixedTarget, target);
2189 Execute(prefixedTarget);
2190 delete prefixedTarget;
2195 ChangeWorkingDir(oldDirectory);
2198 delete targetDirExp;
2202 void Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
2204 Build(false, nodes, compiler, config, bitDepth, justPrint, mode);
2208 void GetMakefileTargetFileName(TargetTypes targetType, char * fileName, ProjectConfig config)
2211 if(targetType == staticLibrary || targetType == sharedLibrary)
2212 strcat(fileName, "$(LP)");
2213 // !!! ReplaceSpaces must be done after all PathCat calls !!!
2214 // ReplaceSpaces(s, GetTargetFileName(config));
2215 strcat(fileName, GetTargetFileName(config));
2219 strcat(fileName, "$(E)");
2222 strcat(fileName, "$(SO)$(VER)");
2225 strcat(fileName, "$(A)");
2230 bool GenerateCrossPlatformMk(File altCrossPlatformMk)
2232 bool result = false;
2233 char path[MAX_LOCATION];
2235 if(!GetProjectCompilerConfigsDir(path, false, false))
2236 GetIDECompilerConfigsDir(path, false, false);
2238 if(!FileExists(path).isDirectory)
2242 char dirName[MAX_FILENAME];
2243 GetLastDirectory(path, dirName);
2244 if(!strcmp(dirName, ".configs"))
2245 FileSetAttribs(path, FileAttribs { isHidden = true });
2248 PathCatSlash(path, "crossplatform.mk");
2250 if(FileExists(path))
2253 File include = altCrossPlatformMk ? altCrossPlatformMk : FileOpen(":crossplatform.mk", read);
2256 File f = FileOpen(path, write);
2259 include.Seek(0, start);
2260 for(; !include.Eof(); )
2263 int count = include.Read(buffer, 1, 4096);
2264 f.Write(buffer, 1, count);
2270 if(!altCrossPlatformMk)
2277 bool GenerateCompilerCf(CompilerConfig compiler)
2279 bool result = false;
2280 char path[MAX_LOCATION];
2282 char * compilerName;
2283 bool gccCompiler = compiler.ccCommand && (strstr(compiler.ccCommand, "gcc") != null || strstr(compiler.ccCommand, "g++") != null);
2284 char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
2285 Platform platform = compiler.targetPlatform;
2287 compilerName = CopyString(compiler.name);
2288 CamelCase(compilerName);
2289 name = PrintString(platform, "-", compilerName, ".cf");
2291 if(!GetProjectCompilerConfigsDir(path, false, false))
2292 GetIDECompilerConfigsDir(path, false, false);
2294 if(!FileExists(path).isDirectory)
2298 char dirName[MAX_FILENAME];
2299 GetLastDirectory(path, dirName);
2300 if(!strcmp(dirName, ".configs"))
2301 FileSetAttribs(path, FileAttribs { isHidden = true });
2304 PathCatSlash(path, name);
2306 if(FileExists(path))
2309 File f = FileOpen(path, write);
2312 if(compiler.environmentVars && compiler.environmentVars.count)
2314 f.Puts("# ENVIRONMENT VARIABLES\n");
2316 for(e : compiler.environmentVars)
2318 f.Printf("export %s := %s\n", e.name, e.string);
2323 f.Puts("# TOOLCHAIN\n");
2326 if(gnuToolchainPrefix && gnuToolchainPrefix[0])
2328 f.Printf("GCC_PREFIX := %s\n", gnuToolchainPrefix);
2331 if(compiler.sysroot && compiler.sysroot[0])
2333 f.Printf("SYSROOT := %s\n", compiler.sysroot);
2334 // Moved this to crossplatform.mk
2335 //f.Puts("_SYSROOT := $(space)--sysroot=$(SYSROOT)\n");
2339 //f.Printf("SHELL := %s\n", "sh"/*compiler.shellCommand*/); // is this really needed?
2340 f.Printf("CPP := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cppCommand);
2341 f.Printf("CC := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.ccCommand);
2342 f.Printf("CXX := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cxxCommand);
2343 f.Printf("ECP := $(if $(ECP_DEBUG),ide -debug-start $(ECERE_SDK_SRC)/compiler/ecp/ecp.epj -@,%s)\n", compiler.ecpCommand);
2344 f.Printf("ECC := $(if $(ECC_DEBUG),ide -debug-start $(ECERE_SDK_SRC)/compiler/ecc/ecc.epj -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
2345 f.Printf("ECS := $(if $(ECS_DEBUG),ide -debug-start $(ECERE_SDK_SRC)/compiler/ecs/ecs.epj -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.ecsCommand);
2346 f.Printf("EAR := %s\n", compiler.earCommand);
2348 f.Puts("AS := $(GCC_PREFIX)as\n");
2349 f.Puts("LD := $(GCC_PREFIX)ld\n");
2350 f.Puts("AR := $(GCC_PREFIX)ar\n");
2351 f.Puts("STRIP := $(GCC_PREFIX)strip\n");
2352 f.Puts("UPX := upx\n");
2355 f.Puts("UPXFLAGS = -9\n"); // TOFEAT: Compression Level Option? Other UPX Options?
2358 f.Puts("EARFLAGS = \n");
2361 f.Puts("ifndef ARCH\n");
2362 f.Puts("TARGET_ARCH :=$(shell $(CC) -dumpmachine)\n");
2363 f.Puts(" ifdef WINDOWS_HOST\n");
2364 f.Puts(" ifneq ($(filter x86_64%,$(TARGET_ARCH)),)\n");
2365 f.Puts(" TARGET_ARCH := x86_64\n");
2367 f.Puts(" TARGET_ARCH := i386\n");
2370 f.Puts("endif\n\n");
2372 f.Puts("# HARD CODED TARGET_PLATFORM-SPECIFIC OPTIONS\n");
2373 f.Printf("LDFLAGS +=$(if $(%s), -Wl$(comma)--no-undefined,)\n", PlatformToMakefileTargetVariable(tux));
2377 f.Printf("LDFLAGS +=$(if $(%s), -framework cocoa -framework OpenGL,)\n", PlatformToMakefileTargetVariable(apple));
2381 f.Puts("\nCFLAGS += -fmessage-length=0\n");
2384 if(compiler.includeDirs && compiler.includeDirs.count)
2386 f.Puts("\nCFLAGS +=");
2387 OutputListOption(f, gccCompiler ? "isystem " : "I", compiler.includeDirs, lineEach, true);
2390 if(compiler.prepDirectives && compiler.prepDirectives.count)
2392 f.Puts("\nCFLAGS +=");
2393 OutputListOption(f, "D", compiler.prepDirectives, inPlace, true);
2396 if(compiler.libraryDirs && compiler.libraryDirs.count)
2398 f.Puts("\nLDFLAGS +=");
2399 OutputListOption(f, "L", compiler.libraryDirs, lineEach, true);
2400 // We would need a bool option to know whether we want to add to rpath as well...
2401 // OutputListOption(f, "Wl,-rpath ", compiler.libraryDirs, lineEach, true);
2404 if(compiler.excludeLibs && compiler.excludeLibs.count)
2406 f.Puts("\nEXCLUDED_LIBS =");
2407 for(l : compiler.excludeLibs)
2413 if(compiler.linkerFlags && compiler.linkerFlags.count)
2415 f.Puts("\nLDFLAGS +=");
2416 OutputListOption(f, "Wl,", compiler.linkerFlags, inPlace, true);
2420 f.Puts("\nOFLAGS += $(LDFLAGS)");
2422 f.Puts("ifdef ARCH_FLAGS\n");
2423 f.Puts("CFLAGS += $(ARCH_FLAGS)\n");
2424 f.Puts("OFLAGS += $(ARCH_FLAGS)\n");
2433 delete compilerName;
2437 bool GenerateMakefile(char * altMakefilePath, bool noResources, char * includemkPath, ProjectConfig config)
2439 bool result = false;
2440 char filePath[MAX_LOCATION];
2441 char makeFile[MAX_LOCATION];
2442 // PathBackup pathBackup { };
2443 // char oldDirectory[MAX_LOCATION];
2446 if(!altMakefilePath)
2448 strcpy(filePath, topNode.path);
2449 CatMakeFileName(makeFile, config);
2450 PathCatSlash(filePath, makeFile);
2453 f = FileOpen(altMakefilePath ? altMakefilePath : filePath, write);
2455 /*SetPath(false, compiler, config);
2456 GetWorkingDir(oldDirectory, MAX_LOCATION);
2457 ChangeWorkingDir(topNode.path);*/
2464 char targetDir[MAX_LOCATION];
2465 char objDirExpNoSpaces[MAX_LOCATION];
2466 char objDirNoSpaces[MAX_LOCATION];
2467 char resDirNoSpaces[MAX_LOCATION];
2468 char targetDirExpNoSpaces[MAX_LOCATION];
2469 char fixedModuleName[MAX_FILENAME];
2470 char fixedConfigName[MAX_FILENAME];
2472 // Non-zero if we're building eC code
2473 // We'll have to be careful with this when merging configs where eC files can be excluded in some configs and included in others
2474 int numCObjects = 0;
2476 bool containsCXX = false; // True if the project contains a C++ file
2477 bool sameObjTargetDirs;
2478 String objDirExp = GetObjDirExpression(config);
2479 TargetTypes targetType = GetTargetType(config);
2481 char cfDir[MAX_LOCATION];
2482 int objectsParts = 0, eCsourcesParts = 0;
2483 Array<String> listItems { };
2484 Map<String, int> varStringLenDiffs { };
2485 Map<String, NameCollisionInfo> namesInfo { };
2487 Map<String, int> cflagsVariations { };
2488 Map<intptr, int> nodeCFlagsMapping { };
2490 Map<String, int> ecflagsVariations { };
2491 Map<intptr, int> nodeECFlagsMapping { };
2493 ReplaceSpaces(objDirNoSpaces, objDirExp);
2494 strcpy(targetDir, GetTargetDirExpression(config));
2495 ReplaceSpaces(targetDirExpNoSpaces, targetDir);
2497 strcpy(objDirExpNoSpaces, GetObjDirExpression(config));
2498 ChangeCh(objDirExpNoSpaces, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
2500 char temp[MAX_LOCATION];
2501 ReplaceSpaces(temp, objDirExpNoSpaces);
2502 strcpy(objDirExpNoSpaces, temp);
2504 ReplaceSpaces(resDirNoSpaces, resNode.path ? resNode.path : "");
2505 ReplaceSpaces(fixedModuleName, moduleName);
2506 ReplaceSpaces(fixedConfigName, GetConfigName(config));
2507 CamelCase(fixedConfigName);
2509 sameObjTargetDirs = !fstrcmp(objDirExpNoSpaces, targetDirExpNoSpaces);
2511 f.Printf(".PHONY: all objdir%s cleantarget clean realclean distclean\n\n", sameObjTargetDirs ? "" : " targetdir");
2513 f.Puts("# CORE VARIABLES\n\n");
2515 f.Printf("MODULE := %s\n", fixedModuleName);
2516 f.Printf("VERSION := %s\n", property::moduleVersion);
2517 f.Printf("CONFIG := %s\n", fixedConfigName);
2518 f.Puts("ifndef COMPILER\n" "COMPILER := default\n" "endif\n");
2521 test = GetTargetTypeIsSetByPlatform(config);
2525 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2527 TargetTypes targetType;
2528 PlatformOptions projectPOs, configPOs;
2529 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2530 targetType = platformTargetType;
2536 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
2537 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2542 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2547 for(c = 0; c < ifCount; c++)
2553 f.Puts("# FLAGS\n\n");
2555 f.Puts("ECFLAGS =\n");
2556 f.Puts("ifndef DEBIAN_PACKAGE\n" "CFLAGS =\n" "LDFLAGS =\n" "endif\n");
2557 f.Puts("PRJ_CFLAGS =\n");
2558 f.Puts("CECFLAGS =\n");
2559 f.Puts("OFLAGS =\n");
2563 f.Puts("ifdef DEBUG\n" "NOSTRIP := y\n" "endif\n");
2566 // Important: We cannot use this ifdef anymore, EXECUTABLE_TARGET is not yet defined. It's embedded in the crossplatform.mk EXECUTABLE
2567 //f.Puts("ifdef EXECUTABLE_TARGET\n");
2568 f.Printf("CONSOLE = %s\n", GetConsole(config) ? "-mconsole" : "-mwindows");
2569 //f.Puts("endif\n");
2572 f.Puts("# INCLUDES\n\n");
2574 if(compilerConfigsDir && compilerConfigsDir[0])
2576 strcpy(cfDir, compilerConfigsDir);
2577 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
2582 GetIDECompilerConfigsDir(cfDir, true, true);
2583 // Use CF_DIR environment variable for absolute paths only
2584 if(cfDir[0] == '/' || (cfDir[0] && cfDir[1] == ':'))
2585 strcpy(cfDir, "$(CF_DIR)");
2588 f.Printf("_CF_DIR = %s\n", cfDir);
2591 f.Printf("include %s\n", includemkPath ? includemkPath : "$(_CF_DIR)crossplatform.mk");
2592 f.Puts("include $(_CF_DIR)$(TARGET_PLATFORM)-$(COMPILER).cf\n");
2595 f.Puts("# POST-INCLUDES VARIABLES\n\n");
2597 f.Printf("OBJ = %s%s\n", objDirExpNoSpaces, objDirExpNoSpaces[0] ? "/" : "");
2600 f.Printf("RES = %s%s\n", resDirNoSpaces, resDirNoSpaces[0] ? "/" : "");
2603 // test = GetTargetTypeIsSetByPlatform(config);
2605 char target[MAX_LOCATION];
2606 char temp[MAX_LOCATION];
2611 for(type = (TargetTypes)1; type < TargetTypes::enumSize; type++)
2613 if(type != targetType)
2618 f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(type));
2620 GetMakefileTargetFileName(type, target, config);
2621 strcpy(temp, targetDir);
2622 PathCatSlash(temp, target);
2623 ReplaceSpaces(target, temp);
2624 f.Printf("TARGET = %s\n", target);
2629 GetMakefileTargetFileName(targetType, target, config);
2630 strcpy(temp, targetDir);
2631 PathCatSlash(temp, target);
2632 ReplaceSpaces(target, temp);
2633 f.Printf("TARGET = %s\n", target);
2639 for(c = 0; c < ifCount; c++)
2646 // Use something fixed here, to not cause Makefile differences across compilers...
2647 varStringLenDiffs["$(OBJ)"] = 30; // strlen("obj/memoryGuard.android.gcc-4.6.2") - 6;
2648 // varStringLenDiffs["$(OBJ)"] = strlen(objDirNoSpaces) - 6;
2650 topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
2654 char * map[5][2] = { { "COBJECTS", "C" }, { "SYMBOLS", "S" }, { "IMPORTS", "I" }, { "ECOBJECTS", "O" }, { "BOWLS", "B" } };
2656 numCObjects = topNode.GenMakefilePrintNode(f, this, eCsources, namesInfo, listItems, config, null);
2659 eCsourcesParts = OutputFileList(f, "_ECSOURCES", listItems, varStringLenDiffs, null);
2661 f.Puts("ECSOURCES = $(call shwspace,$(_ECSOURCES))\n");
2662 if(eCsourcesParts > 1)
2664 for(c = 1; c <= eCsourcesParts; c++)
2665 f.Printf("ECSOURCES%d = $(call shwspace,$(_ECSOURCES%d))\n", c, c);
2669 for(c = 0; c < 5; c++)
2671 if(eCsourcesParts > 1)
2674 f.Printf("%s =", map[c][0]);
2675 for(n = 1; n <= eCsourcesParts; n++)
2676 f.Printf(" $(%s%d)", map[c][0], n);
2678 for(n = 1; n <= eCsourcesParts; n++)
2679 f.Printf("%s%d = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES%d)))))\n", map[c][0], n, map[c][1], n);
2681 else if(eCsourcesParts == 1)
2682 f.Printf("%s = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES)))))\n", map[c][0], map[c][1]);
2688 numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, &containsCXX);
2690 objectsParts = OutputFileList(f, "_OBJECTS", listItems, varStringLenDiffs, null);
2691 f.Printf("OBJECTS =%s%s%s\n", numObjects ? " $(_OBJECTS)" : "", numCObjects ? " $(ECOBJECTS)" : "", numCObjects ? " $(OBJ)$(MODULE).main$(O)" : "");
2694 topNode.GenMakefilePrintNode(f, this, sources, null, listItems, config, null);
2695 OutputFileList(f, "SOURCES", listItems, varStringLenDiffs, numCObjects ? "$(ECSOURCES)" : null);
2698 resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config, null);
2699 OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs, null);
2701 f.Puts("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n");
2703 if((config && config.options && config.options.libraries) ||
2704 (options && options.libraries))
2706 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
2708 if(config && config.options && config.options.libraries)
2709 OutputLibraries(f, config.options.libraries);
2710 else if(options && options.libraries)
2711 OutputLibraries(f, options.libraries);
2717 topNode.GenMakeCollectAssignNodeFlags(config, numCObjects,
2718 cflagsVariations, nodeCFlagsMapping,
2719 ecflagsVariations, nodeECFlagsMapping, null);
2721 GenMakePrintCustomFlags(f, "PRJ_CFLAGS", false, cflagsVariations);
2722 GenMakePrintCustomFlags(f, "ECFLAGS", true, ecflagsVariations);
2724 if(platforms || (config && config.platforms))
2727 //for(platform = firstPlatform; platform <= lastPlatform; platform++)
2728 //for(platform = win32; platform <= apple; platform++)
2730 f.Puts("# PLATFORM-SPECIFIC OPTIONS\n\n");
2731 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2733 PlatformOptions projectPlatformOptions, configPlatformOptions;
2734 MatchProjectAndConfigPlatformOptions(config, platform, &projectPlatformOptions, &configPlatformOptions);
2736 if(projectPlatformOptions || configPlatformOptions)
2741 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
2744 if((projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count) ||
2745 (configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count))
2747 f.Puts("OFLAGS +=");
2748 if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
2750 bool needWl = false;
2752 for(s : projectPlatformOptions.options.linkerOptions)
2754 if(!IsLinkerOption(s))
2762 for(s : projectPlatformOptions.options.linkerOptions)
2763 if(IsLinkerOption(s))
2767 if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
2769 bool needWl = false;
2771 for(s : configPlatformOptions.options.linkerOptions)
2773 if(IsLinkerOption(s))
2781 for(s : configPlatformOptions.options.linkerOptions)
2782 if(!IsLinkerOption(s))
2790 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
2791 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count) ||
2792 (projectPlatformOptions && projectPlatformOptions.options.libraries && projectPlatformOptions.options.libraries.count) ||
2793 (configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
2795 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
2796 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
2797 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count))
2799 f.Puts("OFLAGS +=");
2800 if(configPlatformOptions && configPlatformOptions.options.libraryDirs)
2801 OutputListOption(f, "L", configPlatformOptions.options.libraryDirs, lineEach, true);
2802 if(projectPlatformOptions && projectPlatformOptions.options.libraryDirs)
2803 OutputListOption(f, "L", projectPlatformOptions.options.libraryDirs, lineEach, true);
2807 if((configPlatformOptions && configPlatformOptions.options.libraries))
2809 if(configPlatformOptions.options.libraries.count)
2812 OutputLibraries(f, configPlatformOptions.options.libraries);
2816 else if(projectPlatformOptions && projectPlatformOptions.options.libraries)
2818 if(projectPlatformOptions.options.libraries.count)
2821 OutputLibraries(f, projectPlatformOptions.options.libraries);
2832 for(c = 0; c < ifCount; c++)
2838 if((config && config.options && config.options.linkerOptions && config.options.linkerOptions.count) ||
2839 (options && options.linkerOptions && options.linkerOptions.count))
2841 f.Puts("OFLAGS +=");
2844 if(config && config.options && config.options.linkerOptions && config.options.linkerOptions.count)
2846 bool needWl = false;
2847 for(s : config.options.linkerOptions)
2849 if(!IsLinkerOption(s))
2857 for(s : config.options.linkerOptions)
2858 if(IsLinkerOption(s))
2862 if(options && options.linkerOptions && options.linkerOptions.count)
2864 bool needWl = false;
2865 for(s : options.linkerOptions)
2867 if(!IsLinkerOption(s))
2875 for(s : options.linkerOptions)
2876 if(IsLinkerOption(s))
2884 f.Puts("CECFLAGS += -cpp $(_CPP)");
2888 if(GetProfile(config))
2889 f.Puts("OFLAGS += -pg\n\n");
2891 if((config && config.options && config.options.libraryDirs) || (options && options.libraryDirs))
2893 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
2894 f.Puts("OFLAGS +=");
2895 if(config && config.options && config.options.libraryDirs)
2896 OutputListOption(f, "L", config.options.libraryDirs, lineEach, true);
2897 if(options && options.libraryDirs)
2898 OutputListOption(f, "L", options.libraryDirs, lineEach, true);
2904 f.Puts("# TARGETS\n");
2907 f.Printf("all: objdir%s $(TARGET)\n", sameObjTargetDirs ? "" : " targetdir");
2910 f.Puts("objdir:\n");
2911 f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdirq,$(OBJ)))\n");
2912 //f.Puts("# PRE-BUILD COMMANDS\n");
2913 if(options && options.prebuildCommands)
2915 for(s : options.prebuildCommands)
2916 if(s && s[0]) f.Printf("\t%s\n", s);
2918 if(config && config.options && config.options.prebuildCommands)
2920 for(s : config.options.prebuildCommands)
2921 if(s && s[0]) f.Printf("\t%s\n", s);
2923 if(platforms || (config && config.platforms))
2926 //f.Puts("# TARGET_PLATFORM-SPECIFIC PRE-BUILD COMMANDS\n");
2927 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2929 PlatformOptions projectPOs, configPOs;
2930 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2932 if((projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count) ||
2933 (configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count))
2938 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
2940 if(projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count)
2942 for(s : projectPOs.options.prebuildCommands)
2943 if(s && s[0]) f.Printf("\t%s\n", s);
2945 if(configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count)
2947 for(s : configPOs.options.prebuildCommands)
2948 if(s && s[0]) f.Printf("\t%s\n", s);
2955 for(c = 0; c < ifCount; c++)
2961 if(!sameObjTargetDirs)
2963 f.Puts("targetdir:\n");
2964 f.Printf("\t$(if $(wildcard %s),,$(call mkdirq,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
2970 // Main Module (Linking) for ECERE C modules
2971 f.Puts("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
2972 // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
2973 f.Printf("\t$(ECS)%s $(ARCH_FLAGS) $(ECSLIBOPT) $(SYMBOLS) $(IMPORTS) -symbols %s -o $(OBJ)$(MODULE).main.ec\n",
2974 GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
2976 // Main Module (Linking) for ECERE C modules
2977 f.Puts("$(OBJ)$(MODULE).main.c: $(OBJ)$(MODULE).main.ec\n");
2978 f.Puts("\t$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS)"
2979 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
2980 f.Puts("\t$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY)"
2981 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.c -symbols $(OBJ)\n");
2987 // This would not rebuild the target on updated objects
2988 // f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) | objdir $(SYMBOLS) $(OBJECTS)%s\n", sameObjTargetDirs ? "" : " targetdir");
2990 // This should fix it for good!
2991 f.Puts("$(SYMBOLS): | objdir\n");
2992 f.Puts("$(OBJECTS): | objdir\n");
2994 // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
2995 f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
2997 f.Printf("\t@$(call rmq,$(OBJ)linkobjects.lst)\n");
2998 f.Printf("\t@$(call touch,$(OBJ)linkobjects.lst)\n");
2999 OutputLinkObjectActions(f, "_OBJECTS", objectsParts);
3002 f.Printf("\t@$(call echo,$(OBJ)$(MODULE).main$(O)) >> $(OBJ)linkobjects.lst\n");
3003 OutputLinkObjectActions(f, "ECOBJECTS", eCsourcesParts);
3006 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3008 f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)linkobjects.lst $(LIBS) %s-o $(TARGET) $(INSTALLNAME)\n", containsCXX ? "CXX" : "CC", containsCXX ? "-lstdc++ " : "");
3009 if(!GetDebug(config))
3011 f.Puts("ifndef NOSTRIP\n");
3012 f.Puts("\t$(STRIP) $(STRIPOPT) $(TARGET)\n");
3015 if(GetCompress(config))
3017 f.Printf("ifndef %s\n", PlatformToMakefileTargetVariable(win32));
3018 f.Puts("ifdef EXECUTABLE_TARGET\n");
3019 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3022 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3026 if(resNode.files && resNode.files.count && !noResources)
3027 resNode.GenMakefileAddResources(f, resNode.path, config);
3029 f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)linkobjects.lst $(LIBS)\n");
3031 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3032 f.Puts("ifdef LINUX_TARGET\n");
3033 f.Puts("ifdef LINUX_HOST\n");
3034 // TODO?: support symlinks for longer version numbers
3035 f.Puts("\t$(if $(basename $(VER)),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)),)\n");
3036 f.Puts("\t$(if $(VER),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO),)\n");
3041 //f.Puts("# POST-BUILD COMMANDS\n");
3042 if(options && options.postbuildCommands)
3044 for(s : options.postbuildCommands)
3045 if(s && s[0]) f.Printf("\t%s\n", s);
3047 if(config && config.options && config.options.postbuildCommands)
3049 for(s : config.options.postbuildCommands)
3050 if(s && s[0]) f.Printf("\t%s\n", s);
3052 if(platforms || (config && config.platforms))
3055 //f.Puts("# TARGET_PLATFORM-SPECIFIC POST-BUILD COMMANDS\n");
3056 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3058 PlatformOptions projectPOs, configPOs;
3059 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3061 if((projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count) ||
3062 (configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count))
3067 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3069 if(projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count)
3071 for(s : projectPOs.options.postbuildCommands)
3072 if(s && s[0]) f.Printf("\t%s\n", s);
3074 if(configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count)
3076 for(s : configPOs.options.postbuildCommands)
3077 if(s && s[0]) f.Printf("\t%s\n", s);
3084 for(c = 0; c < ifCount; c++)
3090 f.Puts("# SYMBOL RULES\n");
3093 topNode.GenMakefilePrintSymbolRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3095 f.Puts("# C OBJECT RULES\n");
3098 topNode.GenMakefilePrintCObjectRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3100 f.Puts("# OBJECT RULES\n");
3102 // todo call this still but only generate rules whith specific options
3103 // see we-have-file-specific-options in ProjectNode.ec
3104 topNode.GenMakefilePrintObjectRules(f, this, namesInfo, config, nodeCFlagsMapping, nodeECFlagsMapping);
3107 GenMakefilePrintMainObjectRule(f, config);
3109 f.Printf("cleantarget: objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
3110 f.Puts("\t$(call rmq,$(TARGET))\n");
3111 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3112 f.Puts("ifdef LINUX_TARGET\n");
3113 f.Puts("ifdef LINUX_HOST\n");
3114 // TODO?: support symlinks for longer version numbers
3115 f.Puts("\t$(call rmq,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
3116 f.Puts("\t$(call rmq,$(OBJ)$(LP)$(MODULE)$(SO))\n");
3122 f.Puts("clean: cleantarget\n");
3123 f.Printf("\t$(call rmq,$(OBJ)linkobjects.lst)\n");
3124 OutputCleanActions(f, "_OBJECTS", objectsParts);
3127 f.Printf("\t$(call rmq,%s)\n", "$(OBJ)$(MODULE).main.o $(OBJ)$(MODULE).main.c $(OBJ)$(MODULE).main.ec $(OBJ)$(MODULE).main$(I) $(OBJ)$(MODULE).main$(S)");
3128 OutputCleanActions(f, "ECOBJECTS", eCsourcesParts);
3129 OutputCleanActions(f, "COBJECTS", eCsourcesParts);
3130 OutputCleanActions(f, "BOWLS", eCsourcesParts);
3131 OutputCleanActions(f, "IMPORTS", eCsourcesParts);
3132 OutputCleanActions(f, "SYMBOLS", eCsourcesParts);
3136 f.Puts("realclean: cleantarget\n");
3137 f.Puts("\t$(call rmrq,$(OBJ))\n");
3138 if(!sameObjTargetDirs)
3139 f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
3142 f.Puts("distclean: cleantarget\n");
3143 if(!sameObjTargetDirs)
3144 f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
3145 f.Puts("\t$(call rmrq,obj/)\n");
3151 varStringLenDiffs.Free();
3152 delete varStringLenDiffs;
3156 delete cflagsVariations;
3157 delete nodeCFlagsMapping;
3158 delete ecflagsVariations;
3159 delete nodeECFlagsMapping;
3164 // ChangeWorkingDir(oldDirectory);
3165 // delete pathBackup;
3168 config.makingModified = false;
3172 void GenMakefilePrintMainObjectRule(File f, ProjectConfig config)
3174 char extension[MAX_EXTENSION] = "c";
3175 char modulePath[MAX_LOCATION];
3176 char fixedModuleName[MAX_FILENAME];
3179 char objDirNoSpaces[MAX_LOCATION];
3180 String objDirExp = GetObjDirExpression(config);
3182 ReplaceSpaces(objDirNoSpaces, objDirExp);
3183 ReplaceSpaces(fixedModuleName, moduleName);
3185 //sprintf(fixedModuleName, "%s.main", fixedPrjName);
3186 //strcat(fixedModuleName, ".main");
3188 #if 0 // TODO: Fix nospaces stuff
3189 // *** Dependency command ***
3190 sprintf(command, "gcc -MT $(OBJ)%s$(O) -MM $(OBJ)%s.c", fixedModuleName, fixedModuleName);
3192 // System Includes (from global settings)
3193 for(item : compiler.dirs[Includes])
3195 strcat(command, " -isystem ");
3196 if(strchr(item.name, ' '))
3198 strcat(command, "\"");
3199 strcat(command, item);
3200 strcat(command, "\"");
3203 strcat(command, item);
3206 for(item = includeDirs.first; item; item = item.next)
3208 strcat(command, " -I");
3209 if(strchr(item.name, ' '))
3211 strcat(command, "\"");
3212 strcat(command, item.name);
3213 strcat(command, "\"");
3216 strcat(command, item.name);
3218 for(item = preprocessorDefs.first; item; item = item.next)
3220 strcat(command, " -D");
3221 strcat(command, item.name);
3225 if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
3229 bool firstLine = true;
3231 // To do some time: auto save external dependencies?
3234 if(dep.GetLine(line, sizeof(line)-1))
3238 char * colon = strstr(line, ":");
3239 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
3253 // If we failed to generate dependencies...
3257 f.Puts("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
3258 f.Printf("\t$(CC) $(CFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(OBJ)$(MODULE).main$(O)\n", extension);
3266 void GenMakePrintCustomFlags(File f, String variableName, bool printNonCustom, Map<String, int> cflagsVariations)
3269 for(c = printNonCustom ? 0 : 1; c <= cflagsVariations.count; c++)
3271 for(v : cflagsVariations)
3276 f.Printf("%s +=", variableName);
3278 f.Printf("CUSTOM%d_%s =", v-1, variableName);
3279 f.Puts(&v ? &v : "");
3289 void MatchProjectAndConfigPlatformOptions(ProjectConfig config, Platform platform,
3290 PlatformOptions * projectPlatformOptions, PlatformOptions * configPlatformOptions)
3292 *projectPlatformOptions = null;
3293 *configPlatformOptions = null;
3298 if(!strcmpi(p.name, platform))
3300 *projectPlatformOptions = p;
3305 if(config && config.platforms)
3307 for(p : config.platforms)
3309 if(!strcmpi(p.name, platform))
3311 *configPlatformOptions = p;
3319 Project LegacyBinaryLoadProject(File f, char * filePath)
3321 Project project = null;
3322 char signature[sizeof(epjSignature)];
3324 f.Read(signature, sizeof(signature), 1);
3325 if(!strncmp(signature, (char *)epjSignature, sizeof(epjSignature)))
3327 char topNodePath[MAX_LOCATION];
3328 /*ProjectConfig newConfig
3330 name = CopyString("Default");
3331 makingModified = true;
3332 compilingModified = true;
3333 linkingModified = true;
3337 project = Project { options = { } };
3338 LegacyBinaryLoadNode(project.topNode, f);
3339 delete project.topNode.path;
3340 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3341 MakeSlashPath(topNodePath);
3343 PathCatSlash(topNodePath, filePath);
3344 project.filePath = topNodePath;
3346 /* THIS IS ALREADY DONE BY filePath property
3347 StripLastDirectory(topNodePath, topNodePath);
3348 project.topNode.path = CopyString(topNodePath);
3350 // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
3352 // newConfig.options.defaultNameSpace = "";
3353 /*newConfig.objDir.dir = "obj";
3354 newConfig.targetDir.dir = "";*/
3356 //project.configurations = { [ newConfig ] };
3357 //project.config = newConfig;
3364 String targetFileName, targetDirectory, objectsDirectory;
3366 // { executable = 0, sharedLibrary = 1, staticLibrary = 2 };
3367 f.Read(&temp, sizeof(int),1);
3370 case 0: project.options.targetType = executable; break;
3371 case 1: project.options.targetType = sharedLibrary; break;
3372 case 2: project.options.targetType = staticLibrary; break;
3375 f.Read(&len, sizeof(int),1);
3376 targetFileName = new char[len+1];
3377 f.Read(targetFileName, sizeof(char), len+1);
3378 project.options.targetFileName = targetFileName;
3379 delete targetFileName;
3381 f.Read(&len, sizeof(int),1);
3382 targetDirectory = new char[len+1];
3383 f.Read(targetDirectory, sizeof(char), len+1);
3384 project.options.targetDirectory = targetDirectory;
3385 delete targetDirectory;
3387 f.Read(&len, sizeof(int),1);
3388 objectsDirectory = new byte[len+1];
3389 f.Read(objectsDirectory, sizeof(char), len+1);
3390 project.options.objectsDirectory = objectsDirectory;
3391 delete objectsDirectory;
3393 f.Read(&temp, sizeof(int),1);
3394 project./*config.*/options.debug = temp ? true : false;
3395 f.Read(&temp, sizeof(int),1);
3396 project./*config.*/options.optimization = temp ? speed : none;
3397 f.Read(&temp, sizeof(int),1);
3398 project./*config.*/options.profile = temp ? true : false;
3399 f.Read(&temp, sizeof(int),1);
3400 project.options.warnings = temp ? all : unset;
3402 f.Read(&count, sizeof(int),1);
3405 project.options.includeDirs = { };
3406 for(c = 0; c < count; c++)
3409 f.Read(&len, sizeof(int),1);
3410 name = new char[len+1];
3411 f.Read(name, sizeof(char), len+1);
3412 project.options.includeDirs.Add(name);
3416 f.Read(&count, sizeof(int),1);
3419 project.options.libraryDirs = { };
3420 for(c = 0; c < count; c++)
3423 f.Read(&len, sizeof(int),1);
3424 name = new char[len+1];
3425 f.Read(name, sizeof(char), len+1);
3426 project.options.libraryDirs.Add(name);
3430 f.Read(&count, sizeof(int),1);
3433 project.options.libraries = { };
3434 for(c = 0; c < count; c++)
3437 f.Read(&len, sizeof(int),1);
3438 name = new char[len+1];
3439 f.Read(name, sizeof(char), len+1);
3440 project.options.libraries.Add(name);
3444 f.Read(&count, sizeof(int),1);
3447 project.options.preprocessorDefinitions = { };
3448 for(c = 0; c < count; c++)
3451 f.Read(&len, sizeof(int),1);
3452 name = new char[len+1];
3453 f.Read(name, sizeof(char), len+1);
3454 project.options.preprocessorDefinitions.Add(name);
3458 f.Read(&temp, sizeof(int),1);
3459 project.options.console = temp ? true : false;
3462 for(node : project.topNode.files)
3464 if(node.type == resources)
3466 project.resNode = node;
3476 void ProjectConfig::LegacyProjectConfigLoad(File f)
3484 char subSection[128];
3490 f.GetLine(buffer, 65536 - 1);
3491 TrimLSpaces(buffer, buffer);
3492 TrimRSpaces(buffer, buffer);
3495 if(buffer[0] == '-')
3499 TrimLSpaces(equal, equal);
3500 if(!strcmpi(subSection, "LibraryDirs"))
3502 if(!options.libraryDirs)
3503 options.libraryDirs = { [ CopyString(equal) ] };
3505 options.libraryDirs.Add(CopyString(equal));
3507 else if(!strcmpi(subSection, "IncludeDirs"))
3509 if(!options.includeDirs)
3510 options.includeDirs = { [ CopyString(equal) ] };
3512 options.includeDirs.Add(CopyString(equal));
3515 else if(buffer[0] == '+')
3526 TrimLSpaces(equal, equal);
3527 delete name; name = CopyString(equal); // property::name = equal;
3530 else if(!strcmpi(buffer, "Compiler Options"))
3531 strcpy(section, buffer);
3532 else if(!strcmpi(buffer, "IncludeDirs"))
3533 strcpy(subSection, buffer);
3534 else if(!strcmpi(buffer, "Linker Options"))
3535 strcpy(section, buffer);
3536 else if(!strcmpi(buffer, "LibraryDirs"))
3537 strcpy(subSection, buffer);
3538 else if(!strcmpi(buffer, "Files") || !strcmpi(buffer, "Resources"))
3545 equal = strstr(buffer, "=");
3549 TrimRSpaces(buffer, buffer);
3551 TrimLSpaces(equal, equal);
3552 if(!strcmpi(buffer, "Target Name"))
3553 options.targetFileName = /*CopyString(*/equal/*)*/;
3554 else if(!strcmpi(buffer, "Target Type"))
3556 if(!strcmpi(equal, "Executable"))
3557 options.targetType = executable;
3558 else if(!strcmpi(equal, "Shared"))
3559 options.targetType = sharedLibrary;
3560 else if(!strcmpi(equal, "Static"))
3561 options.targetType = staticLibrary;
3563 options.targetType = executable;
3565 else if(!strcmpi(buffer, "Target Directory"))
3566 options.targetDirectory = /*CopyString(*/equal/*)*/;
3567 else if(!strcmpi(buffer, "Console"))
3568 options.console = ParseTrueFalseValue(equal);
3569 else if(!strcmpi(buffer, "Libraries"))
3571 if(!options.libraries) options.libraries = { };
3572 ParseArrayValue(options.libraries, equal);
3574 else if(!strcmpi(buffer, "Intermediate Directory"))
3575 options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
3576 else if(!strcmpi(buffer, "Debug"))
3577 options.debug = ParseTrueFalseValue(equal);
3578 else if(!strcmpi(buffer, "Optimize"))
3580 if(!strcmpi(equal, "None"))
3581 options.optimization = none;
3582 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
3583 options.optimization = speed;
3584 else if(!strcmpi(equal, "Size"))
3585 options.optimization = size;
3587 options.optimization = none;
3589 else if(!strcmpi(buffer, "Compress"))
3590 options.compress = ParseTrueFalseValue(equal);
3591 else if(!strcmpi(buffer, "Profile"))
3592 options.profile = ParseTrueFalseValue(equal);
3593 else if(!strcmpi(buffer, "AllWarnings"))
3594 options.warnings = ParseTrueFalseValue(equal) ? all : unset;
3595 else if(!strcmpi(buffer, "MemoryGuard"))
3596 options.memoryGuard = ParseTrueFalseValue(equal);
3597 else if(!strcmpi(buffer, "Default Name Space"))
3598 options.defaultNameSpace = CopyString(equal);
3599 else if(!strcmpi(buffer, "Strict Name Spaces"))
3600 options.strictNameSpaces = ParseTrueFalseValue(equal);
3601 else if(!strcmpi(buffer, "Preprocessor Definitions"))
3603 if(!options.preprocessorDefinitions) options.preprocessorDefinitions = { };
3604 ParseArrayValue(options.preprocessorDefinitions, equal);
3610 if(!options.targetDirectory && options.objectsDirectory)
3611 options.targetDirectory = /*CopyString(*/options.objectsDirectory/*)*/;
3612 //if(!objDir.dir) objDir.dir = "obj";
3613 //if(!targetDir.dir) targetDir.dir = "";
3614 // if(!targetName) property::targetName = ""; // How can a targetFileName be nothing???
3615 // if(!defaultNameSpace) property::defaultNameSpace = "";
3616 makingModified = true;
3619 Project LegacyAsciiLoadProject(File f, char * filePath)
3621 Project project = null;
3622 ProjectNode node = null;
3624 char parentPath[MAX_LOCATION];
3625 char section[128] = "";
3626 char subSection[128] = "";
3628 bool configurationsPresent = false;
3638 f.GetLine(buffer, 65536 - 1);
3639 TrimLSpaces(buffer, buffer);
3640 TrimRSpaces(buffer, buffer);
3643 if(buffer[0] == '-' || buffer[0] == '=')
3645 bool simple = buffer[0] == '-';
3648 TrimLSpaces(equal, equal);
3649 if(!strcmpi(section, "Target") && !strcmpi(subSection, "LibraryDirs"))
3651 if(!project.config.options.libraryDirs)
3652 project.config.options.libraryDirs = { [ CopyString(equal) ] };
3654 project.config.options.libraryDirs.Add(CopyString(equal));
3656 else if(!strcmpi(section, "Target") && !strcmpi(subSection, "IncludeDirs"))
3658 if(!project.config.options.includeDirs)
3659 project.config.options.includeDirs = { [ CopyString(equal) ] };
3661 project.config.options.includeDirs.Add(CopyString(equal));
3663 else if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
3665 len = strlen(equal);
3668 char temp[MAX_LOCATION];
3669 ProjectNode child { };
3670 // We don't need to do this anymore, fileName is just a property that sets name & path
3671 // child.fileName = CopyString(equal);
3674 child.name = CopyString(equal);
3675 child.path = CopyString(parentPath);
3679 GetLastDirectory(equal, temp);
3680 child.name = CopyString(temp);
3681 StripLastDirectory(equal, temp);
3682 child.path = CopyString(temp);
3684 child.nodeType = file;
3685 child.parent = parent;
3686 child.indent = parent.indent + 1;
3688 child.icon = NodeIcons::SelectFileIcon(child.name);
3689 parent.files.Add(child);
3695 StripLastDirectory(parentPath, parentPath);
3696 parent = parent.parent;
3700 else if(buffer[0] == '+')
3704 TrimLSpaces(equal, equal);
3705 if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
3707 char temp[MAX_LOCATION];
3708 ProjectNode child { };
3709 // NEW: Folders now have a path set like files
3710 child.name = CopyString(equal);
3711 strcpy(temp, parentPath);
3712 PathCatSlash(temp, child.name);
3713 child.path = CopyString(temp);
3715 child.parent = parent;
3716 child.indent = parent.indent + 1;
3717 child.type = folder;
3718 child.nodeType = folder;
3720 child.icon = folder;
3721 PathCatSlash(parentPath, child.name);
3722 parent.files.Add(child);
3727 else if(!strcmpi(section, "Configurations"))
3729 ProjectConfig newConfig
3731 makingModified = true;
3735 LegacyProjectConfigLoad(newConfig, f);
3736 project.configurations.Add(newConfig);
3739 else if(!strcmpi(buffer, "ECERE Project File"));
3740 else if(!strcmpi(buffer, "Version 0a"))
3741 ; //strcpy(version, "0a");
3742 else if(!strcmpi(buffer, "Version 0.1a"))
3743 ; //strcpy(version, "0.1a");
3744 else if(!strcmpi(buffer, "Configurations"))
3746 project.configurations.Free();
3747 project.config = null;
3748 strcpy(section, buffer);
3749 configurationsPresent = true;
3751 else if(!strcmpi(buffer, "Target") || !strnicmp(buffer, "Target \"", strlen("Target \"")))
3753 ProjectConfig newConfig { name = CopyString("Default"), options = { } };
3754 char topNodePath[MAX_LOCATION];
3755 // newConfig.defaultNameSpace = "";
3756 //newConfig.objDir.dir = "obj";
3757 //newConfig.targetDir.dir = "";
3758 project = Project { /*options = { }*/ };
3759 project.configurations = { [ newConfig ] };
3760 project.config = newConfig;
3761 // if(project.topNode.path) delete project.topNode.path;
3762 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3763 MakeSlashPath(topNodePath);
3764 PathCatSlash(topNodePath, filePath);
3765 project.filePath = topNodePath;
3766 parentPath[0] = '\0';
3767 parent = project.topNode;
3769 strcpy(section, "Target");
3774 if(equal[0] == '\"')
3776 StripQuotes(equal, equal);
3777 delete project.moduleName; project.moduleName = CopyString(equal);
3781 else if(!strcmpi(buffer, "Compiler Options"));
3782 else if(!strcmpi(buffer, "IncludeDirs"))
3783 strcpy(subSection, buffer);
3784 else if(!strcmpi(buffer, "Linker Options"));
3785 else if(!strcmpi(buffer, "LibraryDirs"))
3786 strcpy(subSection, buffer);
3787 else if(!strcmpi(buffer, "Files"))
3789 strcpy(section, "Target");
3790 strcpy(subSection, buffer);
3792 else if(!strcmpi(buffer, "Resources"))
3794 ProjectNode child { };
3795 parent.files.Add(child);
3796 child.parent = parent;
3797 child.indent = parent.indent + 1;
3798 child.name = CopyString(buffer);
3799 child.path = CopyString("");
3800 child.type = resources;
3802 child.icon = archiveFile;
3803 project.resNode = child;
3806 strcpy(subSection, buffer);
3810 equal = strstr(buffer, "=");
3814 TrimRSpaces(buffer, buffer);
3816 TrimLSpaces(equal, equal);
3818 if(!strcmpi(section, "Target"))
3820 if(!strcmpi(buffer, "Build Exclusions"))
3822 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
3824 /*if(node && node.type != NodeTypes::project)
3825 ParseListValue(node.buildExclusions, equal);*/
3828 else if(!strcmpi(buffer, "Path") && !strcmpi(subSection, "Resources"))
3830 delete project.resNode.path;
3831 project.resNode.path = CopyString(equal);
3832 PathCatSlash(parentPath, equal);
3836 else if(!strcmpi(buffer, "Intermediate Directory"))
3837 project.config.options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
3838 else if(!strcmpi(buffer, "Debug"))
3839 project.config.options.debug = ParseTrueFalseValue(equal);
3840 else if(!strcmpi(buffer, "Optimize"))
3842 if(!strcmpi(equal, "None"))
3843 project.config.options.optimization = none;
3844 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
3845 project.config.options.optimization = speed;
3846 else if(!strcmpi(equal, "Size"))
3847 project.config.options.optimization = size;
3849 project.config.options.optimization = none;
3851 else if(!strcmpi(buffer, "Profile"))
3852 project.config.options.profile = ParseTrueFalseValue(equal);
3853 else if(!strcmpi(buffer, "MemoryGuard"))
3854 project.config.options.memoryGuard = ParseTrueFalseValue(equal);
3857 if(!project.options) project.options = { };
3859 // Project Wide Settings (All configs)
3860 if(!strcmpi(buffer, "Target Name"))
3861 project.options.targetFileName = /*CopyString(*/equal/*)*/;
3862 else if(!strcmpi(buffer, "Target Type"))
3864 if(!strcmpi(equal, "Executable"))
3865 project.options.targetType = executable;
3866 else if(!strcmpi(equal, "Shared"))
3867 project.options.targetType = sharedLibrary;
3868 else if(!strcmpi(equal, "Static"))
3869 project.options.targetType = staticLibrary;
3871 project.options.targetType = executable;
3873 else if(!strcmpi(buffer, "Target Directory"))
3874 project.options.targetDirectory = /*CopyString(*/equal/*)*/;
3875 else if(!strcmpi(buffer, "Console"))
3876 project.options.console = ParseTrueFalseValue(equal);
3877 else if(!strcmpi(buffer, "Libraries"))
3879 if(!project.options.libraries) project.options.libraries = { };
3880 ParseArrayValue(project.options.libraries, equal);
3882 else if(!strcmpi(buffer, "AllWarnings"))
3883 project.options.warnings = ParseTrueFalseValue(equal) ? all : unset;
3884 else if(!strcmpi(buffer, "Preprocessor Definitions"))
3886 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
3888 /*if(node && (node.type == NodeTypes::project || (node.type == file && !node.isInResources) || node.type == folder))
3889 ParseListValue(node.preprocessorDefs, equal);*/
3893 if(!project.options.preprocessorDefinitions) project.options.preprocessorDefinitions = { };
3894 ParseArrayValue(project.options.preprocessorDefinitions, equal);
3905 SplitPlatformLibraries(project);
3907 if(configurationsPresent)
3908 CombineIdenticalConfigOptions(project);
3912 void SplitPlatformLibraries(Project project)
3914 if(project && project.configurations)
3916 for(cfg : project.configurations)
3918 if(cfg.options.libraries && cfg.options.libraries.count)
3920 Iterator<String> it { cfg.options.libraries };
3924 char * platformName = strstr(l, ":");
3927 PlatformOptions platform = null;
3929 if(!cfg.platforms) cfg.platforms = { };
3930 for(p : cfg.platforms)
3932 if(!strcmpi(platformName, p.name))
3940 platform = { name = CopyString(platformName), options = { libraries = { } } };
3941 cfg.platforms.Add(platform);
3943 *(platformName-1) = 0;
3944 platform.options.libraries.Add(CopyString(l));
3946 cfg.options.libraries.Delete(it.pointer);
3955 void CombineIdenticalConfigOptions(Project project)
3957 if(project && project.configurations && project.configurations.count)
3960 ProjectOptions nullOptions { };
3961 ProjectConfig firstConfig = null;
3962 for(cfg : project.configurations)
3964 if(cfg.options.targetType != staticLibrary)
3971 firstConfig = project.configurations.firstIterator.data;
3973 for(member = class(ProjectOptions).membersAndProperties.first; member; member = member.next)
3975 if(!member.isProperty)
3977 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
3982 for(cfg : project.configurations)
3984 if(cfg != firstConfig)
3986 if(cfg.options.targetType != staticLibrary)
3990 if(type.type == noHeadClass || type.type == normalClass)
3992 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
3993 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
3994 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
3998 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
3999 (byte *)firstConfig.options + member.offset + member._class.offset,
4000 (byte *)cfg.options + member.offset + member._class.offset);
4012 if(type.type == noHeadClass || type.type == normalClass)
4014 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4015 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4016 *(void **)((byte *)nullOptions + member.offset + member._class.offset)))
4021 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4022 (byte *)firstConfig.options + member.offset + member._class.offset,
4023 (byte *)nullOptions + member.offset + member._class.offset))
4027 if(!project.options) project.options = { };
4029 /*if(type.type == noHeadClass || type.type == normalClass)
4031 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4032 (byte *)project.options + member.offset + member._class.offset,
4033 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
4037 void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
4038 // TOFIX: ListBox::SetData / OnCopy mess
4039 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4040 (byte *)project.options + member.offset + member._class.offset,
4041 (type.typeSize > 4) ? address :
4042 ((type.typeSize == 4) ? (void *)*(uint32 *)address :
4043 ((type.typeSize == 2) ? (void *)*(uint16*)address :
4044 (void *)*(byte *)address )));
4047 (byte *)project.options + member.offset + member._class.offset,
4048 (byte *)firstConfig.options + member.offset + member._class.offset, type.typeSize);
4050 for(cfg : project.configurations)
4052 if(cfg.options.targetType == staticLibrary)
4056 if(type.type == noHeadClass || type.type == normalClass)
4058 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4059 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4060 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4064 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4065 (byte *)firstConfig.options + member.offset + member._class.offset,
4066 (byte *)cfg.options + member.offset + member._class.offset);
4071 if(cfg != firstConfig)
4073 if(type.type == noHeadClass || type.type == normalClass)
4075 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4076 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4080 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4081 (byte *)cfg.options + member.offset + member._class.offset);
4083 memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
4086 memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
4093 // Compare Platform Specific Settings
4096 for(cfg : project.configurations)
4098 if(cfg != firstConfig && cfg.options.targetType != staticLibrary && (firstConfig.platforms || cfg.platforms) &&
4099 ((!firstConfig.platforms && cfg.platforms) || firstConfig.platforms.OnCompare(cfg.platforms)))
4105 if(same && firstConfig.platforms)
4107 for(cfg : project.configurations)
4109 if(cfg.options.targetType == staticLibrary && firstConfig.platforms.OnCompare(cfg.platforms))
4111 if(cfg != firstConfig)
4113 cfg.platforms.Free();
4114 delete cfg.platforms;
4117 project.platforms = firstConfig.platforms;
4118 firstConfig.platforms = null;
4122 // Static libraries can't contain libraries
4123 for(cfg : project.configurations)
4125 if(cfg.options.targetType == staticLibrary)
4127 if(!cfg.options.libraries) cfg.options.libraries = { };
4128 cfg.options.libraries.Free();
4134 Project LoadProject(char * filePath, char * activeConfigName)
4136 Project project = null;
4137 File f = FileOpen(filePath, read);
4140 project = LegacyBinaryLoadProject(f, filePath);
4143 JSONParser parser { f = f };
4144 JSONResult result = parser.GetObject(class(Project), &project);
4147 char insidePath[MAX_LOCATION];
4149 delete project.topNode.files;
4150 if(!project.files) project.files = { };
4151 project.topNode.files = project.files;
4152 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4153 delete project.resNode.path;
4154 project.resNode.path = project.resourcesPath;
4155 project.resourcesPath = null;
4156 project.resNode.nodeType = (ProjectNodeType)-1;
4157 delete project.resNode.files;
4158 project.resNode.files = project.resources;
4159 project.files = null;
4160 project.resources = null;
4161 if(!project.configurations) project.configurations = { };
4164 char topNodePath[MAX_LOCATION];
4165 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
4166 MakeSlashPath(topNodePath);
4167 PathCatSlash(topNodePath, filePath);
4168 project.filePath = topNodePath;//filePath;
4171 project.topNode.FixupNode(insidePath);
4176 project = LegacyAsciiLoadProject(f, filePath);
4182 if(!project.options) project.options = { };
4183 if(activeConfigName && activeConfigName[0] && project.configurations)
4185 for(cfg : project.configurations)
4187 if(!strcmpi(cfg.name, activeConfigName))
4189 project.config = cfg;
4194 if(!project.config && project.configurations)
4195 project.config = project.configurations.firstIterator.data;
4197 if(!project.resNode)
4199 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4202 if(!project.moduleName)
4203 project.moduleName = CopyString(project.name);
4204 if(project.config &&
4205 (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
4206 (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
4208 //delete project.config.options.targetFileName;
4210 project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
4211 project.config.options.optimization = none;
4212 project.config.options.debug = true;
4213 //project.config.options.warnings = unset;
4214 project.config.options.memoryGuard = false;
4215 project.config.compilingModified = true;
4216 project.config.linkingModified = true;
4218 else if(!project.topNode.name && project.config)
4220 project.topNode.name = CopyString(project.config.options.targetFileName);
4223 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
4224 project.topNode.configurations = project.configurations;
4225 project.topNode.platforms = project.platforms;
4226 project.topNode.options = project.options;*/