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 __attribute__((unused)) 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 #ifndef MAKEFILE_GENERATOR
46 IDESettings settings = (IDESettings)data;
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<const 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 { noPrint, objects, cObjects, symbols, imports, sources, resources, eCsources, rcSources };
411 define WorkspaceExtension = "ews";
412 define ProjectExtension = "epj";
414 define stringInFileIncludedFrom = "In file included from ";
415 define stringFrom = " from ";
417 // chars refused for project name: windowsFileNameCharsNotAllowed + " &,."
419 //define gnuMakeCharsNeedEscaping = "$%";
421 //define windowsFileNameCharsNotAllowed = "*/:<>?\\\"|";
422 //define linuxFileNameCharsNotAllowed = "/";
424 //define windowsFileNameCharsNeedEscaping = " !%&'()+,;=[]^`{}~"; // "#$-.@_" are ok
425 //define linuxFileNameCharsNeedEscaping = " !\"$&'()*:;<=>?[\\`{|"; // "#%+,-.@]^_}~" are ok
427 // NOTES: - this function should get only unescaped unix style paths
428 // - paths with literal $(somestring) in them are not supported
429 // my_$(messed_up)_path would likely become my__path
430 void EscapeForMake(char * output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
432 char ch, *o = output;
433 const char *i = input;
436 int len = strlen(input);
437 if(len && ((input[0] == '"' && input[len-1] == '"') || strchr(input, '\\') || strchr(input, 127) || (!allowDblQuote && strchr(input, '"'))))
438 PrintLn("Invalid input for EscapeForMake! -- ", input);
444 if(i-1 != input && *(i-2) == '$' && allowVars)
451 if(inVar == true && allowVars)
456 else if(ch == '$' && *i != '(')
478 void EscapeForMakeToFile(File output, char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
480 char * buf = new char[strlen(input)*2+1];
481 EscapeForMake(buf, input, hideSpace, allowVars, allowDblQuote);
486 void EscapeForMakeToDynString(DynamicString output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
488 char * buf = new char[strlen(input)*2+1];
489 EscapeForMake(buf, input, hideSpace, allowVars, allowDblQuote);
494 int OutputFileList(File f, const char * name, Array<String> list, Map<String, int> varStringLenDiffs, const char * prefix)
497 const int breakListLength = 1536;
498 const int breakLineLength = 78; // TODO: turn this into an option.
500 int c, len, itemCount = 0;
501 Array<int> breaks { };
505 MapNode<String, int> mn;
506 for(c=0; c<list.count; c++)
508 len = strlen(list[c]) + 3;
509 if(strstr(list[c], "$(") && varStringLenDiffs && varStringLenDiffs.count)
511 for(mn = varStringLenDiffs.root.minimum; mn; mn = mn.next)
513 if(strstr(list[c], mn.key))
517 if(charCount + len > breakListLength)
519 breaks.Add(itemCount);
527 breaks.Add(itemCount);
528 numOfBreaks = breaks.count;
533 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
534 for(c=0; c<numOfBreaks; c++)
535 f.Printf(" $(%s%d)", name, c+1);
539 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
545 for(c=0; c<numOfBreaks; c++)
548 f.Printf("%s%d =", name, c+1);
551 itemCount = breaks[c];
552 for(n=offset; n<offset+itemCount; n++)
554 if(false) // TODO: turn this into an option.
556 int itemLen = strlen(list[n]);
557 if(len > 3 && len + itemLen > breakLineLength)
559 f.Printf(" \\\n\t%s", list[n]);
565 f.Printf(" %s", list[n]);
569 f.Printf(" \\\n\t%s", list[n]);
584 void OutputFileListActions(File f, const char * name, int parts, const char * fileName)
589 for(c=0; c<parts; c++)
590 f.Printf("\t$(call addtolistfile,$(%s%d),%s)\n", name, c+1, fileName);
594 f.Printf("\t$(call addtolistfile,$(%s),%s)\n", name, fileName);
598 void OutputCleanActions(File f, const char * name, int parts)
603 for(c=0; c<parts; c++)
604 f.Printf("\t$(call rm,$(_%s%d))\n", name, c+1);
607 f.Printf("\t$(call rm,$(_%s))\n", name);
610 enum LineOutputMethod { inPlace, newLine, lineEach };
611 enum StringOutputMethod { asIs, escape, escapePath};
613 enum ToolchainFlag { any, _D, _I, _isystem, _Wl, _L/*, _Wl-rpath*/ };
614 const String flagNames[ToolchainFlag] = { "", "-D", "-I", "-isystem ", "-Wl,", /*"-Wl,--library-path="*/"-L"/*, "-Wl,-rpath "*/ };
615 void OutputFlags(File f, ToolchainFlag flag, Array<String> list, LineOutputMethod lineMethod)
619 if(lineMethod == newLine)
623 if(lineMethod == lineEach)
625 f.Printf(" %s", flagNames[flag]);
626 if(flag != _D && flag != _Wl && flag != any)
628 char * tmp = new char[strlen(item)*2+1];
629 EscapeForMake(tmp, item, false, true, false);
630 f.Printf("$(call quote_path,%s)", tmp);
634 EscapeForMakeToFile(f, item, false, true, true);
639 static void OutputLibraries(File f, Array<String> libraries)
641 for(item : libraries)
643 char ext[MAX_EXTENSION];
644 char temp[MAX_LOCATION];
646 bool usedFunction = false;
647 GetExtension(item, ext);
648 if(!strcmp(ext, "o") || !strcmp(ext, "a"))
652 if(!strcmp(ext, "so") || !strcmp(ext, "dylib"))
654 if(!strncmp(item, "lib", 3))
655 strcpy(temp, item + 3);
658 StripExtension(temp);
661 f.Puts(" \\\n\t$(call _L,");
664 EscapeForMakeToFile(f, s, false, false, false);
670 void CamelCase(char * string)
674 int c, len = strlen(string);
675 for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
676 string[c] = (char)tolower(string[c]);
680 CompilerConfig GetCompilerConfig()
682 #ifndef MAKEFILE_GENERATOR
683 CompilerConfig compiler = null;
684 if(ide && ide.workspace)
685 compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
688 incref defaultCompiler;
689 return defaultCompiler;
695 #ifdef MAKEFILE_GENERATOR
696 return 0; // todo: improve this somehow? add bit depth command line option?
698 return ide.workspace.bitDepth;
702 define localTargetType = config && config.options && config.options.targetType ?
703 config.options.targetType : options && options.targetType ?
704 options.targetType : TargetTypes::executable;
705 define localWarnings = config && config.options && config.options.warnings ?
706 config.options.warnings : options && options.warnings ?
707 options.warnings : WarningsOption::unset;
708 define localDebug = config && config.options && config.options.debug ?
709 config.options.debug : options && options.debug ?
710 options.debug : SetBool::unset;
711 define localMemoryGuard = config && config.options && config.options.memoryGuard ?
712 config.options.memoryGuard : options && options.memoryGuard ?
713 options.memoryGuard : SetBool::unset;
714 define localNoLineNumbers = config && config.options && config.options.noLineNumbers ?
715 config.options.noLineNumbers : options && options.noLineNumbers ?
716 options.noLineNumbers : SetBool::unset;
717 define localProfile = config && config.options && config.options.profile ?
718 config.options.profile : options && options.profile ?
719 options.profile : SetBool::unset;
720 define localOptimization = config && config.options && config.options.optimization ?
721 config.options.optimization : options && options.optimization ?
722 options.optimization : OptimizationStrategy::none;
723 define localFastMath = config && config.options && config.options.fastMath ?
724 config.options.fastMath : options && options.fastMath ?
725 options.fastMath : SetBool::unset;
726 define localDefaultNameSpace = config && config.options && config.options.defaultNameSpace ?
727 config.options.defaultNameSpace : options && options.defaultNameSpace ?
728 options.defaultNameSpace : null;
729 define localStrictNameSpaces = config && config.options && config.options.strictNameSpaces ?
730 config.options.strictNameSpaces : options && options.strictNameSpaces ?
731 options.strictNameSpaces : SetBool::unset;
732 // TODO: I would rather have null here, check if it'll be ok, have the property return "" if required
733 define localTargetFileName = config && config.options && config.options.targetFileName ?
734 config.options.targetFileName : options && options.targetFileName ?
735 options.targetFileName : "";
736 define localTargetDirectory = config && config.options && config.options.targetDirectory && config.options.targetDirectory[0] ?
737 config.options.targetDirectory : options && options.targetDirectory && options.targetDirectory[0] ?
738 options.targetDirectory : null;
739 define settingsTargetDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
740 ideSettings.projectDefaultIntermediateObjDir[0] ?
741 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
742 define localObjectsDirectory = config && config.options && config.options.objectsDirectory && config.options.objectsDirectory[0] ?
743 config.options.objectsDirectory : options && options.objectsDirectory && options.objectsDirectory[0] ?
744 options.objectsDirectory : null;
745 define settingsObjectsDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
746 ideSettings.projectDefaultIntermediateObjDir[0] ?
747 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
748 define localConsole = config && config.options && config.options.console ?
749 config.options.console : options && options.console ?
750 options.console : SetBool::unset;
751 define localCompress = config && config.options && config.options.compress ?
752 config.options.compress : options && options.compress ?
753 options.compress : SetBool::unset;
755 define platformTargetType =
756 configPOs && configPOs.options && configPOs.options.targetType && configPOs.options.targetType != localTargetType ?
757 configPOs.options.targetType :
758 projectPOs && projectPOs.options && projectPOs.options.targetType && projectPOs.options.targetType != localTargetType ?
759 projectPOs.options.targetType : TargetTypes::unset;
762 const char * PlatformToMakefileTargetVariable(Platform platform)
764 return platform == win32 ? "WINDOWS_TARGET" :
765 platform == tux ? "LINUX_TARGET" :
766 platform == apple ? "OSX_TARGET" :
770 const char * TargetTypeToMakefileVariable(TargetTypes targetType)
772 return targetType == executable ? "executable" :
773 targetType == sharedLibrary ? "sharedlib" :
774 targetType == staticLibrary ? "staticlib" :
778 // Move this to ProjectConfig? null vs Common to consider...
779 const char * GetConfigName(ProjectConfig config)
781 return config ? config.name : "Common";
784 public enum SingleFileCompileMode
786 normal, debugPrecompile, debugCompile, debugGenerateSymbols, cObject;
788 property bool eC_ToolsDebug { get { return this == debugCompile || this == debugGenerateSymbols || this == debugPrecompile; } }
791 class Project : struct
793 class_no_expansion; // To use Find on the Container<Project> in Workspace::projects
794 // We might want to tweak this default behavior of regular classes ?
795 // Expansion/the current default kind of Find matching we want for things like BitmapResource, FontResource (Also regular classes)
800 property const char * moduleVersion
802 set { delete moduleVersion; if(value && value[0]) moduleVersion = CopyString(value); } // TODO: use CopyString function that filters chars
803 get { return moduleVersion ? moduleVersion : ""; } // version number should only use digits and dots
804 isset { return moduleVersion != null && moduleVersion[0]; } // add leading/trailing 0 if value start/ends with dot(s)
807 property const char * description
809 set { delete description; if(value && value[0]) description = CopyString(value); }
810 get { return description ? description : ""; }
811 isset { return description != null && description[0]; }
814 property const char * license
816 set { delete license; if(value && value[0]) license = CopyString(value); }
817 get { return license ? license : ""; }
818 isset { return license != null && license[0]; }
821 property const char * compilerConfigsDir
823 set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
824 get { return compilerConfigsDir ? compilerConfigsDir : ""; }
825 isset { return compilerConfigsDir && compilerConfigsDir[0]; }
828 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
829 property Array<PlatformOptions> platforms
831 get { return platforms; }
834 if(platforms) { platforms.Free(); delete platforms; }
837 List<PlatformOptions> empty { };
838 Iterator<PlatformOptions> it { value };
840 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
841 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
851 if(p.options && !p.options.isEmpty)
858 List<ProjectConfig> configurations;
859 LinkList<ProjectNode> files;
860 String resourcesPath;
861 LinkList<ProjectNode> resources;
864 // topNode.name holds the file name (.epj)
865 ProjectOptions options;
866 Array<PlatformOptions> platforms;
867 ProjectNode topNode { type = project, icon = epjFile, files = LinkList<ProjectNode>{ }, project = this };
870 ProjectConfig config;
872 // This is the file name stripped of the epj extension
873 // It should NOT be edited, saved or loaded anywhere
878 String compilerConfigsDir;
879 String moduleVersion;
881 String lastBuildConfigName;
882 String lastBuildCompilerName;
884 Map<String, Map<String, NameCollisionInfo>> configsNameCollisions { };
886 #ifndef MAKEFILE_GENERATOR
887 FileMonitor fileMonitor
889 this, FileChange { modified = true };
890 bool OnFileNotify(FileChange action, const char * param)
892 fileMonitor.StopMonitoring();
893 if(OnProjectModified(action, param))
894 fileMonitor.StartMonitoring();
899 bool StartMonitoring()
901 fileMonitor.fileName = filePath;
902 fileMonitor.StartMonitoring();
906 bool StopMonitoring()
908 fileMonitor.StopMonitoring();
912 bool OnProjectModified(FileChange fileChange, const char * param)
915 sprintf(temp, $"The project %s was modified by another application.\n"
916 "Would you like to reload it and lose your changes?", name);
917 if(MessageBox { type = yesNo, master = ide,
918 text = $"Project has been modified", contents = temp }.Modal() == yes)
920 Project project = LoadProject(filePath, config ? config.name : null);
923 ProjectView projectView = ide.projectView;
924 DataRow prev = topNode.row ? topNode.row.previous : null;
925 FileMonitor fm = fileMonitor;
926 bool confirmation = true;
930 if(projectView.projectSettingsDialog)
932 confirmation = projectView.projectSettingsDialog.CloseConfirmation(true);
934 projectView.projectSettingsDialog.Destroy(0);
937 projectView.DeleteNode(topNode);
944 topNode.project = this;
948 CompilerConfig compiler = ideSettings.GetCompilerConfig(projectView.workspace.compiler);
949 projectView.AddNode(topNode, null);
950 topNode.row.Move(prev);
952 projectView.ShowOutputBuildLog(true);
953 projectView.DisplayCompiler(compiler, false);
954 projectView.ProjectUpdateMakefileForAllConfigs(this);
957 eSystem_Delete(project);
964 return !ide.destroyed;
969 // This frees contents without freeing the instance
970 // For use from destructor and for file monitor reloading
971 // (To work around JSON loader (LoadProject) always returning a new instance)
974 if(platforms) { platforms.Free(); delete platforms; }
975 if(configurations) { configurations.Free(); delete configurations; }
976 if(files) { files.Free(); delete files; }
977 if(resources) { resources.Free(); delete resources; }
979 delete resourcesPath;
983 delete compilerConfigsDir;
985 delete moduleVersion;
989 delete lastBuildConfigName;
990 delete lastBuildCompilerName;
991 for(map : configsNameCollisions)
993 configsNameCollisions.Free();
998 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
999 topNode.configurations = null;
1000 topNode.platforms = null;
1001 topNode.options = null;
1006 property ProjectConfig config
1011 delete topNode.info;
1012 topNode.info = CopyString(GetConfigName(config));
1016 property const char * filePath
1022 char string[MAX_LOCATION];
1023 GetLastDirectory(value, string);
1024 delete topNode.name;
1025 topNode.name = CopyString(string);
1026 StripExtension(string);
1028 name = CopyString(string);
1029 StripLastDirectory(value, string);
1030 delete topNode.path;
1031 topNode.path = CopyString(string);
1033 filePath = CopyString(value);
1038 ProjectConfig GetConfig(const char * configName)
1040 ProjectConfig result = null;
1041 if(configName && configName[0] && configurations.count)
1043 for(cfg : configurations; !strcmpi(cfg.name, configName))
1052 ProjectNode FindNodeByObjectFileName(const char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config, const char * objectFileExt)
1055 const char * cfgName;
1057 config = this.config;
1058 cfgName = config ? config.name : "";
1059 if(!configsNameCollisions[cfgName])
1060 ProjectLoadLastBuildNamesInfo(this, config);
1061 result = topNode.FindByObjectFileName(fileName, type, dotMain, configsNameCollisions[cfgName], objectFileExt);
1065 TargetTypes GetTargetType(ProjectConfig config)
1067 TargetTypes targetType = localTargetType;
1071 bool GetTargetTypeIsSetByPlatform(ProjectConfig config)
1074 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
1076 PlatformOptions projectPOs, configPOs;
1077 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
1078 if(platformTargetType)
1084 const char * GetObjDirExpression(ProjectConfig config)
1086 // TODO: Support platform options
1087 const char * expression = localObjectsDirectory;
1089 expression = settingsObjectsDirectory;
1093 DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1095 const char * expression = GetObjDirExpression(config);
1096 DirExpression objDir { type = intermediateObjectsDir };
1097 objDir.Evaluate(expression, this, compiler, config, bitDepth);
1101 const char * GetTargetDirExpression(ProjectConfig config)
1103 // TODO: Support platform options
1104 const char * expression = localTargetDirectory;
1106 expression = settingsTargetDirectory;
1110 DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1112 const char * expression = GetTargetDirExpression(config);
1113 DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
1114 targetDir.Evaluate(expression, this, compiler, config, bitDepth);
1118 WarningsOption GetWarnings(ProjectConfig config)
1120 WarningsOption warnings = localWarnings;
1124 bool GetDebug(ProjectConfig config)
1126 SetBool debug = localDebug;
1127 return debug == true;
1130 bool GetMemoryGuard(ProjectConfig config)
1132 SetBool memoryGuard = localMemoryGuard;
1133 return memoryGuard == true;
1136 bool GetNoLineNumbers(ProjectConfig config)
1138 SetBool noLineNumbers = localNoLineNumbers;
1139 return noLineNumbers == true;
1142 bool GetProfile(ProjectConfig config)
1144 SetBool profile = localProfile;
1145 return profile == true;
1148 OptimizationStrategy GetOptimization(ProjectConfig config)
1150 OptimizationStrategy optimization = localOptimization;
1151 return optimization;
1154 bool GetFastMath(ProjectConfig config)
1156 SetBool fastMath = localFastMath;
1157 return fastMath == true;
1160 const String GetDefaultNameSpace(ProjectConfig config)
1162 const String defaultNameSpace = localDefaultNameSpace;
1163 return defaultNameSpace;
1166 bool GetStrictNameSpaces(ProjectConfig config)
1168 SetBool strictNameSpaces = localStrictNameSpaces;
1169 return strictNameSpaces == true;
1172 const String GetTargetFileName(ProjectConfig config)
1174 const String targetFileName = localTargetFileName;
1175 return targetFileName;
1178 //String targetDirectory;
1179 //String objectsDirectory;
1180 bool GetConsole(ProjectConfig config)
1182 SetBool console = localConsole;
1183 return console == true;
1186 bool GetCompress(ProjectConfig config)
1188 SetBool compress = localCompress;
1189 return compress == true;
1191 //SetBool excludeFromBuild;
1193 bool GetConfigIsInActiveDebugSession(ProjectConfig config)
1195 #ifndef MAKEFILE_GENERATOR
1196 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
1202 bool GetConfigIsInDebugSession(ProjectConfig config)
1204 #ifndef MAKEFILE_GENERATOR
1205 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
1211 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
1213 #ifndef MAKEFILE_GENERATOR
1214 ide.SetPath(projectsDirs, compiler, config, bitDepth);
1218 #ifndef MAKEFILE_GENERATOR
1219 bool Save(const char * fileName)
1222 /*char output[MAX_LOCATION];
1223 ChangeExtension(fileName, "json", output);
1224 f = FileOpen(output, write);*/
1225 f = FileOpen(fileName, write);
1228 files = topNode.files;
1229 resources = resNode.files;
1230 resourcesPath = resNode.path;
1232 files.Remove(resNode);
1235 WriteJSONObject(f, class(Project), this, 0);
1241 resourcesPath = null;
1248 void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
1250 TargetTypes targetType = GetTargetType(config);
1251 const String targetFileName = GetTargetFileName(config);
1252 if(targetType == staticLibrary)
1254 PathCatSlash(string, "lib");
1255 strcat(string, targetFileName);
1257 else if(compiler.targetPlatform != win32 && targetType == sharedLibrary)
1259 PathCatSlash(string, "lib");
1260 strcat(string, targetFileName);
1263 PathCatSlash(string, targetFileName);
1268 if(compiler.targetPlatform == win32)
1269 strcat(string, ".exe");
1272 if(compiler.targetPlatform == win32)
1273 strcat(string, ".dll");
1274 else if(compiler.targetPlatform == apple)
1275 strcat(string, ".dylib");
1277 strcat(string, ".so");
1278 if(compiler.targetPlatform == tux && __runtimePlatform == tux && moduleVersion && moduleVersion[0])
1280 strcat(string, ".");
1281 strcat(string, moduleVersion);
1285 strcat(string, ".a");
1290 bool GetProjectCompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1292 bool result = false;
1293 char temp[MAX_LOCATION];
1294 strcpy(cfDir, topNode.path);
1295 if(compilerConfigsDir && compilerConfigsDir[0])
1297 PathCatSlash(cfDir, compilerConfigsDir);
1302 strcpy(temp, cfDir);
1303 // Using a relative path makes it less likely to run into spaces issues
1304 // Even with escaped spaces, there still seems to be issues including a config file
1305 // in a path containing spaces
1307 MakePathRelative(temp, topNode.path, cfDir);
1310 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1314 strcpy(temp, cfDir);
1315 ReplaceSpaces(cfDir, temp);
1320 bool GetIDECompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1322 char temp[MAX_LOCATION];
1323 bool result = false;
1324 strcpy(cfDir, topNode.path);
1325 if(ideSettings && ideSettings.compilerConfigsDir && ideSettings.compilerConfigsDir[0])
1327 PathCatSlash(cfDir, ideSettings.compilerConfigsDir);
1332 // Default to <ProjectDir>/.configs if unset
1333 PathCatSlash(cfDir, ".configs");
1338 strcpy(temp, cfDir);
1339 // Using a relative path makes it less likely to run into spaces issues
1340 // Even with escaped spaces, there still seems to be issues including a config file
1341 // in a path containing spaces
1342 if(IsPathInsideOf(cfDir, topNode.path))
1343 MakePathRelative(temp, topNode.path, cfDir);
1345 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1349 strcpy(temp, cfDir);
1350 ReplaceSpaces(cfDir, temp);
1355 void CatMakeFileName(char * string, ProjectConfig config)
1357 char projectName[MAX_LOCATION];
1358 strcpy(projectName, name);
1359 sprintf(string, "%s%s%s.Makefile", projectName, config ? "-" : "", config ? config.name : "");
1362 #ifndef MAKEFILE_GENERATOR
1363 ProjectNode GetObjectFileNode(const char * filePath, const char * objectFileExt)
1365 ProjectNode node = null;
1366 char ext[MAX_EXTENSION];
1367 GetExtension(filePath, ext);
1370 IntermediateFileType type = IntermediateFileType::FromExtension(ext);
1373 char fileName[MAX_FILENAME];
1374 GetLastDirectory(filePath, fileName);
1377 DotMain dotMain = DotMain::FromFileName(fileName);
1378 node = FindNodeByObjectFileName(fileName, type, dotMain, null, objectFileExt);
1385 bool GetAbsoluteFromRelativePath(const char * relativePath, char * absolutePath, const char * objectFileExt)
1387 ProjectNode node = topNode.FindWithPath(relativePath, false);
1389 node = GetObjectFileNode(relativePath, objectFileExt);
1392 strcpy(absolutePath, node.project.topNode.path);
1393 PathCat(absolutePath, relativePath);
1394 MakeSlashPath(absolutePath);
1396 return node != null;
1399 void MarkChanges(ProjectNode node)
1401 for(cfg : topNode.configurations)
1403 ProjectConfig c = null;
1404 for(i : node.configurations; !strcmpi(i.name, cfg.name)) { c = i; break; }
1406 if(c && ((c.options && cfg.options && cfg.options.console != c.options.console) ||
1407 (!c.options || !cfg.options)))
1408 cfg.symbolGenModified = true;
1409 if(c && ((c.options && cfg.options &&
1410 ( (cfg.options.libraries && c.options.libraries && cfg.options.libraries.OnCompare(c.options.libraries)) || (!cfg.options.libraries || !c.options.libraries)) )
1411 || (!c.options || !cfg.options)))
1412 cfg.linkingModified = true;
1414 cfg.makingModified = true;
1418 void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
1420 Map<String, NameCollisionInfo> cfgNameCollision;
1421 MapIterator<const String, Map<String, NameCollisionInfo>> it { map = configsNameCollisions };
1422 if(it.Index("", false))
1424 cfgNameCollision = it.data;
1425 cfgNameCollision.Free();
1426 delete cfgNameCollision;
1429 for(cfg : configurations)
1433 cfg.makingModified = true;
1434 if(it.Index(cfg.name, false))
1436 cfgNameCollision = it.data;
1437 cfgNameCollision.Free();
1438 delete cfgNameCollision;
1443 cfg.compilingModified = true;
1445 cfg.linkingModified = true;
1447 cfg.symbolGenModified = true;
1449 if(compiling || linking)
1451 ide.projectView.modifiedDocument = true;
1452 ide.workspace.modified = true;
1456 void RotateActiveConfig(bool forward, bool syncAllProjects)
1458 if(configurations.first && configurations.last != configurations.first)
1460 Iterator<ProjectConfig> cfg { configurations };
1461 while(forward ? cfg.Next() : cfg.Prev())
1462 if(cfg.data == config)
1477 ide.workspace.SelectActiveConfig(cfg.data.name);
1480 property::config = cfg.data;
1481 ide.UpdateToolBarActiveConfigs(true);
1482 ide.workspace.modified = true;
1483 ide.projectView.Update(null);
1488 bool ProcessPipeOutputRaw(DualPipe f)
1491 while(!f.Eof() && !ide.projectView.stopBuild)
1494 double lastTime = GetTime();
1498 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1500 ide.outputView.buildBox.Logf("%s\n", line);
1502 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1504 //printf("Processing Input...\n");
1505 if(app.ProcessInput(true))
1507 app.UpdateDisplay();
1510 //printf("Waiting...\n");
1513 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1515 if(ide.projectView.stopBuild)
1517 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1520 return !ide.projectView.stopBuild;
1523 bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, BuildType buildType, List<ProjectNode> onlyNodes,
1524 CompilerConfig compiler, ProjectConfig config, int bitDepth)
1528 bool compiling = false, linking = false, precompiling = false;
1529 int compilingEC = 0;
1530 int numErrors = 0, numWarnings = 0;
1531 bool loggedALine = false;
1532 int lenMakeCommand = strlen(compiler.makeCommand);
1534 const char * t, * s, * s2;
1535 char moduleName[MAX_FILENAME];
1536 const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
1538 DynamicString test { };
1539 DynamicString ecp { };
1540 DynamicString ecc { };
1541 DynamicString ecs { };
1542 DynamicString ear { };
1543 DynamicString prefix { };
1544 DynamicString cpp { };
1545 DynamicString cc { };
1546 DynamicString cxx { };
1547 DynamicString strip { };
1548 DynamicString ar { };
1549 DynamicString windres { };
1552 if(bitDepth == 64 && compiler.targetPlatform == win32)
1553 gnuToolchainPrefix = "x86_64-w64-mingw32-";
1554 else if(bitDepth == 32 && compiler.targetPlatform == win32)
1555 gnuToolchainPrefix = "i686-w64-mingw32-";
1557 ecp.concatx(compiler.ecpCommand, " ");
1558 ecc.concatx(compiler.eccCommand, " ");
1559 ecs.concatx(compiler.ecsCommand, " ");
1560 ear.concatx(compiler.earCommand, " ");
1563 compiler.ccacheEnabled ? "ccache " : "",
1564 compiler.distccEnabled ? "distcc " : "",
1565 gnuToolchainPrefix);
1567 cpp.concatx((String)prefix, compiler.cppCommand, " ");
1568 cc.concatx((String)prefix, compiler.ccCommand, " ");
1569 cxx.concatx((String)prefix, compiler.cxxCommand, " ");
1571 strip.concatx(gnuToolchainPrefix, "strip ");
1572 ar.concatx(gnuToolchainPrefix, "ar rcs");
1573 windres.concatx(gnuToolchainPrefix, "windres ");
1575 testLen = Max(testLen, ecp.size);
1576 testLen = Max(testLen, ecc.size);
1577 testLen = Max(testLen, ecs.size);
1578 testLen = Max(testLen, ear.size);
1579 testLen = Max(testLen, cpp.size);
1580 testLen = Max(testLen, cc.size);
1581 testLen = Max(testLen, cxx.size);
1582 testLen = Max(testLen, strip.size);
1583 testLen = Max(testLen, ar.size);
1584 testLen = Max(testLen, windres.size);
1585 testLen = Max(testLen, strlen("mkdir "));
1588 while(!f.Eof() && !ide.projectView.stopBuild)
1590 double lastTime = GetTime();
1592 while(!f.Eof() && !ide.projectView.stopBuild)
1595 bool lineDone = f.GetLinePeek(line + linePos, sizeof(line)-linePos-1, &nChars);
1599 Sleep(0.5 / PEEK_RESOLUTION);
1606 const char * message = null;
1607 const char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1608 const char * from = strstr(line, stringFrom);
1609 test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
1610 if((t = strstr(line, (s=": recipe for target"))) && (t = strstr(t+strlen(s), (s2 = " failed"))) && (t+strlen(s2))[0] == '\0')
1611 ; // ignore this new gnu make error but what is it about?
1612 else if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
1614 const char * moduleBackTick = strstr(line, "No rule to make target `");
1615 const char * module = moduleBackTick ? moduleBackTick : strstr(line, "No rule to make target '");
1619 module = strchr(module, moduleBackTick ? '`' : '\'') + 1;
1620 end = strchr(module, '\'');
1624 ide.outputView.buildBox.Logf($" %s: No such file or directory\n", module);
1625 // ide.outputView.buildBox.Logf("error: %s\n No such file or directory\n", module);
1631 //ide.outputView.buildBox.Logf("error: %s\n", line);
1635 else if(strstr(test, "mkdir ") == test);
1636 else if((t = strstr(line, "cd ")) && (t = strstr(line, "type ")) && (t = strstr(line, "nul ")) && (t = strstr(line, "copy ")) && (t = strstr(line, "cd ")));
1637 else if(strstr(test, ear) == test);
1638 else if(strstr(test, strip) == test);
1639 else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
1641 char * module = null;
1642 bool isPrecomp = false;
1645 if(strstr(test, cc) == test || strstr(test, cxx) == test)
1647 module = strstr(line, " -c ");
1648 if(module) module += 4;
1651 else if(strstr(test, ecc) == test)
1653 module = strstr(line, " -c ");
1654 if(module) module += 4;
1655 //module = line + 3;
1656 // Don't show GCC warnings about generated C code because it does not compile clean yet...
1657 compilingEC = 3;//2;
1660 else if(strstr(test, ecp) == test)
1662 // module = line + 8;
1663 module = strstr(line, " -c ");
1664 if(module) module += 4;
1675 if(!compiling && !isPrecomp)
1677 ide.outputView.buildBox.Logf($"Compiling...\n");
1680 else if(!precompiling && isPrecomp)
1682 ide.outputView.buildBox.Logf($"Generating symbols...\n");
1683 precompiling = true;
1685 Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
1686 GetLastDirectory(tokens[0], moduleName);
1687 ide.outputView.buildBox.Logf("%s\n", moduleName);
1689 else if((module = strstr(line, " -o ")))
1692 precompiling = false;
1694 ide.outputView.buildBox.Logf($"Linking...\n");
1698 ide.outputView.buildBox.Logf("%s\n", line);
1699 if(strstr(line, "warning:") || strstr(line, "note:"))
1701 else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
1705 if(compilingEC) compilingEC--;
1707 else if(strstr(test, windres) == test)
1710 module = strstr(line, " ");
1711 if(module) module++;
1715 char * dashF = strstr(module, "-F ");
1719 while(*dashF && *dashF != ' ') dashF++;
1720 while(*dashF && *dashF == ' ') dashF++;
1723 Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
1724 GetLastDirectory(module, moduleName);
1725 ide.outputView.buildBox.Logf("%s\n", moduleName);
1728 else if(strstr(test, ar) == test)
1729 ide.outputView.buildBox.Logf($"Building library...\n");
1730 else if(strstr(test, ecs) == test)
1731 ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
1734 if(linking || compiling || precompiling)
1736 const char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
1737 const char * colon = strstr(start, ":"); //, * bracket;
1738 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1739 colon = strstr(colon + 1, ":");
1742 const char * sayError = "";
1743 char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
1746 int len = (int)(colon - start);
1747 char ext[MAX_EXTENSION];
1748 len = Min(len, MAX_LOCATION-1);
1749 // Don't be mistaken by the drive letter colon
1751 // TODO: need to fix colon - line gives char *
1752 // warning: incompatible expression colon - line (char *); expected int
1754 strncpy(moduleName, line, (int)(colon - line));
1755 moduleName[colon - line] = '\0';
1757 strncpy(moduleName, start, len);
1758 moduleName[len] = '\0';
1759 // Remove stuff in brackets
1760 //bracket = strstr(moduleName, "(");
1761 //if(bracket) *bracket = '\0';
1763 GetLastDirectory(moduleName, temp);
1764 GetExtension(temp, ext);
1766 if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
1768 char * cColon = strstr(colon+1, ":");
1769 if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
1770 cColon = strstr(cColon + 1, ":");
1773 int len = (int)(cColon - (colon+1));
1774 char mName[MAX_LOCATION];
1775 len = Min(len, MAX_LOCATION-1);
1776 strncpy(mName, colon+1, len);
1778 GetLastDirectory(mName, temp);
1779 GetExtension(temp, ext);
1780 if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
1783 strcpy(moduleName, mName);
1787 if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
1790 if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
1792 message = $"Linker Message: ";
1795 else if(SearchString(colon, 0, "warning:", false, false))
1797 message = $"Linker Warning: ";
1803 message = $"Linker Error: ";
1806 else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
1810 if(strstr(colon, "Warning:") == colon)
1812 message = $"Linker ";
1815 else if(strstr(line, "error:"))
1817 message = $"Linker Error: ";
1823 strcpy(temp, topNode.path);
1824 PathCatSlash(temp, moduleName);
1825 MakePathRelative(temp, topNode.path, moduleName);
1827 error = strstr(line, "error:");
1828 if(!message && error && error > colon)
1832 // Silence warnings for compiled eC
1833 //char * objDir = strstr(moduleName, objDirExp.dir);
1837 if((pointer = strstr(line, "undefined")) ||
1838 (pointer = strstr(line, "multiple definition")) ||
1839 (pointer = strstr(line, "No such file")) ||
1840 (pointer = strstr(line, "token")))
1842 strncat(moduleName, colon, pointer - colon);
1843 sayError = "error: ";
1848 else if((pointer = strstr(line, "No such file")))
1850 strncat(moduleName, colon, pointer - colon);
1851 sayError = "error: ";
1855 else //if(compilingEC == 1 || (objDir && objDir == moduleName))
1859 // Filter out these warnings caused by eC generated C code:
1861 // Declaration ordering bugs -- Awaiting topo sort implementation
1863 if(strstr(line, "declared inside parameter list")) skip = true;
1864 else if(strstr(line, "its scope is only this definition")) skip = true;
1865 else if(strstr(line, "from incompatible pointer type")) skip = true;
1866 else if(strstr(line, "note: expected 'struct ") || strstr(line, "note: expected ‘struct "))
1868 #define STRUCT_A "'struct "
1869 #define STRUCT_B "‘struct "
1870 char * struct1, * struct2, ch1, ch2;
1871 struct1 = strstr(line, STRUCT_A);
1872 if(struct1) { struct1 += sizeof(STRUCT_A)-1; } else { struct1 = strstr(line, STRUCT_B); struct1 += sizeof(STRUCT_B)-1; };
1874 struct2 = strstr(struct1, STRUCT_A);
1875 if(struct2) { struct2 += sizeof(STRUCT_A)-1; } else { struct2 = strstr(struct1, STRUCT_B); if(struct2) struct2 += sizeof(STRUCT_B)-1; };
1877 if(struct1 && struct2)
1879 while(ch1 = *(struct1++), ch2 = *(struct2++), ch1 && ch2 && (ch1 == '_' || isalnum(ch1)) && (ch2 == '_' || isalnum(ch2)));
1885 // For preprocessed code from objidl.h (MinGW-w64 headers)
1886 else if(strstr(line, "declaration does not declare anything")) skip = true;
1888 // Location information that could apply to ignored warnings
1889 else if(strstr(line, "In function '") || strstr(line, "In function ‘") ) skip = true;
1890 else if(strstr(line, "At top level")) skip = true;
1891 else if(strstr(line, "(near initialization for '") || strstr(line, "(near initialization for ‘")) skip = true;
1896 /*else if(strstr(line, "warning:"))
1902 ide.outputView.buildBox.Logf(" %s%s\n", message, colon);
1903 /*else if(this == ide.workspace.projects.firstIterator.data)
1904 ide.outputView.buildBox.Logf(" %s%s%s\n", moduleName, sayError, colon);*/
1907 char fullModuleName[MAX_LOCATION];
1908 FileAttribs found = 0;
1909 //Project foundProject = this;
1912 char * loc = strstr(moduleName, ":");
1914 strcpy(fullModuleName, topNode.path);
1915 PathCat(fullModuleName, moduleName);
1916 found = FileExists(fullModuleName);
1917 if(!found && !strcmp(ext, "c"))
1919 char ecName[MAX_LOCATION];
1920 ChangeExtension(fullModuleName, "ec", ecName);
1921 found = FileExists(ecName);
1925 char path[MAX_LOCATION];
1926 if(ide && ide.workspace)
1928 for(prj : ide.workspace.projects)
1931 MakePathRelative(fullModuleName, prj.topNode.path, path);
1933 if((node = prj.topNode.FindWithPath(path, false)))
1935 strcpy(fullModuleName, prj.topNode.path);
1936 PathCatSlash(fullModuleName, node.path);
1937 PathCatSlash(fullModuleName, node.name);
1938 found = FileExists(fullModuleName);
1941 //foundProject = prj;
1946 if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
1948 for(prj : ide.workspace.projects)
1951 if((node = prj.topNode.Find(moduleName, false)))
1953 strcpy(fullModuleName, prj.topNode.path);
1954 PathCatSlash(fullModuleName, node.path);
1955 PathCatSlash(fullModuleName, node.name);
1956 found = FileExists(fullModuleName);
1959 //foundProject = prj;
1969 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
1970 MakeSystemPath(fullModuleName);
1973 strcpy(fullModuleName, moduleName);
1976 strcat(fullModuleName, ":");
1977 strcat(fullModuleName, loc + 1);
1981 fullModuleName[0] = 0;
1982 ide.outputView.buildBox.Logf(" %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
1987 ide.outputView.buildBox.Logf("%s\n", line);
1988 linking = compiling = precompiling = false;
1992 ide.outputView.buildBox.Logf("%s\n", line);
1997 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1999 //printf("Processing Input...\n");
2000 if(app.ProcessInput(true))
2002 app.UpdateDisplay();
2005 //printf("Waiting...\n");
2008 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
2010 if(ide.projectView.stopBuild)
2012 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
2015 else if(loggedALine || buildType != run)
2017 if(f.GetExitCode() && !numErrors)
2019 /*bool result = */f.GetLine(line, sizeof(line)-1);
2020 ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
2022 else if(buildType != install)
2026 char targetFileName[MAX_LOCATION];
2027 targetFileName[0] = '\0';
2028 CatTargetFileName(targetFileName, compiler, config);
2029 ide.outputView.buildBox.Logf("\n%s (%s) - ", targetFileName, lastBuildConfigName);
2032 ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
2034 ide.outputView.buildBox.Logf($"no error, ");
2037 ide.outputView.buildBox.Logf("%d %s\n", numWarnings, (numWarnings > 1) ? $"warnings" : $"warning");
2039 ide.outputView.buildBox.Logf($"no warning\n");
2056 return numErrors == 0 && !ide.projectView.stopBuild;
2059 void ProcessCleanPipeOutput(DualPipe f, CompilerConfig compiler, ProjectConfig config)
2062 int lenMakeCommand = strlen(compiler.makeCommand);
2067 double lastTime = GetTime();
2070 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
2072 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':');
2073 else if(strstr(line, "mkdir") == line);
2074 else if(strstr(line, "del") == line);
2075 else if(strstr(line, "rm") == line);
2076 else if(strstr(line, "Could Not Find") == line);
2079 ide.outputView.buildBox.Logf(line);
2080 ide.outputView.buildBox.Logf("\n");
2084 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
2086 if(app.ProcessInput(true))
2088 app.UpdateDisplay();
2091 //Sleep(1.0 / PEEK_RESOLUTION);
2095 bool Build(BuildType buildType, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, bool raw, SingleFileCompileMode mode)
2097 bool result = false;
2099 char targetFileName[MAX_LOCATION] = "";
2100 DynamicString makeTargets { };
2101 char makeFile[MAX_LOCATION];
2102 char makeFilePath[MAX_LOCATION];
2103 char configName[MAX_LOCATION];
2104 DirExpression objDirExp = GetObjDir(compiler, config, bitDepth);
2105 PathBackup pathBackup { };
2106 bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
2107 const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
2109 bool eC_Debug = mode.eC_ToolsDebug;
2110 bool singleProjectOnlyNode = onlyNodes && onlyNodes.count == 1 && onlyNodes[0].type == project;
2111 int numJobs = compiler.numJobs;
2112 char command[MAX_F_STRING*4];
2113 char * compilerName = CopyString(compiler.name);
2114 Map<String, NameCollisionInfo> cfgNameCollisions;
2115 const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) != 0 ? compiler.objectFileExt : null;
2117 delete lastBuildConfigName;
2118 lastBuildConfigName = CopyString(config ? config.name : "Common");
2119 delete lastBuildCompilerName;
2120 lastBuildCompilerName = CopyString(compiler.name);
2121 ProjectLoadLastBuildNamesInfo(this, config);
2122 cfgNameCollisions = configsNameCollisions[config ? config.name : ""];
2124 CamelCase(compilerName);
2126 strcpy(configName, config ? config.name : "Common");
2128 SetPath(false, compiler, config, bitDepth); //true
2129 CatTargetFileName(targetFileName, compiler, config);
2131 strcpy(makeFilePath, topNode.path);
2132 CatMakeFileName(makeFile, config);
2133 PathCatSlash(makeFilePath, makeFile);
2135 // TODO: TEST ON UNIX IF \" around makeTarget is ok
2136 if(buildType == install)
2137 makeTargets.concat(" install");
2140 if(compiler.type.isVC)
2142 PrintLn("compiling a single file is not yet supported");
2146 char pushD[MAX_LOCATION];
2147 char cfDir[MAX_LOCATION];
2148 GetIDECompilerConfigsDir(cfDir, true, true);
2149 GetWorkingDir(pushD, sizeof(pushD));
2150 ChangeWorkingDir(topNode.path);
2151 // Create object dir if it does not exist already
2152 if(!FileExists(objDirExp.dir).isDirectory)
2154 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s%s%s objdir -C \"%s\"%s -f \"%s\"",
2155 compiler.makeCommand, cfDir,
2156 crossCompiling ? " TARGET_PLATFORM=" : "",
2158 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2159 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" : */"",
2162 objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
2163 topNode.path, justPrint ? " -n" : "", makeFilePath);
2164 if(justPrint || raw)
2165 ide.outputView.buildBox.Logf("%s\n", command);
2169 ChangeWorkingDir(pushD);
2171 for(node : onlyNodes)
2173 if(node.GetIsExcludedForCompiler(config, compiler))
2174 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2178 node.DeleteIntermediateFiles(compiler, config, bitDepth, cfgNameCollisions, mode == cObject ? true : false);
2179 node.GetTargets(config, cfgNameCollisions, objDirExp.dir, compiler.objectFileExt, makeTargets);
2185 if(compiler.type.isVC)
2187 //bool result = false;
2188 char oldwd[MAX_LOCATION];
2189 GetWorkingDir(oldwd, sizeof(oldwd));
2190 ChangeWorkingDir(topNode.path);
2192 // TODO: support justPrint
2193 sprintf(command, "%s /useenv /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2194 if(justPrint || raw)
2195 ide.outputView.buildBox.Logf("%s\n", command);
2196 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
2198 ProcessPipeOutputRaw(f);
2202 ChangeWorkingDir(oldwd);
2204 else if(onlyNodes && strlen(makeTargets) == 0)
2206 ide.outputView.buildBox.Log("No targets to compile.\n");
2210 GccVersionInfo ccVersion = GetGccVersionInfo(compiler, compiler.ccCommand);
2211 GccVersionInfo cxxVersion = GetGccVersionInfo(compiler, compiler.cxxCommand);
2212 char cfDir[MAX_LOCATION];
2213 GetIDECompilerConfigsDir(cfDir, true, true);
2214 sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s%s COMPILER=%s%s%s %s%s%s-j%d %s%s%s -C \"%s\"%s -f \"%s\"",
2215 #if defined(__WIN32__)
2218 buildType == install ? "pkexec --user root " : "",
2220 compiler.makeCommand,
2221 mode == debugPrecompile ? "ECP_DEBUG=y " : mode == debugCompile ? "ECC_DEBUG=y " : mode == debugGenerateSymbols ? "ECS_DEBUG=y " : "",
2223 crossCompiling ? " TARGET_PLATFORM=" : "",
2225 bitDepth ? " ARCH=" : "",
2226 bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2227 ide.workspace.useValgrind ? " DISABLED_POOLING=1" : "",
2228 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
2230 objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
2231 eC_Debug ? "--always-make " : "",
2232 ccVersion == post4_8 ? "GCC_CC_FLAGS=-fno-diagnostics-show-caret " : "",
2233 cxxVersion == post4_8 ? "GCC_CXX_FLAGS=-fno-diagnostics-show-caret " : "",
2235 (compiler.ccacheEnabled && !eC_Debug) ? "CCACHE=y " : "",
2236 (compiler.distccEnabled && !eC_Debug) ? "DISTCC=y " : "",
2237 (String)makeTargets, topNode.path, (justPrint || eC_Debug) ? " -n" : "", makeFilePath);
2238 if(justPrint || raw)
2239 ide.outputView.buildBox.Logf("%s\n", command);
2241 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2249 ide.outputView.buildBox.Logf($"\nMake outputs the following list of commands to choose from:\n");
2255 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
2258 ide.outputView.buildBox.Logf("%s\n", line);
2259 if(!error && !found && strstr(line, "echo ") == line && strstr(line, "ECERE_SDK_SRC"))
2261 strcpy(command, line+5);
2264 if(!error && (singleProjectOnlyNode || !found) && strstr(line, "ecere-ide ") == line)
2266 strcpy(command, line);
2275 else if(justPrint || raw)
2276 result = ProcessPipeOutputRaw(f);
2278 result = ProcessBuildPipeOutput(f, objDirExp, buildType, onlyNodes, compiler, config, bitDepth);
2281 ide.outputView.buildBox.Logf("%s\n", command);
2282 else if(justPrint && found)
2283 ide.outputView.buildBox.Logf($"\nThe following command was chosen to be executed:\n%s\n", command);
2288 ide.outputView.buildBox.Logf($"Error executing make (%s) command\n", compiler.makeCommand);
2293 delete compilerName;
2298 void Clean(CompilerConfig compiler, ProjectConfig config, int bitDepth, CleanType cleanType, bool justPrint, bool raw)
2300 char makeFile[MAX_LOCATION];
2301 char makeFilePath[MAX_LOCATION];
2302 char command[MAX_LOCATION];
2303 char * compilerName;
2305 PathBackup pathBackup { };
2306 bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
2307 const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
2308 const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) ? compiler.objectFileExt : null;
2310 compilerName = CopyString(compiler.name);
2311 CamelCase(compilerName);
2313 SetPath(false, compiler, config, bitDepth);
2315 strcpy(makeFilePath, topNode.path);
2316 CatMakeFileName(makeFile, config);
2317 PathCatSlash(makeFilePath, makeFile);
2319 if(compiler.type.isVC)
2321 //bool result = false;
2322 char oldwd[MAX_LOCATION];
2323 GetWorkingDir(oldwd, sizeof(oldwd));
2324 ChangeWorkingDir(topNode.path);
2326 // TODO: justPrint support
2327 sprintf(command, "%s /useenv /clean /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2328 if(justPrint || raw)
2329 ide.outputView.buildBox.Logf("%s\n", command);
2330 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2332 ProcessPipeOutputRaw(f);
2336 ChangeWorkingDir(oldwd);
2341 char cfDir[MAX_LOCATION];
2342 GetIDECompilerConfigsDir(cfDir, true, true);
2343 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s%s%s %sclean%s -C \"%s\"%s -f \"%s\"",
2344 compiler.makeCommand, cfDir,
2345 crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
2346 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2348 objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
2349 cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
2350 topNode.path, justPrint ? " -n": "", makeFilePath);
2351 if(justPrint || raw)
2352 ide.outputView.buildBox.Logf("%s\n", command);
2353 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2355 ide.outputView.buildBox.Tellf($"Deleting %s%s...",
2356 cleanType == realClean ? $"intermediate objects directory" : $"target",
2357 cleanType == clean ? $" and object files" : "");
2358 if(justPrint || raw)
2359 ProcessPipeOutputRaw(f);
2361 ProcessCleanPipeOutput(f, compiler, config);
2362 ide.outputView.buildBox.Logf($"%s%s deleted\n",
2363 cleanType == realClean ? $"Intermediate objects directory" : $"Target",
2364 cleanType == clean ? $" and object files" : "");
2370 delete compilerName;
2373 void Run(const char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2375 String target = new char[maxPathLen];
2376 char oldDirectory[MAX_LOCATION];
2377 char * executableLauncher = compiler.executableLauncher;
2378 DirExpression targetDirExp = GetTargetDir(compiler, config, bitDepth);
2379 PathBackup pathBackup { };
2381 // Build(project, ideMain, true, null, false);
2383 strcpy(target, topNode.path);
2384 PathCatSlash(target, targetDirExp.dir);
2385 CatTargetFileName(target, compiler, config);
2386 sprintf(target, "%s %s", target, args);
2387 GetWorkingDir(oldDirectory, MAX_LOCATION);
2389 if(strlen(ide.workspace.debugDir))
2391 char temp[MAX_LOCATION];
2392 strcpy(temp, topNode.path);
2393 PathCatSlash(temp, ide.workspace.debugDir);
2394 ChangeWorkingDir(temp);
2397 ChangeWorkingDir(topNode.path);
2398 SetPath(true, compiler, config, bitDepth);
2399 if(executableLauncher)
2401 char * prefixedTarget = new char[strlen(executableLauncher) + strlen(target) + 8];
2402 prefixedTarget[0] = '\0';
2403 strcat(prefixedTarget, executableLauncher);
2404 strcat(prefixedTarget, " ");
2405 strcat(prefixedTarget, target);
2406 Execute(prefixedTarget);
2407 delete prefixedTarget;
2412 ChangeWorkingDir(oldDirectory);
2415 delete targetDirExp;
2419 bool Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, bool raw, SingleFileCompileMode mode)
2421 return Build(build, nodes, compiler, config, bitDepth, justPrint, raw, mode);
2425 void GetMakefileTargetFileName(TargetTypes targetType, char * fileName, ProjectConfig config)
2428 if(targetType == staticLibrary || targetType == sharedLibrary)
2429 strcat(fileName, "$(LP)");
2430 strcat(fileName, GetTargetFileName(config));
2431 strcat(fileName, "$(OUT)");
2434 bool GenerateCrossPlatformMk(File altCrossPlatformMk)
2436 bool result = false;
2437 char path[MAX_LOCATION];
2439 if(!GetProjectCompilerConfigsDir(path, false, false))
2440 GetIDECompilerConfigsDir(path, false, false);
2442 if(!FileExists(path).isDirectory)
2446 char dirName[MAX_FILENAME];
2447 GetLastDirectory(path, dirName);
2448 if(!strcmp(dirName, ".configs"))
2449 FileSetAttribs(path, FileAttribs { isHidden = true });
2452 PathCatSlash(path, "crossplatform.mk");
2454 if(FileExists(path))
2457 File include = altCrossPlatformMk ? altCrossPlatformMk : FileOpen(":crossplatform.mk", read);
2460 File f = FileOpen(path, write);
2463 include.Seek(0, start);
2464 for(; !include.Eof(); )
2467 int count = include.Read(buffer, 1, 4096);
2468 f.Write(buffer, 1, count);
2474 if(!altCrossPlatformMk)
2481 bool GenerateCompilerCf(CompilerConfig compiler, bool eC)
2483 bool result = false;
2484 char path[MAX_LOCATION];
2486 char * compilerName;
2487 bool gccCompiler = compiler.ccCommand && (strstr(compiler.ccCommand, "gcc") != null || strstr(compiler.ccCommand, "g++") != null);
2488 const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
2489 Platform platform = compiler.targetPlatform;
2491 compilerName = CopyString(compiler.name);
2492 CamelCase(compilerName);
2493 name = PrintString(platform, "-", compilerName, ".cf");
2495 if(!GetProjectCompilerConfigsDir(path, false, false))
2496 GetIDECompilerConfigsDir(path, false, false);
2498 if(!FileExists(path).isDirectory)
2502 char dirName[MAX_FILENAME];
2503 GetLastDirectory(path, dirName);
2504 if(!strcmp(dirName, ".configs"))
2505 FileSetAttribs(path, FileAttribs { isHidden = true });
2508 PathCatSlash(path, name);
2510 if(FileExists(path))
2513 File f = FileOpen(path, write);
2516 if(compiler.environmentVars && compiler.environmentVars.count)
2518 f.Puts("# ENVIRONMENT VARIABLES\n");
2520 for(e : compiler.environmentVars)
2522 #if defined(__WIN32__)
2523 ChangeCh(e.string, '\\', '/');
2525 f.Printf("export %s := %s\n", e.name, e.string);
2526 #if defined(__WIN32__)
2527 ChangeCh(e.string, '/', '\\');
2533 f.Puts("# TOOLCHAIN\n");
2536 f.Puts("# OPTIONS\n");
2537 if(compiler.resourcesDotEar)
2538 f.Puts("USE_RESOURCES_EAR := defined\n");
2541 f.Puts("# EXTENSIONS\n");
2542 if(compiler.outputFileExt)
2543 f.Printf("OUT := %s\n", compiler.outputFileExt);
2545 f.Puts("OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))\n");
2547 if(gnuToolchainPrefix && gnuToolchainPrefix[0])
2549 f.Printf("GCC_PREFIX := %s\n", gnuToolchainPrefix);
2552 if(compiler.sysroot && compiler.sysroot[0])
2554 f.Printf("SYSROOT := %s\n", compiler.sysroot);
2555 // Moved this to crossplatform.mk
2556 //f.Puts("_SYSROOT := $(space)--sysroot=$(SYSROOT)\n");
2560 //f.Printf("SHELL := %s\n", "sh"/*compiler.shellCommand*/); // is this really needed?
2561 f.Printf("CPP := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cppCommand);
2562 f.Printf("CC := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.ccCommand);
2563 f.Printf("CXX := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CXX_FLAGS),$(space)$(GCC_CXX_FLAGS),)\n", compiler.cxxCommand);
2566 f.Printf("ECP := $(if $(ECP_DEBUG),ecere-ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecp/ecp.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.ecpCommand);
2567 f.Printf("ECC := $(if $(ECC_DEBUG),ecere-ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecc/ecc.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.eccCommand);
2568 f.Printf("ECS := $(if $(ECS_DEBUG),ecere-ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecs/ecs.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)$(if $(DISABLED_POOLING), -disabled-pooling,)\n", compiler.ecsCommand);
2572 f.Printf("ECP := %s\n", compiler.ecpCommand);
2573 f.Printf("ECC := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
2574 f.Printf("ECS := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)$(if $(DISABLED_POOLING), -disabled-pooling,)\n", compiler.ecsCommand);
2576 f.Printf("EAR := %s\n", compiler.earCommand);
2578 f.Puts("AS := $(GCC_PREFIX)as\n");
2580 if(compiler.ldCommand && compiler.ldCommand[0])
2582 f.Puts("$(GCC_PREFIX)");
2583 f.Puts(compiler.ldCommand);
2586 f.Puts("$(if $(CONTAINS_CXX),$(CXX),$(CC))");
2587 f.Puts("$(_SYSROOT)$(if $(GCC_LD_FLAGS),$(space)$(GCC_LD_FLAGS),)\n");
2589 f.Printf("AR := $(GCC_PREFIX)%s\n", compiler.arCommand);
2590 f.Puts("STRIP := $(GCC_PREFIX)strip\n");
2591 f.Puts("ifdef WINDOWS_TARGET\n");
2592 f.Puts("WINDRES := $(GCC_PREFIX)windres\n");
2593 f.Puts(" ifdef ARCH\n");
2594 f.Puts(" ifeq ($(ARCH),x32)\n");
2595 f.Puts("WINDRES_FLAGS := -F pe-i386\n");
2597 f.Puts(" ifeq ($(ARCH),x64)\n");
2598 f.Puts("WINDRES_FLAGS := -F pe-x86-64\n");
2603 f.Puts("UPX := upx\n");
2606 f.Puts("UPXFLAGS = -9\n"); // TOFEAT: Compression Level Option? Other UPX Options?
2609 f.Puts("EARFLAGS = \n");
2612 f.Puts("ifndef ARCH\n");
2613 f.Puts("TARGET_ARCH :=$(shell $(CC) -dumpmachine)\n");
2614 f.Puts(" ifdef WINDOWS_HOST\n");
2615 f.Puts(" ifneq ($(filter x86_64%,$(TARGET_ARCH)),)\n");
2616 f.Puts(" TARGET_ARCH := x86_64\n");
2618 f.Puts(" TARGET_ARCH := i386\n");
2621 f.Puts("endif\n\n");
2623 f.Puts("# HARD CODED TARGET_PLATFORM-SPECIFIC OPTIONS\n");
2624 f.Printf("LDFLAGS +=$(if $(%s), -Wl$(comma)--no-undefined,)\n", PlatformToMakefileTargetVariable(tux));
2628 f.Printf("LDFLAGS +=$(if $(%s), -framework cocoa -framework OpenGL,)\n", PlatformToMakefileTargetVariable(apple));
2632 f.Puts("\nCFLAGS += -fmessage-length=0\n");
2635 if(compiler.includeDirs && compiler.includeDirs.count)
2637 f.Puts("\nCFLAGS +=");
2638 OutputFlags(f, gccCompiler ? _isystem : _I, compiler.includeDirs, lineEach);
2641 if(compiler.prepDirectives && compiler.prepDirectives.count)
2643 f.Puts("\nCFLAGS +=");
2644 OutputFlags(f, _D, compiler.prepDirectives, inPlace);
2647 if(compiler.libraryDirs && compiler.libraryDirs.count)
2649 f.Puts("\nLDFLAGS +=");
2650 OutputFlags(f, _L, compiler.libraryDirs, lineEach);
2651 // We would need a bool option to know whether we want to add to rpath as well...
2652 // OutputFlags(f, _Wl-rpath, compiler.libraryDirs, lineEach);
2655 if(compiler.excludeLibs && compiler.excludeLibs.count)
2657 f.Puts("\nEXCLUDED_LIBS =");
2658 for(l : compiler.excludeLibs)
2664 if(compiler.eCcompilerFlags && compiler.eCcompilerFlags.count)
2666 f.Puts("\nECFLAGS +=");
2667 OutputFlags(f, any, compiler.eCcompilerFlags, inPlace);
2670 if(compiler.compilerFlags && compiler.compilerFlags.count)
2672 f.Puts("\nCFLAGS +=");
2673 OutputFlags(f, any, compiler.compilerFlags, inPlace);
2676 if(compiler.linkerFlags && compiler.linkerFlags.count)
2678 f.Puts("\nLDFLAGS +=");
2679 OutputFlags(f, _Wl, compiler.linkerFlags, inPlace);
2683 f.Puts("\nOFLAGS += $(LDFLAGS)");
2685 f.Puts("ifdef ARCH_FLAGS\n");
2686 f.Puts("CFLAGS += $(ARCH_FLAGS)\n");
2687 f.Puts("OFLAGS += $(ARCH_FLAGS)\n");
2696 delete compilerName;
2700 bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config)
2702 bool result = false;
2703 char filePath[MAX_LOCATION];
2704 char makeFile[MAX_LOCATION];
2705 // PathBackup pathBackup { };
2706 // char oldDirectory[MAX_LOCATION];
2709 if(!altMakefilePath)
2711 strcpy(filePath, topNode.path);
2712 CatMakeFileName(makeFile, config);
2713 PathCatSlash(filePath, makeFile);
2716 f = FileOpen(altMakefilePath ? altMakefilePath : filePath, write);
2718 /*SetPath(false, compiler, config);
2719 GetWorkingDir(oldDirectory, MAX_LOCATION);
2720 ChangeWorkingDir(topNode.path);*/
2727 char targetDir[MAX_LOCATION];
2728 char objDirExpNoSpaces[MAX_LOCATION];
2729 char objDirNoSpaces[MAX_LOCATION];
2730 char resDirNoSpaces[MAX_LOCATION];
2731 char targetDirExpNoSpaces[MAX_LOCATION];
2732 char fixedModuleName[MAX_FILENAME];
2733 char fixedConfigName[MAX_FILENAME];
2735 int lenObjDirExpNoSpaces, lenTargetDirExpNoSpaces;
2736 // Non-zero if we're building eC code
2737 // We'll have to be careful with this when merging configs where eC files can be excluded in some configs and included in others
2738 int numCObjects = 0;
2740 int numRCObjects = 0;
2741 bool containsCXX = false; // True if the project contains a C++ file
2742 bool relObjDir, sameOrRelObjTargetDirs;
2743 const String objDirExp = GetObjDirExpression(config);
2744 TargetTypes targetType = GetTargetType(config);
2746 char cfDir[MAX_LOCATION];
2747 int objectsParts = 0;
2748 int eCsourcesParts = 0;
2749 int rcSourcesParts = 0;
2750 Array<String> listItems { };
2751 Map<String, int> varStringLenDiffs { };
2752 Map<String, NameCollisionInfo> namesInfo { };
2754 Map<String, int> cflagsVariations { };
2755 Map<intptr, int> nodeCFlagsMapping { };
2757 Map<String, int> ecflagsVariations { };
2758 Map<intptr, int> nodeECFlagsMapping { };
2760 ReplaceSpaces(objDirNoSpaces, objDirExp);
2761 strcpy(targetDir, GetTargetDirExpression(config));
2762 ReplaceSpaces(targetDirExpNoSpaces, targetDir);
2764 strcpy(objDirExpNoSpaces, GetObjDirExpression(config));
2765 ChangeCh(objDirExpNoSpaces, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
2767 char temp[MAX_LOCATION];
2768 ReplaceSpaces(temp, objDirExpNoSpaces);
2769 strcpy(objDirExpNoSpaces, temp);
2771 ReplaceSpaces(resDirNoSpaces, resNode.path ? resNode.path : "");
2772 ReplaceSpaces(fixedModuleName, moduleName);
2773 ReplaceSpaces(fixedConfigName, GetConfigName(config));
2774 CamelCase(fixedConfigName);
2776 lenObjDirExpNoSpaces = strlen(objDirExpNoSpaces);
2777 relObjDir = lenObjDirExpNoSpaces == 0 ||
2778 (objDirExpNoSpaces[0] == '.' && (lenObjDirExpNoSpaces == 1 || objDirExpNoSpaces[1] == '.'));
2779 lenTargetDirExpNoSpaces = strlen(targetDirExpNoSpaces);
2780 sameOrRelObjTargetDirs = lenTargetDirExpNoSpaces == 0 ||
2781 (targetDirExpNoSpaces[0] == '.' && (lenTargetDirExpNoSpaces == 1 || targetDirExpNoSpaces[1] == '.')) ||
2782 !fstrcmp(objDirExpNoSpaces, targetDirExpNoSpaces);
2784 f.Printf(".PHONY: all objdir%s cleantarget clean realclean distclean\n\n", sameOrRelObjTargetDirs ? "" : " targetdir");
2786 f.Puts("# CORE VARIABLES\n\n");
2788 f.Printf("MODULE := %s\n", fixedModuleName);
2789 f.Printf("VERSION := %s\n", property::moduleVersion);
2790 f.Printf("CONFIG := %s\n", fixedConfigName);
2791 topNode.GenMakefilePrintNode(f, this, noPrint, null, null, config, &containsCXX);
2793 f.Puts("CONTAINS_CXX := defined\n");
2794 f.Puts("ifndef COMPILER\n" "COMPILER := default\n" "endif\n");
2797 test = GetTargetTypeIsSetByPlatform(config);
2801 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2803 TargetTypes targetType;
2804 PlatformOptions projectPOs, configPOs;
2805 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2806 targetType = platformTargetType;
2812 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
2813 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2818 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2823 for(c = 0; c < ifCount; c++)
2829 f.Puts("# FLAGS\n\n");
2831 f.Puts("ECFLAGS =\n");
2832 f.Puts("ifndef DEBIAN_PACKAGE\n" "CFLAGS =\n" "LDFLAGS =\n" "endif\n");
2833 f.Puts("PRJ_CFLAGS =\n");
2834 f.Puts("CECFLAGS =\n");
2835 f.Puts("OFLAGS =\n");
2839 f.Puts("ifdef DEBUG\n" "NOSTRIP := y\n" "endif\n");
2842 // Important: We cannot use this ifdef anymore, EXECUTABLE_TARGET is not yet defined. It's embedded in the crossplatform.mk EXECUTABLE
2843 //f.Puts("ifdef EXECUTABLE_TARGET\n");
2844 f.Printf("CONSOLE = %s\n", GetConsole(config) ? "-mconsole" : "-mwindows");
2845 //f.Puts("endif\n");
2848 f.Puts("# INCLUDES\n\n");
2850 if(compilerConfigsDir && compilerConfigsDir[0])
2852 strcpy(cfDir, compilerConfigsDir);
2853 if(cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
2858 GetIDECompilerConfigsDir(cfDir, true, true);
2859 // Use CF_DIR environment variable for absolute paths only
2860 if(cfDir[0] == '/' || (cfDir[0] && cfDir[1] == ':'))
2861 strcpy(cfDir, "$(CF_DIR)");
2864 f.Printf("_CF_DIR = %s\n", cfDir);
2867 f.Printf("include %s\n", includemkPath ? includemkPath : "$(_CF_DIR)crossplatform.mk");
2868 f.Puts("include $(_CF_DIR)$(TARGET_PLATFORM)-$(COMPILER).cf\n");
2871 f.Puts("# POST-INCLUDES VARIABLES\n\n");
2873 f.Printf("OBJ = %s%s\n", objDirExpNoSpaces, objDirExpNoSpaces[0] ? "/" : "");
2876 f.Printf("RES = %s%s\n", resDirNoSpaces, resDirNoSpaces[0] ? "/" : "");
2879 // test = GetTargetTypeIsSetByPlatform(config);
2881 char target[MAX_LOCATION];
2882 char temp[MAX_LOCATION];
2887 for(type = (TargetTypes)1; type < TargetTypes::enumSize; type++)
2889 if(type != targetType)
2894 f.Printf("ifeq ($(TARGET_TYPE),%s)\n", TargetTypeToMakefileVariable(type));
2896 GetMakefileTargetFileName(type, target, config);
2897 strcpy(temp, targetDir);
2898 PathCatSlash(temp, target);
2899 ReplaceSpaces(target, temp);
2900 f.Printf("TARGET = %s\n", target);
2905 GetMakefileTargetFileName(targetType, target, config);
2906 strcpy(temp, targetDir);
2907 PathCatSlash(temp, target);
2908 ReplaceSpaces(target, temp);
2909 f.Printf("TARGET = %s\n", target);
2915 for(c = 0; c < ifCount; c++)
2922 // Use something fixed here, to not cause Makefile differences across compilers...
2923 varStringLenDiffs["$(OBJ)"] = 30; // strlen("obj/memoryGuard.android.gcc-4.6.2") - 6;
2924 // varStringLenDiffs["$(OBJ)"] = strlen(objDirNoSpaces) - 6;
2926 topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
2930 const char * map[5][2] = { { "COBJECTS", "C" }, { "SYMBOLS", "S" }, { "IMPORTS", "I" }, { "ECOBJECTS", "O" }, { "BOWLS", "B" } };
2932 numCObjects = topNode.GenMakefilePrintNode(f, this, eCsources, namesInfo, listItems, config, null);
2935 eCsourcesParts = OutputFileList(f, "_ECSOURCES", listItems, varStringLenDiffs, null);
2937 f.Puts("ECSOURCES = $(call shwspace,$(_ECSOURCES))\n");
2938 if(eCsourcesParts > 1)
2940 for(c = 1; c <= eCsourcesParts; c++)
2941 f.Printf("ECSOURCES%d = $(call shwspace,$(_ECSOURCES%d))\n", c, c);
2945 for(c = 0; c < 5; c++)
2947 if(eCsourcesParts > 1)
2950 f.Printf("_%s =", map[c][0]);
2951 for(n = 1; n <= eCsourcesParts; n++)
2952 f.Printf(" $(%s%d)", map[c][0], n);
2954 for(n = 1; n <= eCsourcesParts; n++)
2955 f.Printf("_%s%d = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES%d))))\n", map[c][0], n, map[c][1], n);
2957 else if(eCsourcesParts == 1)
2958 f.Printf("_%s = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES))))\n", map[c][0], map[c][1]);
2962 for(c = 0; c < 5; c++)
2964 if(eCsourcesParts > 1)
2967 f.Printf("%s =", map[c][0]);
2968 for(n = 1; n <= eCsourcesParts; n++)
2969 f.Printf(" $(%s%d)", map[c][0], n);
2971 for(n = 1; n <= eCsourcesParts; n++)
2972 f.Printf("%s%d = $(call shwspace,$(_%s%d))\n", map[c][0], n, map[c][0], n);
2974 else if(eCsourcesParts == 1)
2975 f.Printf("%s = $(call shwspace,$(_%s))\n", map[c][0], map[c][0]);
2981 numRCObjects = topNode.GenMakefilePrintNode(f, this, rcSources, namesInfo, listItems, config, null);
2984 f.Puts("ifdef WINDOWS_TARGET\n\n");
2986 rcSourcesParts = OutputFileList(f, "_RCSOURCES", listItems, varStringLenDiffs, null);
2988 f.Puts("RCSOURCES = $(call shwspace,$(_RCSOURCES))\n");
2989 if(rcSourcesParts > 1)
2991 for(c = 1; c <= rcSourcesParts; c++)
2992 f.Printf("RCSOURCES%d = $(call shwspace,$(_RCSOURCES%d))\n", c, c);
2995 if(rcSourcesParts > 1)
2998 f.Printf("%s =", "RCOBJECTS");
2999 for(n = 1; n <= rcSourcesParts; n++)
3000 f.Printf(" $(%s%d)", "RCOBJECTS", n);
3002 for(n = 1; n <= rcSourcesParts; n++)
3003 f.Printf("%s%d = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.rc,%%$(%s),$(notdir $(_RCSOURCES%d)))))\n", "RCOBJECTS", n, "O", n);
3005 else if(rcSourcesParts == 1)
3006 f.Printf("%s = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.rc,%%$(%s),$(notdir $(_RCSOURCES)))))\n", "RCOBJECTS", "O");
3010 f.Puts("RCSOURCES =\n");
3011 f.Puts("RCOBJECTS =\n");
3012 f.Puts("endif\n\n");
3015 numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, null);
3017 objectsParts = OutputFileList(f, "_OBJECTS", listItems, varStringLenDiffs, null);
3018 f.Printf("OBJECTS =%s%s%s%s\n",
3019 numObjects ? " $(_OBJECTS)" : "", numCObjects ? " $(ECOBJECTS)" : "",
3020 numCObjects ? " $(OBJ)$(MODULE).main$(O)" : "",
3021 numRCObjects ? " $(RCOBJECTS)" : "");
3024 topNode.GenMakefilePrintNode(f, this, sources, null, listItems, config, null);
3026 const char * prefix;
3027 if(numCObjects && numRCObjects)
3028 prefix = "$(ECSOURCES) $(RCSOURCES)";
3029 else if(numCObjects)
3030 prefix = "$(ECSOURCES)";
3033 OutputFileList(f, "SOURCES", listItems, varStringLenDiffs, prefix);
3037 resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config, null);
3038 OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs, null);
3040 f.Puts("ifdef USE_RESOURCES_EAR\n");
3041 f.Puts("RESOURCES_EAR = $(OBJ)resources.ear\n");
3043 f.Puts("RESOURCES_EAR = $(RESOURCES)\n");
3047 f.Puts("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n");
3049 if((config && config.options && config.options.libraries) ||
3050 (options && options.libraries))
3052 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3054 if(config && config.options && config.options.libraries)
3055 OutputLibraries(f, config.options.libraries);
3056 else if(options && options.libraries)
3057 OutputLibraries(f, options.libraries);
3063 topNode.GenMakeCollectAssignNodeFlags(config, numCObjects != 0,
3064 cflagsVariations, nodeCFlagsMapping,
3065 ecflagsVariations, nodeECFlagsMapping, null);
3067 GenMakePrintCustomFlags(f, "PRJ_CFLAGS", false, cflagsVariations);
3068 f.Puts("ECFLAGS += -module $(MODULE)\n");
3069 GenMakePrintCustomFlags(f, "ECFLAGS", true, ecflagsVariations);
3071 if(platforms || (config && config.platforms))
3074 //for(platform = firstPlatform; platform <= lastPlatform; platform++)
3075 //for(platform = win32; platform <= apple; platform++)
3077 f.Puts("# PLATFORM-SPECIFIC OPTIONS\n\n");
3078 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3080 PlatformOptions projectPlatformOptions, configPlatformOptions;
3081 MatchProjectAndConfigPlatformOptions(config, platform, &projectPlatformOptions, &configPlatformOptions);
3083 if(projectPlatformOptions || configPlatformOptions)
3088 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3091 if((projectPlatformOptions && projectPlatformOptions.options.compilerOptions && projectPlatformOptions.options.compilerOptions.count) ||
3092 (configPlatformOptions && configPlatformOptions.options.compilerOptions && configPlatformOptions.options.compilerOptions.count))
3094 f.Puts("CFLAGS +=");
3095 if(projectPlatformOptions && projectPlatformOptions.options.compilerOptions && projectPlatformOptions.options.compilerOptions.count)
3098 for(s : projectPlatformOptions.options.compilerOptions)
3101 if(configPlatformOptions && configPlatformOptions.options.compilerOptions && configPlatformOptions.options.compilerOptions.count)
3104 for(s : configPlatformOptions.options.compilerOptions)
3111 if((projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count) ||
3112 (configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count))
3114 f.Puts("OFLAGS +=");
3115 if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
3117 bool needWl = false;
3119 for(s : projectPlatformOptions.options.linkerOptions)
3121 if(!IsLinkerOption(s))
3129 for(s : projectPlatformOptions.options.linkerOptions)
3130 if(IsLinkerOption(s))
3134 if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
3136 bool needWl = false;
3138 for(s : configPlatformOptions.options.linkerOptions)
3140 if(IsLinkerOption(s))
3148 for(s : configPlatformOptions.options.linkerOptions)
3149 if(!IsLinkerOption(s))
3157 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
3158 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count) ||
3159 (projectPlatformOptions && projectPlatformOptions.options.libraries && projectPlatformOptions.options.libraries.count) ||
3160 (configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
3162 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3163 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
3164 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count))
3166 f.Puts("OFLAGS +=");
3167 if(configPlatformOptions && configPlatformOptions.options.libraryDirs)
3168 OutputFlags(f, _L, configPlatformOptions.options.libraryDirs, lineEach);
3169 if(projectPlatformOptions && projectPlatformOptions.options.libraryDirs)
3170 OutputFlags(f, _L, projectPlatformOptions.options.libraryDirs, lineEach);
3174 if(configPlatformOptions && configPlatformOptions.options.libraries)
3176 if(configPlatformOptions.options.libraries.count)
3179 OutputLibraries(f, configPlatformOptions.options.libraries);
3183 else if(projectPlatformOptions && projectPlatformOptions.options.libraries)
3185 if(projectPlatformOptions.options.libraries.count)
3188 OutputLibraries(f, projectPlatformOptions.options.libraries);
3199 for(c = 0; c < ifCount; c++)
3205 if((config && config.options && config.options.compilerOptions && config.options.compilerOptions.count) ||
3206 (options && options.compilerOptions && options.compilerOptions.count))
3208 f.Puts("CFLAGS +=");
3211 if(config && config.options && config.options.compilerOptions && config.options.compilerOptions.count)
3213 for(s : config.options.compilerOptions)
3216 if(options && options.compilerOptions && options.compilerOptions.count)
3218 for(s : options.compilerOptions)
3225 if((config && config.options && config.options.linkerOptions && config.options.linkerOptions.count) ||
3226 (options && options.linkerOptions && options.linkerOptions.count))
3228 f.Puts("OFLAGS +=");
3231 if(config && config.options && config.options.linkerOptions && config.options.linkerOptions.count)
3233 bool needWl = false;
3234 for(s : config.options.linkerOptions)
3236 if(!IsLinkerOption(s))
3244 for(s : config.options.linkerOptions)
3245 if(IsLinkerOption(s))
3249 if(options && options.linkerOptions && options.linkerOptions.count)
3251 bool needWl = false;
3252 for(s : options.linkerOptions)
3254 if(!IsLinkerOption(s))
3262 for(s : options.linkerOptions)
3263 if(IsLinkerOption(s))
3271 f.Puts("CECFLAGS += -cpp $(_CPP)");
3275 if(GetProfile(config))
3276 f.Puts("OFLAGS += -pg\n\n");
3278 if((config && config.options && config.options.libraryDirs) || (options && options.libraryDirs))
3280 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3281 f.Puts("OFLAGS +=");
3282 if(config && config.options && config.options.libraryDirs)
3283 OutputFlags(f, _L, config.options.libraryDirs, lineEach);
3284 if(options && options.libraryDirs)
3285 OutputFlags(f, _L, options.libraryDirs, lineEach);
3291 f.Puts("# TARGETS\n");
3294 f.Printf("all: objdir%s $(TARGET)\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3297 f.Puts("objdir:\n");
3299 f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdir,$(OBJ)))\n");
3302 f.Puts("\t$(if $(ECERE_SDK_SRC),$(if $(wildcard $(call escspace,$(ECERE_SDK_SRC)/crossplatform.mk)),,@$(call echo,Ecere SDK Source Warning: The value of ECERE_SDK_SRC is pointing to an incorrect ($(ECERE_SDK_SRC)) location.)),)\n");
3303 f.Puts("\t$(if $(ECERE_SDK_SRC),,$(if $(ECP_DEBUG)$(ECC_DEBUG)$(ECS_DEBUG),@$(call echo,ECC Debug Warning: Please define ECERE_SDK_SRC before using ECP_DEBUG, ECC_DEBUG or ECS_DEBUG),))\n");
3305 //f.Puts("# PRE-BUILD COMMANDS\n");
3306 if(options && options.prebuildCommands)
3308 for(s : options.prebuildCommands)
3309 if(s && s[0]) f.Printf("\t%s\n", s);
3311 if(config && config.options && config.options.prebuildCommands)
3313 for(s : config.options.prebuildCommands)
3314 if(s && s[0]) f.Printf("\t%s\n", s);
3316 if(platforms || (config && config.platforms))
3319 //f.Puts("# TARGET_PLATFORM-SPECIFIC PRE-BUILD COMMANDS\n");
3320 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3322 PlatformOptions projectPOs, configPOs;
3323 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3325 if((projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count) ||
3326 (configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count))
3331 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3333 if(projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count)
3335 for(s : projectPOs.options.prebuildCommands)
3336 if(s && s[0]) f.Printf("\t%s\n", s);
3338 if(configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count)
3340 for(s : configPOs.options.prebuildCommands)
3341 if(s && s[0]) f.Printf("\t%s\n", s);
3348 for(c = 0; c < ifCount; c++)
3354 if(!sameOrRelObjTargetDirs)
3356 f.Puts("targetdir:\n");
3357 f.Printf("\t$(if $(wildcard %s),,$(call mkdir,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
3363 // Main Module (Linking) for ECERE C modules
3364 f.Puts("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
3365 f.Printf("\t@$(call rm,$(OBJ)symbols.lst)\n");
3366 f.Printf("\t@$(call touch,$(OBJ)symbols.lst)\n");
3367 OutputFileListActions(f, "SYMBOLS", eCsourcesParts, "$(OBJ)symbols.lst");
3368 OutputFileListActions(f, "IMPORTS", eCsourcesParts, "$(OBJ)symbols.lst");
3369 // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
3370 f.Printf("\t$(ECS)%s $(ARCH_FLAGS) $(ECSLIBOPT) @$(OBJ)symbols.lst -symbols %s -o $(call quote_path,$@)\n",
3371 GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
3373 // Main Module (Linking) for ECERE C modules
3374 f.Puts("$(OBJ)$(MODULE).main.c: $(OBJ)$(MODULE).main.ec\n");
3375 f.Puts("\t$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS)"
3376 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
3377 f.Puts("\t$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY)"
3378 " -c $(OBJ)$(MODULE).main.ec -o $(call quote_path,$@) -symbols $(OBJ)\n");
3382 if(resNode.files && resNode.files.count && !noResources)
3384 f.Puts("ifdef USE_RESOURCES_EAR\n");
3385 f.Puts("$(RESOURCES_EAR): $(RESOURCES) | objdir\n");
3386 resNode.GenMakefileAddResources(f, resNode.path, config, "RESOURCES_EAR");
3393 // This would not rebuild the target on updated objects
3394 // f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) | objdir $(SYMBOLS) $(OBJECTS)%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3396 // This should fix it for good!
3397 f.Puts("$(SYMBOLS): | objdir\n");
3398 f.Puts("$(OBJECTS): | objdir\n");
3400 // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
3401 f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES_EAR) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
3402 rcSourcesParts ? " $(RCSOURCES)" : "", sameOrRelObjTargetDirs ? "" : " targetdir");
3404 f.Printf("\t@$(call rm,$(OBJ)objects.lst)\n");
3405 f.Printf("\t@$(call touch,$(OBJ)objects.lst)\n");
3406 OutputFileListActions(f, "_OBJECTS", objectsParts, "$(OBJ)objects.lst");
3409 f.Puts("ifdef WINDOWS_TARGET\n");
3410 OutputFileListActions(f, "RCOBJECTS", rcSourcesParts, "$(OBJ)objects.lst");
3415 f.Printf("\t$(call addtolistfile,$(OBJ)$(MODULE).main$(O),$(OBJ)objects.lst)\n");
3416 OutputFileListActions(f, "ECOBJECTS", eCsourcesParts, "$(OBJ)objects.lst");
3419 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3421 f.Puts("\t$(LD) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
3422 if(!GetDebug(config))
3424 f.Puts("ifndef NOSTRIP\n");
3425 f.Puts("\t$(STRIP) $(STRIPOPT) $(TARGET)\n");
3428 if(GetCompress(config))
3430 f.Printf("ifndef %s\n", PlatformToMakefileTargetVariable(win32));
3431 f.Puts("ifdef EXECUTABLE_TARGET\n");
3432 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3435 //f.Puts("ifneq ($(TARGET_ARCH),x86_64)\n");
3436 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3437 //f.Puts("endif\n");
3441 if(resNode.files && resNode.files.count && !noResources)
3443 f.Puts("ifndef USE_RESOURCES_EAR\n");
3444 resNode.GenMakefileAddResources(f, resNode.path, config, "TARGET");
3448 f.Puts("ifdef WINDOWS_HOST\n");
3449 f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)objects.lst $(LIBS)\n");
3451 f.Puts("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
3454 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3455 f.Puts("ifdef LINUX_TARGET\n");
3456 f.Puts("ifdef LINUX_HOST\n");
3457 // TODO?: support symlinks for longer version numbers
3458 f.Puts("\t$(if $(basename $(VER)),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)),)\n");
3459 f.Puts("\t$(if $(VER),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO),)\n");
3464 //f.Puts("# POST-BUILD COMMANDS\n");
3465 if(options && options.postbuildCommands)
3467 for(s : options.postbuildCommands)
3468 if(s && s[0]) f.Printf("\t%s\n", s);
3470 if(config && config.options && config.options.postbuildCommands)
3472 for(s : config.options.postbuildCommands)
3473 if(s && s[0]) f.Printf("\t%s\n", s);
3475 if(platforms || (config && config.platforms))
3478 //f.Puts("# TARGET_PLATFORM-SPECIFIC POST-BUILD COMMANDS\n");
3479 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3481 PlatformOptions projectPOs, configPOs;
3482 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3484 if((projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count) ||
3485 (configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count))
3490 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3492 if(projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count)
3494 for(s : projectPOs.options.postbuildCommands)
3495 if(s && s[0]) f.Printf("\t%s\n", s);
3497 if(configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count)
3499 for(s : configPOs.options.postbuildCommands)
3500 if(s && s[0]) f.Printf("\t%s\n", s);
3507 for(c = 0; c < ifCount; c++)
3514 if(platforms || (config && config.platforms))
3516 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3518 PlatformOptions projectPOs, configPOs;
3519 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3521 if((projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count) ||
3522 (configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count))
3529 if(test || (options && options.installCommands) ||
3530 (config && config.options && config.options.installCommands))
3532 f.Puts("install:\n");
3533 if(options && options.installCommands)
3535 for(s : options.installCommands)
3536 if(s && s[0]) f.Printf("\t%s\n", s);
3538 if(config && config.options && config.options.installCommands)
3540 for(s : config.options.installCommands)
3541 if(s && s[0]) f.Printf("\t%s\n", s);
3543 if(platforms || (config && config.platforms))
3546 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3548 PlatformOptions projectPOs, configPOs;
3549 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3551 if((projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count) ||
3552 (configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count))
3557 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3559 if(projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count)
3561 for(s : projectPOs.options.installCommands)
3562 if(s && s[0]) f.Printf("\t%s\n", s);
3564 if(configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count)
3566 for(s : configPOs.options.installCommands)
3567 if(s && s[0]) f.Printf("\t%s\n", s);
3574 for(c = 0; c < ifCount; c++)
3581 f.Puts("# SYMBOL RULES\n");
3584 topNode.GenMakefilePrintSymbolRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3586 f.Puts("# C OBJECT RULES\n");
3589 topNode.GenMakefilePrintCObjectRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3591 f.Puts("# OBJECT RULES\n");
3593 // todo call this still but only generate rules whith specific options
3594 // see we-have-file-specific-options in ProjectNode.ec
3595 topNode.GenMakefilePrintObjectRules(f, this, namesInfo, config, nodeCFlagsMapping, nodeECFlagsMapping);
3598 GenMakefilePrintMainObjectRule(f, config);
3600 f.Printf("cleantarget: objdir%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3603 f.Printf("\t$(call rm,%s)\n", "$(OBJ)$(MODULE).main$(O) $(OBJ)$(MODULE).main.c $(OBJ)$(MODULE).main.ec $(OBJ)$(MODULE).main$(I) $(OBJ)$(MODULE).main$(S)");
3604 f.Printf("\t$(call rm,$(OBJ)symbols.lst)\n");
3606 f.Printf("\t$(call rm,$(OBJ)objects.lst)\n");
3607 f.Puts("\t$(call rm,$(TARGET))\n");
3608 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3609 f.Puts("ifdef LINUX_TARGET\n");
3610 f.Puts("ifdef LINUX_HOST\n");
3611 // TODO?: support symlinks for longer version numbers
3612 f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
3613 f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO))\n");
3619 f.Puts("clean: cleantarget\n");
3620 OutputCleanActions(f, "OBJECTS", objectsParts);
3623 f.Puts("ifdef WINDOWS_TARGET\n");
3624 OutputCleanActions(f, "RCOBJECTS", rcSourcesParts);
3629 OutputCleanActions(f, "ECOBJECTS", eCsourcesParts);
3630 OutputCleanActions(f, "COBJECTS", eCsourcesParts);
3631 OutputCleanActions(f, "BOWLS", eCsourcesParts);
3632 OutputCleanActions(f, "IMPORTS", eCsourcesParts);
3633 OutputCleanActions(f, "SYMBOLS", eCsourcesParts);
3635 if(resNode.files && resNode.files.count && !noResources)
3637 f.Puts("ifdef USE_RESOURCES_EAR\n");
3638 f.Printf("\t$(call rm,$(RESOURCES_EAR))\n");
3643 f.Puts("realclean: cleantarget\n");
3644 f.Puts("\t$(call rmr,$(OBJ))\n");
3645 if(!sameOrRelObjTargetDirs)
3646 f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
3649 f.Puts("distclean: cleantarget\n");
3650 if(!sameOrRelObjTargetDirs)
3651 f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
3653 f.Puts("\t$(call rmr,obj/)\n");
3654 f.Puts("\t$(call rmr,.configs/)\n");
3655 f.Puts("\t$(call rm,*.ews)\n");
3656 f.Puts("\t$(call rm,*.Makefile)\n");
3662 varStringLenDiffs.Free();
3663 delete varStringLenDiffs;
3667 delete cflagsVariations;
3668 delete nodeCFlagsMapping;
3669 delete ecflagsVariations;
3670 delete nodeECFlagsMapping;
3675 // ChangeWorkingDir(oldDirectory);
3676 // delete pathBackup;
3679 config.makingModified = false;
3683 void GenMakefilePrintMainObjectRule(File f, ProjectConfig config)
3685 char extension[MAX_EXTENSION] = "c";
3686 //char modulePath[MAX_LOCATION];
3687 char fixedModuleName[MAX_FILENAME];
3689 //char command[2048];
3690 char objDirNoSpaces[MAX_LOCATION];
3691 const String objDirExp = GetObjDirExpression(config);
3693 ReplaceSpaces(objDirNoSpaces, objDirExp);
3694 ReplaceSpaces(fixedModuleName, moduleName);
3696 //sprintf(fixedModuleName, "%s.main", fixedPrjName);
3697 //strcat(fixedModuleName, ".main");
3699 #if 0 // TODO: Fix nospaces stuff
3700 // *** Dependency command ***
3701 sprintf(command, "gcc -MT $(OBJ)%s$(O) -MM $(OBJ)%s.c", fixedModuleName, fixedModuleName);
3703 // System Includes (from global settings)
3704 for(item : compiler.dirs[Includes])
3706 strcat(command, " -isystem ");
3707 if(strchr(item.name, ' '))
3709 strcat(command, "\"");
3710 strcat(command, item);
3711 strcat(command, "\"");
3714 strcat(command, item);
3717 for(item = includeDirs.first; item; item = item.next)
3719 strcat(command, " -I");
3720 if(strchr(item.name, ' '))
3722 strcat(command, "\"");
3723 strcat(command, item.name);
3724 strcat(command, "\"");
3727 strcat(command, item.name);
3729 for(item = preprocessorDefs.first; item; item = item.next)
3731 strcat(command, " -D");
3732 strcat(command, item.name);
3736 if((dep = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
3740 bool firstLine = true;
3742 // To do some time: auto save external dependencies?
3745 if(dep.GetLine(line, sizeof(line)-1))
3749 char * colon = strstr(line, ":");
3750 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
3764 // If we failed to generate dependencies...
3768 f.Puts("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
3769 f.Printf("\t$(CC) $(CFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(call quote_path,$@)\n", extension);
3777 void GenMakePrintCustomFlags(File f, const String variableName, bool printNonCustom, Map<String, int> cflagsVariations)
3780 for(c = printNonCustom ? 0 : 1; c <= cflagsVariations.count; c++)
3782 for(v : cflagsVariations)
3787 f.Printf("%s +=", variableName);
3789 f.Printf("CUSTOM%d_%s =", v-1, variableName);
3790 f.Puts(&v ? &v : "");
3798 void MatchProjectAndConfigPlatformOptions(ProjectConfig config, Platform platform,
3799 PlatformOptions * projectPlatformOptions, PlatformOptions * configPlatformOptions)
3801 *projectPlatformOptions = null;
3802 *configPlatformOptions = null;
3807 if(!strcmpi(p.name, platform))
3809 *projectPlatformOptions = p;
3814 if(config && config.platforms)
3816 for(p : config.platforms)
3818 if(!strcmpi(p.name, platform))
3820 *configPlatformOptions = p;
3828 static inline void ProjectLoadLastBuildNamesInfo(Project prj, ProjectConfig cfg)
3830 const char * cfgName = cfg ? cfg.name : "";
3831 Map<String, NameCollisionInfo> cfgNameCollisions = prj.configsNameCollisions[cfgName];
3832 if(cfgNameCollisions)
3834 cfgNameCollisions.Free();
3835 delete cfgNameCollisions;
3837 prj.configsNameCollisions[cfgName] = cfgNameCollisions = { };
3838 prj.topNode.GenMakefileGetNameCollisionInfo(cfgNameCollisions, cfg);
3841 Project LegacyBinaryLoadProject(File f, const char * filePath)
3843 Project project = null;
3844 char signature[sizeof(epjSignature)];
3846 f.Read(signature, sizeof(signature), 1);
3847 if(!strncmp(signature, (char *)epjSignature, sizeof(epjSignature)))
3849 char topNodePath[MAX_LOCATION];
3850 /*ProjectConfig newConfig
3852 name = CopyString("Default");
3853 makingModified = true;
3854 compilingModified = true;
3855 linkingModified = true;
3859 project = Project { options = { } };
3860 LegacyBinaryLoadNode(project.topNode, f);
3861 delete project.topNode.path;
3862 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3863 MakeSlashPath(topNodePath);
3865 PathCatSlash(topNodePath, filePath);
3866 project.filePath = topNodePath;
3868 /* THIS IS ALREADY DONE BY filePath property
3869 StripLastDirectory(topNodePath, topNodePath);
3870 project.topNode.path = CopyString(topNodePath);
3872 // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
3874 // newConfig.options.defaultNameSpace = "";
3875 /*newConfig.objDir.dir = "obj";
3876 newConfig.targetDir.dir = "";*/
3878 //project.configurations = { [ newConfig ] };
3879 //project.config = newConfig;
3886 String targetFileName, targetDirectory, objectsDirectory;
3888 // { executable = 0, sharedLibrary = 1, staticLibrary = 2 };
3889 f.Read(&temp, sizeof(int),1);
3892 case 0: project.options.targetType = executable; break;
3893 case 1: project.options.targetType = sharedLibrary; break;
3894 case 2: project.options.targetType = staticLibrary; break;
3897 f.Read(&len, sizeof(int),1);
3898 targetFileName = new char[len+1];
3899 f.Read(targetFileName, sizeof(char), len+1);
3900 project.options.targetFileName = targetFileName;
3901 delete targetFileName;
3903 f.Read(&len, sizeof(int),1);
3904 targetDirectory = new char[len+1];
3905 f.Read(targetDirectory, sizeof(char), len+1);
3906 project.options.targetDirectory = targetDirectory;
3907 delete targetDirectory;
3909 f.Read(&len, sizeof(int),1);
3910 objectsDirectory = new byte[len+1];
3911 f.Read(objectsDirectory, sizeof(char), len+1);
3912 project.options.objectsDirectory = objectsDirectory;
3913 delete objectsDirectory;
3915 f.Read(&temp, sizeof(int),1);
3916 project./*config.*/options.debug = temp ? true : false;
3917 f.Read(&temp, sizeof(int),1);
3918 project./*config.*/options.optimization = temp ? speed : none;
3919 f.Read(&temp, sizeof(int),1);
3920 project./*config.*/options.profile = temp ? true : false;
3921 f.Read(&temp, sizeof(int),1);
3922 project.options.warnings = temp ? all : unset;
3924 f.Read(&count, sizeof(int),1);
3927 project.options.includeDirs = { };
3928 for(c = 0; c < count; c++)
3931 f.Read(&len, sizeof(int),1);
3932 name = new char[len+1];
3933 f.Read(name, sizeof(char), len+1);
3934 project.options.includeDirs.Add(name);
3938 f.Read(&count, sizeof(int),1);
3941 project.options.libraryDirs = { };
3942 for(c = 0; c < count; c++)
3945 f.Read(&len, sizeof(int),1);
3946 name = new char[len+1];
3947 f.Read(name, sizeof(char), len+1);
3948 project.options.libraryDirs.Add(name);
3952 f.Read(&count, sizeof(int),1);
3955 project.options.libraries = { };
3956 for(c = 0; c < count; c++)
3959 f.Read(&len, sizeof(int),1);
3960 name = new char[len+1];
3961 f.Read(name, sizeof(char), len+1);
3962 project.options.libraries.Add(name);
3966 f.Read(&count, sizeof(int),1);
3969 project.options.preprocessorDefinitions = { };
3970 for(c = 0; c < count; c++)
3973 f.Read(&len, sizeof(int),1);
3974 name = new char[len+1];
3975 f.Read(name, sizeof(char), len+1);
3976 project.options.preprocessorDefinitions.Add(name);
3980 f.Read(&temp, sizeof(int),1);
3981 project.options.console = temp ? true : false;
3984 for(node : project.topNode.files)
3986 if(node.type == resources)
3988 project.resNode = node;
3998 void ProjectConfig::LegacyProjectConfigLoad(File f)
4006 char subSection[128];
4011 f.GetLine(buffer, 65536 - 1);
4012 TrimLSpaces(buffer, buffer);
4013 TrimRSpaces(buffer, buffer);
4016 if(buffer[0] == '-')
4020 TrimLSpaces(equal, equal);
4021 if(!strcmpi(subSection, "LibraryDirs"))
4023 if(!options.libraryDirs)
4024 options.libraryDirs = { [ CopyString(equal) ] };
4026 options.libraryDirs.Add(CopyString(equal));
4028 else if(!strcmpi(subSection, "IncludeDirs"))
4030 if(!options.includeDirs)
4031 options.includeDirs = { [ CopyString(equal) ] };
4033 options.includeDirs.Add(CopyString(equal));
4036 else if(buffer[0] == '+')
4047 TrimLSpaces(equal, equal);
4048 delete name; name = CopyString(equal); // property::name = equal;
4051 else if(!strcmpi(buffer, "Compiler Options"))
4052 strcpy(section, buffer);
4053 else if(!strcmpi(buffer, "IncludeDirs"))
4054 strcpy(subSection, buffer);
4055 else if(!strcmpi(buffer, "Linker Options"))
4056 strcpy(section, buffer);
4057 else if(!strcmpi(buffer, "LibraryDirs"))
4058 strcpy(subSection, buffer);
4059 else if(!strcmpi(buffer, "Files") || !strcmpi(buffer, "Resources"))
4066 equal = strstr(buffer, "=");
4070 TrimRSpaces(buffer, buffer);
4072 TrimLSpaces(equal, equal);
4073 if(!strcmpi(buffer, "Target Name"))
4074 options.targetFileName = /*CopyString(*/equal/*)*/;
4075 else if(!strcmpi(buffer, "Target Type"))
4077 if(!strcmpi(equal, "Executable"))
4078 options.targetType = executable;
4079 else if(!strcmpi(equal, "Shared"))
4080 options.targetType = sharedLibrary;
4081 else if(!strcmpi(equal, "Static"))
4082 options.targetType = staticLibrary;
4084 options.targetType = executable;
4086 else if(!strcmpi(buffer, "Target Directory"))
4087 options.targetDirectory = /*CopyString(*/equal/*)*/;
4088 else if(!strcmpi(buffer, "Console"))
4089 options.console = ParseTrueFalseValue(equal);
4090 else if(!strcmpi(buffer, "Libraries"))
4092 if(!options.libraries) options.libraries = { };
4093 ParseArrayValue(options.libraries, equal);
4095 else if(!strcmpi(buffer, "Intermediate Directory"))
4096 options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
4097 else if(!strcmpi(buffer, "Debug"))
4098 options.debug = ParseTrueFalseValue(equal);
4099 else if(!strcmpi(buffer, "Optimize"))
4101 if(!strcmpi(equal, "None"))
4102 options.optimization = none;
4103 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
4104 options.optimization = speed;
4105 else if(!strcmpi(equal, "Size"))
4106 options.optimization = size;
4108 options.optimization = none;
4110 else if(!strcmpi(buffer, "Compress"))
4111 options.compress = ParseTrueFalseValue(equal);
4112 else if(!strcmpi(buffer, "Profile"))
4113 options.profile = ParseTrueFalseValue(equal);
4114 else if(!strcmpi(buffer, "AllWarnings"))
4115 options.warnings = ParseTrueFalseValue(equal) ? all : unset;
4116 else if(!strcmpi(buffer, "MemoryGuard"))
4117 options.memoryGuard = ParseTrueFalseValue(equal);
4118 else if(!strcmpi(buffer, "Default Name Space"))
4119 options.defaultNameSpace = CopyString(equal);
4120 else if(!strcmpi(buffer, "Strict Name Spaces"))
4121 options.strictNameSpaces = ParseTrueFalseValue(equal);
4122 else if(!strcmpi(buffer, "Preprocessor Definitions"))
4124 if(!options.preprocessorDefinitions) options.preprocessorDefinitions = { };
4125 ParseArrayValue(options.preprocessorDefinitions, equal);
4131 if(!options.targetDirectory && options.objectsDirectory)
4132 options.targetDirectory = /*CopyString(*/options.objectsDirectory/*)*/;
4133 //if(!objDir.dir) objDir.dir = "obj";
4134 //if(!targetDir.dir) targetDir.dir = "";
4135 // if(!targetName) property::targetName = ""; // How can a targetFileName be nothing???
4136 // if(!defaultNameSpace) property::defaultNameSpace = "";
4137 makingModified = true;
4140 Project LegacyAsciiLoadProject(File f, const char * filePath)
4142 Project project = null;
4144 char parentPath[MAX_LOCATION];
4145 char section[128] = "";
4146 char subSection[128] = "";
4147 ProjectNode parent = null;
4148 bool configurationsPresent = false;
4158 f.GetLine(buffer, 65536 - 1);
4159 TrimLSpaces(buffer, buffer);
4160 TrimRSpaces(buffer, buffer);
4163 if(buffer[0] == '-' || buffer[0] == '=')
4165 bool simple = buffer[0] == '-';
4168 TrimLSpaces(equal, equal);
4169 if(!strcmpi(section, "Target") && !strcmpi(subSection, "LibraryDirs"))
4171 if(!project.config.options.libraryDirs)
4172 project.config.options.libraryDirs = { [ CopyString(equal) ] };
4174 project.config.options.libraryDirs.Add(CopyString(equal));
4176 else if(!strcmpi(section, "Target") && !strcmpi(subSection, "IncludeDirs"))
4178 if(!project.config.options.includeDirs)
4179 project.config.options.includeDirs = { [ CopyString(equal) ] };
4181 project.config.options.includeDirs.Add(CopyString(equal));
4183 else if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
4185 len = strlen(equal);
4188 char temp[MAX_LOCATION];
4189 ProjectNode child { };
4190 // We don't need to do this anymore, fileName is just a property that sets name & path
4191 // child.fileName = CopyString(equal);
4194 child.name = CopyString(equal);
4195 child.path = CopyString(parentPath);
4199 GetLastDirectory(equal, temp);
4200 child.name = CopyString(temp);
4201 StripLastDirectory(equal, temp);
4202 child.path = CopyString(temp);
4204 child.nodeType = file;
4205 child.parent = parent;
4206 child.indent = parent.indent + 1;
4208 child.icon = NodeIcons::SelectFileIcon(child.name);
4209 parent.files.Add(child);
4215 StripLastDirectory(parentPath, parentPath);
4216 parent = parent.parent;
4220 else if(buffer[0] == '+')
4224 TrimLSpaces(equal, equal);
4225 if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
4227 char temp[MAX_LOCATION];
4228 ProjectNode child { };
4229 // NEW: Folders now have a path set like files
4230 child.name = CopyString(equal);
4231 strcpy(temp, parentPath);
4232 PathCatSlash(temp, child.name);
4233 child.path = CopyString(temp);
4235 child.parent = parent;
4236 child.indent = parent.indent + 1;
4237 child.type = folder;
4238 child.nodeType = folder;
4240 child.icon = folder;
4241 PathCatSlash(parentPath, child.name);
4242 parent.files.Add(child);
4247 else if(!strcmpi(section, "Configurations"))
4249 ProjectConfig newConfig
4251 makingModified = true;
4255 LegacyProjectConfigLoad(newConfig, f);
4256 project.configurations.Add(newConfig);
4259 else if(!strcmpi(buffer, "ECERE Project File"));
4260 else if(!strcmpi(buffer, "Version 0a"))
4261 ; //strcpy(version, "0a");
4262 else if(!strcmpi(buffer, "Version 0.1a"))
4263 ; //strcpy(version, "0.1a");
4264 else if(!strcmpi(buffer, "Configurations"))
4266 project.configurations.Free();
4267 project.config = null;
4268 strcpy(section, buffer);
4269 configurationsPresent = true;
4271 else if(!strcmpi(buffer, "Target") || !strnicmp(buffer, "Target \"", strlen("Target \"")))
4273 ProjectConfig newConfig { name = CopyString("Default"), options = { } };
4274 char topNodePath[MAX_LOCATION];
4275 // newConfig.defaultNameSpace = "";
4276 //newConfig.objDir.dir = "obj";
4277 //newConfig.targetDir.dir = "";
4278 project = Project { /*options = { }*/ };
4279 project.configurations = { [ newConfig ] };
4280 project.config = newConfig;
4281 // if(project.topNode.path) delete project.topNode.path;
4282 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
4283 MakeSlashPath(topNodePath);
4284 PathCatSlash(topNodePath, filePath);
4285 project.filePath = topNodePath;
4286 parentPath[0] = '\0';
4287 parent = project.topNode;
4289 strcpy(section, "Target");
4294 if(equal[0] == '\"')
4296 StripQuotes(equal, equal);
4297 delete project.moduleName; project.moduleName = CopyString(equal);
4301 else if(!strcmpi(buffer, "Compiler Options"));
4302 else if(!strcmpi(buffer, "IncludeDirs"))
4303 strcpy(subSection, buffer);
4304 else if(!strcmpi(buffer, "Linker Options"));
4305 else if(!strcmpi(buffer, "LibraryDirs"))
4306 strcpy(subSection, buffer);
4307 else if(!strcmpi(buffer, "Files"))
4309 strcpy(section, "Target");
4310 strcpy(subSection, buffer);
4312 else if(!strcmpi(buffer, "Resources"))
4314 ProjectNode child { };
4315 parent.files.Add(child);
4316 child.parent = parent;
4317 child.indent = parent.indent + 1;
4318 child.name = CopyString(buffer);
4319 child.path = CopyString("");
4320 child.type = resources;
4322 child.icon = archiveFile;
4323 project.resNode = child;
4326 strcpy(subSection, buffer);
4330 equal = strstr(buffer, "=");
4334 TrimRSpaces(buffer, buffer);
4336 TrimLSpaces(equal, equal);
4338 if(!strcmpi(section, "Target"))
4340 if(!strcmpi(buffer, "Build Exclusions"))
4342 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
4344 /*if(node && node.type != NodeTypes::project)
4345 ParseListValue(node.buildExclusions, equal);*/
4348 else if(!strcmpi(buffer, "Path") && !strcmpi(subSection, "Resources"))
4350 delete project.resNode.path;
4351 project.resNode.path = CopyString(equal);
4352 PathCatSlash(parentPath, equal);
4356 else if(!strcmpi(buffer, "Intermediate Directory"))
4357 project.config.options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
4358 else if(!strcmpi(buffer, "Debug"))
4359 project.config.options.debug = ParseTrueFalseValue(equal);
4360 else if(!strcmpi(buffer, "Optimize"))
4362 if(!strcmpi(equal, "None"))
4363 project.config.options.optimization = none;
4364 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
4365 project.config.options.optimization = speed;
4366 else if(!strcmpi(equal, "Size"))
4367 project.config.options.optimization = size;
4369 project.config.options.optimization = none;
4371 else if(!strcmpi(buffer, "Profile"))
4372 project.config.options.profile = ParseTrueFalseValue(equal);
4373 else if(!strcmpi(buffer, "MemoryGuard"))
4374 project.config.options.memoryGuard = ParseTrueFalseValue(equal);
4377 if(!project.options) project.options = { };
4379 // Project Wide Settings (All configs)
4380 if(!strcmpi(buffer, "Target Name"))
4381 project.options.targetFileName = /*CopyString(*/equal/*)*/;
4382 else if(!strcmpi(buffer, "Target Type"))
4384 if(!strcmpi(equal, "Executable"))
4385 project.options.targetType = executable;
4386 else if(!strcmpi(equal, "Shared"))
4387 project.options.targetType = sharedLibrary;
4388 else if(!strcmpi(equal, "Static"))
4389 project.options.targetType = staticLibrary;
4391 project.options.targetType = executable;
4393 else if(!strcmpi(buffer, "Target Directory"))
4394 project.options.targetDirectory = /*CopyString(*/equal/*)*/;
4395 else if(!strcmpi(buffer, "Console"))
4396 project.options.console = ParseTrueFalseValue(equal);
4397 else if(!strcmpi(buffer, "Libraries"))
4399 if(!project.options.libraries) project.options.libraries = { };
4400 ParseArrayValue(project.options.libraries, equal);
4402 else if(!strcmpi(buffer, "AllWarnings"))
4403 project.options.warnings = ParseTrueFalseValue(equal) ? all : unset;
4404 else if(!strcmpi(buffer, "Preprocessor Definitions"))
4406 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
4408 /*if(node && (node.type == NodeTypes::project || (node.type == file && !node.isInResources) || node.type == folder))
4409 ParseListValue(node.preprocessorDefs, equal);*/
4413 if(!project.options.preprocessorDefinitions) project.options.preprocessorDefinitions = { };
4414 ParseArrayValue(project.options.preprocessorDefinitions, equal);
4425 SplitPlatformLibraries(project);
4427 if(configurationsPresent)
4428 CombineIdenticalConfigOptions(project);
4432 void SplitPlatformLibraries(Project project)
4434 if(project && project.configurations)
4436 for(cfg : project.configurations)
4438 if(cfg.options.libraries && cfg.options.libraries.count)
4440 Iterator<String> it { cfg.options.libraries };
4444 char * platformName = strstr(l, ":");
4447 PlatformOptions platform = null;
4449 if(!cfg.platforms) cfg.platforms = { };
4450 for(p : cfg.platforms)
4452 if(!strcmpi(platformName, p.name))
4460 platform = { name = CopyString(platformName), options = { libraries = { } } };
4461 cfg.platforms.Add(platform);
4463 *(platformName-1) = 0;
4464 platform.options.libraries.Add(CopyString(l));
4466 cfg.options.libraries.Delete(it.pointer);
4475 void CombineIdenticalConfigOptions(Project project)
4477 if(project && project.configurations && project.configurations.count)
4480 ProjectOptions nullOptions { };
4481 ProjectConfig firstConfig = null;
4482 for(cfg : project.configurations)
4484 if(cfg.options.targetType != staticLibrary)
4491 firstConfig = project.configurations.firstIterator.data;
4493 for(member = class(ProjectOptions).membersAndProperties.first; member; member = member.next)
4495 if(!member.isProperty)
4497 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
4502 for(cfg : project.configurations)
4504 if(cfg != firstConfig)
4506 if(cfg.options.targetType != staticLibrary)
4510 if(type.type == noHeadClass || type.type == normalClass)
4512 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4513 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4514 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4518 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4519 (byte *)firstConfig.options + member.offset + member._class.offset,
4520 (byte *)cfg.options + member.offset + member._class.offset);
4532 if(type.type == noHeadClass || type.type == normalClass)
4534 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4535 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4536 *(void **)((byte *)nullOptions + member.offset + member._class.offset)))
4541 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4542 (byte *)firstConfig.options + member.offset + member._class.offset,
4543 (byte *)nullOptions + member.offset + member._class.offset))
4547 if(!project.options) project.options = { };
4549 /*if(type.type == noHeadClass || type.type == normalClass)
4551 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4552 (byte *)project.options + member.offset + member._class.offset,
4553 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
4557 void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
4558 // TOFIX: ListBox::SetData / OnCopy mess
4559 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4560 (byte *)project.options + member.offset + member._class.offset,
4561 (type.typeSize > 4) ? address :
4562 ((type.typeSize == 4) ? (void *)*(uint32 *)address :
4563 ((type.typeSize == 2) ? (void *)*(uint16*)address :
4564 (void *)*(byte *)address )));
4567 (byte *)project.options + member.offset + member._class.offset,
4568 (byte *)firstConfig.options + member.offset + member._class.offset, type.typeSize);
4570 for(cfg : project.configurations)
4572 if(cfg.options.targetType == staticLibrary)
4576 if(type.type == noHeadClass || type.type == normalClass)
4578 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4579 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4580 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4584 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4585 (byte *)firstConfig.options + member.offset + member._class.offset,
4586 (byte *)cfg.options + member.offset + member._class.offset);
4591 if(cfg != firstConfig)
4593 if(type.type == noHeadClass || type.type == normalClass)
4595 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4596 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4600 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4601 (byte *)cfg.options + member.offset + member._class.offset);
4603 memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
4606 memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
4613 // Compare Platform Specific Settings
4616 for(cfg : project.configurations)
4618 if(cfg != firstConfig && cfg.options.targetType != staticLibrary && (firstConfig.platforms || cfg.platforms) &&
4619 ((!firstConfig.platforms && cfg.platforms) || firstConfig.platforms.OnCompare(cfg.platforms)))
4625 if(same && firstConfig.platforms)
4627 for(cfg : project.configurations)
4629 if(cfg.options.targetType == staticLibrary && firstConfig.platforms.OnCompare(cfg.platforms))
4631 if(cfg != firstConfig)
4633 cfg.platforms = null;
4636 project.platforms = firstConfig.platforms;
4637 *&firstConfig.platforms = null;
4641 // Static libraries can't contain libraries
4642 for(cfg : project.configurations)
4644 if(cfg.options.targetType == staticLibrary)
4646 if(!cfg.options.libraries) cfg.options.libraries = { };
4647 cfg.options.libraries.Free();
4653 Project LoadProject(const char * filePath, const char * activeConfigName)
4655 Project project = null;
4656 File f = FileOpen(filePath, read);
4659 project = LegacyBinaryLoadProject(f, filePath);
4662 ECONParser parser { f = f };
4663 /*JSONResult result = */parser.GetObject(class(Project), &project);
4666 char insidePath[MAX_LOCATION];
4668 delete project.topNode.files;
4669 if(!project.files) project.files = { };
4670 project.topNode.files = project.files;
4673 char topNodePath[MAX_LOCATION];
4674 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
4675 MakeSlashPath(topNodePath);
4676 PathCatSlash(topNodePath, filePath);
4677 project.filePath = topNodePath;//filePath;
4680 project.topNode.FixupNode(insidePath);
4682 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4683 delete project.resNode.path;
4684 project.resNode.path = project.resourcesPath;
4685 project.resourcesPath = null;
4686 project.resNode.nodeType = (ProjectNodeType)-1;
4687 delete project.resNode.files;
4688 project.resNode.files = project.resources;
4689 project.files = null;
4690 project.resources = null;
4691 if(!project.configurations) project.configurations = { };
4693 project.resNode.FixupNode(insidePath);
4698 project = LegacyAsciiLoadProject(f, filePath);
4704 if(!project.options) project.options = { };
4705 if(activeConfigName && activeConfigName[0] && project.configurations)
4706 project.config = project.GetConfig(activeConfigName);
4707 if(!project.config && project.configurations)
4708 project.config = project.configurations.firstIterator.data;
4710 if(!project.resNode)
4712 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4715 if(!project.moduleName)
4716 project.moduleName = CopyString(project.name);
4717 if(project.config &&
4718 (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
4719 (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
4721 //delete project.config.options.targetFileName;
4723 project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
4724 project.config.options.optimization = none;
4725 project.config.options.debug = true;
4726 //project.config.options.warnings = unset;
4727 project.config.options.memoryGuard = false;
4728 project.config.compilingModified = true;
4729 project.config.linkingModified = true;
4731 else if(!project.topNode.name && project.config)
4733 project.topNode.name = CopyString(project.config.options.targetFileName);
4736 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
4737 project.topNode.configurations = project.configurations;
4738 project.topNode.platforms = project.platforms;
4739 project.topNode.options = project.options;*/
4745 #ifndef MAKEFILE_GENERATOR
4746 static GccVersionInfo GetGccVersionInfo(CompilerConfig compiler, const String compilerCommand)
4748 GccVersionInfo result = unknown;
4749 if(compiler.ccCommand)
4751 char command[MAX_F_STRING*4];
4753 sprintf(command, "%s%s --version", compiler.gccPrefix ? compiler.gccPrefix : "", compilerCommand);
4754 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
4756 bool firstLine = true;
4761 if(f.GetLine(line,sizeof(line)))
4765 uint count = Tokenize(line, sizeof(tokens)/sizeof(tokens[0]), tokens,false);
4766 char * token = null;
4769 for(i = 0; i < count; i++)
4771 if(tokens[i][0] == '(')
4773 if(tokens[i][strlen(tokens[i])-1] != ')')
4776 else if(tokens[i][0] && tokens[i][strlen(tokens[i])-1] == ')')
4778 else if(!inPar && isdigit(tokens[i][0]) && strchr(tokens[i], '.'))
4782 result = GccVersionInfo::GetVersionInfo(token);
4793 static enum GccVersionInfo
4795 unknown, pre4_8, post4_8;
4797 GccVersionInfo ::GetVersionInfo(char * version)
4799 GccVersionInfo result = unknown;
4801 char * s = CopyString(version);
4803 uint count = TokenizeWith(s, sizeof(tokens)/sizeof(tokens[0]), tokens, ".", false);
4804 ver = count > 1 ? atoi(tokens[1]) : 0;
4805 ver += count ? atoi(tokens[0]) * 1000 : 0;