2 public import static "ecere"
9 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
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 #if defined(ECERE_DOCUMENTOR) || defined(ECERE_EPJ2MAKE)
36 CompilerConfig defaultCompiler;
39 // LEGACY BINARY EPJ LOADING
41 SetBool ParseTrueFalseValue(char * string)
43 if(!strcmpi(string, "True")) return true;
47 void ParseArrayValue(Array<String> array, char * equal)
49 char * start, * comma;
51 string = CopyString(equal);
55 comma = strstr(start, ",");
58 array.Add(CopyString(start));
68 void ProjectNode::LegacyBinaryLoadNode(File f)
73 f.Read(&len, sizeof(len), 1);
74 name = new char[len+1];
76 f.Read(name, sizeof(char), len+1);
77 f.Read(&len, sizeof(len), 1);
79 path = new char[len+1];
80 f.Read(path, sizeof(char), len+1);
83 fileName = new char[fileNameLen+2];
84 strcpy(fileName, path);
85 if(fileName[0]) strcat(fileName, "/");
86 strcat(fileName, name);
89 f.Read(&type, sizeof(type), 1);
90 f.Read(&count, sizeof(count), 1);
95 icon = NodeIcons::SelectFileIcon(name);
100 icon = NodeIcons::SelectNodeIcon(type);
103 if(count && !files) files = { };
104 for(c = 0; c < count; c++)
106 ProjectNode child { };
109 child.indent = indent + 1;
110 LegacyBinaryLoadNode(child, f);
114 /*void LegacyBinarySaveNode(File f)
119 f.Write(&len, sizeof(len), 1);
120 f.Write(name, sizeof(char), len+1);
124 // Projects Absolute Path Are Not Saved
126 f.Write(&len, sizeof(len), 1);
127 f.Write(&len, sizeof(char), 1);
132 f.Write(&len, sizeof(len), 1);
133 f.Write(path, sizeof(char), len+1);
135 f.Write(&type, sizeof(type), 1);
136 f.Write(&children.count, sizeof(children.count), 1);
137 for(child = children.first; child; child.next)
141 void ProjectNode::LegacyAsciiSaveNode(File f, char * indentation, char * insidePath)
144 char printPath[MAX_LOCATION];
146 if(type == project && (files.count /*|| preprocessorDefs.first*/))
148 f.Printf("\n Files\n");
150 else if(type == file)
152 if(!strcmp(path, insidePath))
153 f.Printf("%s - %s\n", indentation, name);
156 strcpy(printPath, path);
157 len = strlen(printPath);
159 if(printPath[len-1] != '/')
160 strcat(printPath, "/");
161 strcat(printPath, name);
162 f.Printf("%s = %s\n", indentation, printPath);
165 f.Printf("\nError\n\n");
167 else if(type == folder)
169 f.Printf("%s + %s\n", indentation, name);
171 else if(type == resources && files.count)
173 PathCatSlash(insidePath, path);
174 f.Printf("\n%sResources\n", indentation);
176 f.Printf("%s Path = %s\n", indentation, path);
179 /*if(buildExclusions.first && type != project)
181 for(item = buildExclusions.first; item; item = item.next)
183 if(item == buildExclusions.first)
184 f.Printf("%s Build Exclusions = %s", indentation, item.name);
186 f.Printf(", %s", item.name);
191 if(preprocessorDefs.first && (type == project || ((type == file || type == folder) && !isInResources)))
193 for(item = preprocessorDefs.first; item; item = item.next)
195 if(item == preprocessorDefs.first)
196 f.Printf("%s%s Preprocessor Definitions = %s", indentation, type == project ? "" : " ", item.name);
198 f.Printf(", %s", item.name);
204 if(type == project && (files.count /*|| preprocessorDefs.first*/))
208 LegacyAsciiSaveNode(child, f, indentation, insidePath);
210 else if(type == folder)
212 strcat(indentation, " ");
213 // WHAT WAS THIS: strcpy(printPath, path);
214 // TOCHECK: why is Unix/PathCat not used here
215 len = strlen(insidePath);
217 if(insidePath[len-1] != '/')
218 strcat(insidePath, "/");
219 strcat(insidePath, name);
222 LegacyAsciiSaveNode(child, f, indentation, insidePath);
223 f.Printf("%s -\n", indentation);
224 indentation[strlen(indentation) - 3] = '\0';
225 StripLastDirectory(insidePath, insidePath);
227 else if(type == resources && files.count)
231 LegacyAsciiSaveNode(child, f, indentation, insidePath);
232 StripLastDirectory(insidePath, insidePath);
237 void ProjectConfig::LegacyProjectConfigSave(File f)
239 char * indentation = " ";
241 //f.Printf("\n * Common\n");
243 f.Printf("\n + %s\n", name);
244 f.Printf("\n Compiler\n\n");
245 if(objDir.expression[0])
246 f.Printf("%sIntermediate Directory = %s\n", indentation, objDir.expression);
247 f.Printf("%sDebug = %s\n", indentation, (options.debug == true) ? "True" : "False");
248 switch(options.optimization)
250 // case none: f.Printf("%sOptimize = %s\n", indentation, "None"); break;
251 case speed: f.Printf("%sOptimize = %s\n", indentation, "Speed"); break;
252 case size: f.Printf("%sOptimize = %s\n", indentation, "Size"); break;
254 f.Printf("%sAllWarnings = %s\n", indentation, (options.warnings == all) ? "True" : "False");
256 f.Printf("%sProfile = %s\n", indentation, (options.profile == true) ? "True" : "False");
257 if(options.memoryGuard == true)
258 f.Printf("%sMemoryGuard = %s\n", indentation, (options.memoryGuard == true) ? "True" : "False");
259 if(options.strictNameSpaces == true)
260 f.Printf("%sStrict Name Spaces = %s\n", indentation, (options.strictNameSpaces == true) ? "True" : "False");
261 if(options.defaultNameSpace && strlen(options.defaultNameSpace))
262 f.Printf("%sDefault Name Space = %s\n", indentation, options.defaultNameSpace);
263 TOFIX: Compiler Bug {
264 if(options.preprocessorDefinitions.count)
267 for(item : options.preprocessorDefinitions)
271 f.Printf("\n%sPreprocessor Definitions = %s", indentation, item);
275 f.Printf(", %s", item);
280 if(options.includeDirs.count)
282 f.Printf("\n%sInclude Directories\n", indentation);
283 for(item : options.includeDirs)
284 f.Printf("%s - %s\n", indentation, name);
288 f.Printf("\n%sLinker\n\n", indentation);
289 f.Printf("%sTarget Name = %s\n", indentation, options.targetFileName);
290 switch(options.targetType)
292 case executable: f.Printf("%sTarget Type = %s\n", indentation, "Executable"); break;
293 case sharedLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Shared"); break;
294 case staticLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Static"); break;
296 if(targetDir.expression[0])
297 f.Printf("%sTarget Directory = %s\n", indentation, targetDir.expression);
299 f.Printf("%sConsole = %s\n", indentation, options.console ? "True" : "False");
301 f.Printf("%sCompress = %s\n", indentation, options.compress ? "True" : "False");
302 if(options.libraries.count)
305 for(item : options.libraries)
309 f.Printf("\n%sLibraries = %s", indentation, name);
313 f.Printf(", %s", item);
317 if(options.libraryDirs.count)
319 f.Printf("\n%sLibrary Directories\n\n", indentation);
320 for(item : options.libraryDirs)
321 f.Printf(" - %s\n", indentation, item);
325 void LegacyAsciiSaveProject(File f, Project project)
327 char indentation[128*3];
328 char path[MAX_LOCATION];
330 f.Printf("\nECERE Project File : Format Version 0.1b\n");
331 f.Printf("\nDescription\n%s\n.\n", project.description);
332 f.Printf("\nLicense\n%s\n.\n", project.license);
333 f.Printf("\nModule Name = %s\n", project.moduleName);
334 f.Printf("\n Configurations\n");
335 //////////////////////////////////////commonConfig.Save(f, true);
336 for(cfg : project.configurations)
337 LegacyProjectConfigSave(cfg, f);
339 strcpy(indentation, " ");
341 LegacyAsciiSaveNode(project.topNode, f, indentation, path);
347 // *** NEW JSON PROJECT FORMAT ***
348 public enum ProjectNodeType { file, folder };
350 // *******************************
352 define PEEK_RESOLUTION = (18.2 * 10);
358 static Array<const String> notLinkerOptions
380 static bool IsLinkerOption(String s)
382 for(i : notLinkerOptions)
383 if(strstr(s, "-Wl,") || !strcmp(s, i))
388 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
390 enum GenMakefilePrintTypes { noPrint, objects, cObjects, symbols, imports, sources, resources, eCsources, rcSources };
392 define WorkspaceExtension = "ews";
393 define ProjectExtension = "epj";
395 define stringInFileIncludedFrom = "In file included from ";
396 define stringFrom = " from ";
398 // chars refused for project name: windowsFileNameCharsNotAllowed + " &,."
400 //define gnuMakeCharsNeedEscaping = "$%";
402 //define windowsFileNameCharsNotAllowed = "*/:<>?\\\"|";
403 //define linuxFileNameCharsNotAllowed = "/";
405 //define windowsFileNameCharsNeedEscaping = " !%&'()+,;=[]^`{}~"; // "#$-.@_" are ok
406 //define linuxFileNameCharsNeedEscaping = " !\"$&'()*:;<=>?[\\`{|"; // "#%+,-.@]^_}~" are ok
408 // NOTES: - this function should get only unescaped unix style paths
409 // - paths with literal $(somestring) in them are not supported
410 // my_$(messed_up)_path would likely become my__path
411 void EscapeForMake(char * output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
413 char ch, *o = output;
414 const char *i = input;
417 int len = strlen(input);
418 if(len && ((input[0] == '"' && input[len-1] == '"') || strchr(input, '\\') || strchr(input, 127) || (!allowDblQuote && strchr(input, '"'))))
419 PrintLn("Invalid input for EscapeForMake! -- ", input);
425 if(i-1 != input && *(i-2) == '$' && allowVars)
432 if(inVar == true && allowVars)
437 else if(ch == '$' && *i != '(')
459 void EscapeForMakeToFile(File output, char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
461 char * buf = new char[strlen(input)*2+1];
462 EscapeForMake(buf, input, hideSpace, allowVars, allowDblQuote);
467 void EscapeForMakeToDynString(DynamicString output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
469 char * buf = new char[strlen(input)*2+1];
470 EscapeForMake(buf, input, hideSpace, allowVars, allowDblQuote);
475 int OutputFileList(File f, const char * name, Array<String> list, Map<String, int> varStringLenDiffs, const char * prefix)
478 const int breakListLength = 1536;
479 const int breakLineLength = 78; // TODO: turn this into an option.
481 int c, len, itemCount = 0;
482 Array<int> breaks { };
486 MapNode<String, int> mn;
487 for(c=0; c<list.count; c++)
489 len = strlen(list[c]) + 3;
490 if(strstr(list[c], "$(") && varStringLenDiffs && varStringLenDiffs.count)
492 for(mn = varStringLenDiffs.root.minimum; mn; mn = mn.next)
494 if(strstr(list[c], mn.key))
498 if(charCount + len > breakListLength)
500 breaks.Add(itemCount);
508 breaks.Add(itemCount);
509 numOfBreaks = breaks.count;
514 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
515 for(c=0; c<numOfBreaks; c++)
516 f.Printf(" $(%s%d)", name, c+1);
520 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
526 for(c=0; c<numOfBreaks; c++)
529 f.Printf("%s%d =", name, c+1);
532 itemCount = breaks[c];
533 for(n=offset; n<offset+itemCount; n++)
535 if(false) // TODO: turn this into an option.
537 int itemLen = strlen(list[n]);
538 if(len > 3 && len + itemLen > breakLineLength)
540 f.Printf(" \\\n\t%s", list[n]);
546 f.Printf(" %s", list[n]);
550 f.Printf(" \\\n\t%s", list[n]);
565 void OutputFileListActions(File f, const char * name, int parts, const char * fileName)
570 for(c=0; c<parts; c++)
571 f.Printf("\t$(call addtolistfile,$(%s%d),%s)\n", name, c+1, fileName);
575 f.Printf("\t$(call addtolistfile,$(%s),%s)\n", name, fileName);
579 void OutputCleanActions(File f, const char * name, int parts)
584 for(c=0; c<parts; c++)
585 f.Printf("\t$(call rm,$(_%s%d))\n", name, c+1);
588 f.Printf("\t$(call rm,$(_%s))\n", name);
591 enum LineOutputMethod { inPlace, newLine, lineEach };
592 enum StringOutputMethod { asIs, escape, escapePath};
594 enum ToolchainFlag { any, _D, _I, _isystem, _Wl, _L/*, _Wl-rpath*/ };
595 const String flagNames[ToolchainFlag] = { "", "-D", "-I", "-isystem ", "-Wl,", /*"-Wl,--library-path="*/"-L"/*, "-Wl,-rpath "*/ };
596 void OutputFlags(File f, ToolchainFlag flag, Array<String> list, LineOutputMethod lineMethod)
600 if(lineMethod == newLine)
604 if(lineMethod == lineEach)
606 f.Printf(" %s", flagNames[flag]);
607 if(flag != _D && flag != _Wl && flag != any)
609 char * tmp = new char[strlen(item)*2+1];
610 EscapeForMake(tmp, item, false, true, false);
611 f.Printf("$(call quote_path,%s)", tmp);
615 EscapeForMakeToFile(f, item, false, true, true);
620 static void OutputLibraries(File f, Array<String> libraries)
622 for(item : libraries)
624 char ext[MAX_EXTENSION];
625 char temp[MAX_LOCATION];
627 bool usedFunction = false;
628 GetExtension(item, ext);
629 if(!strcmp(ext, "o") || !strcmp(ext, "a"))
633 if(!strcmp(ext, "so") || !strcmp(ext, "dylib"))
635 if(!strncmp(item, "lib", 3))
636 strcpy(temp, item + 3);
639 StripExtension(temp);
642 f.Puts(" \\\n\t$(call _L,");
645 EscapeForMakeToFile(f, s, false, false, false);
651 void CamelCase(char * string)
655 int c, len = strlen(string);
656 for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
657 string[c] = (char)tolower(string[c]);
661 CompilerConfig GetCompilerConfig()
663 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
664 CompilerConfig compiler = null;
665 if(ide && ide.workspace)
666 compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler);
669 incref defaultCompiler;
670 return defaultCompiler;
676 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
677 return ide.workspace ? ide.workspace.bitDepth : 0;
679 return 0; // todo: improve this somehow? add bit depth command line option?
683 define localTargetType = config && config.options && config.options.targetType ?
684 config.options.targetType : options && options.targetType ?
685 options.targetType : TargetTypes::executable;
686 define localWarnings = config && config.options && config.options.warnings ?
687 config.options.warnings : options && options.warnings ?
688 options.warnings : WarningsOption::unset;
689 define localDebug = config && config.options && config.options.debug ?
690 config.options.debug : options && options.debug ?
691 options.debug : SetBool::unset;
692 define localMemoryGuard = config && config.options && config.options.memoryGuard ?
693 config.options.memoryGuard : options && options.memoryGuard ?
694 options.memoryGuard : SetBool::unset;
695 define localNoLineNumbers = config && config.options && config.options.noLineNumbers ?
696 config.options.noLineNumbers : options && options.noLineNumbers ?
697 options.noLineNumbers : SetBool::unset;
698 define localProfile = config && config.options && config.options.profile ?
699 config.options.profile : options && options.profile ?
700 options.profile : SetBool::unset;
701 define localOptimization = config && config.options && config.options.optimization ?
702 config.options.optimization : options && options.optimization ?
703 options.optimization : OptimizationStrategy::none;
704 define localFastMath = config && config.options && config.options.fastMath ?
705 config.options.fastMath : options && options.fastMath ?
706 options.fastMath : SetBool::unset;
707 define localDefaultNameSpace = config && config.options && config.options.defaultNameSpace ?
708 config.options.defaultNameSpace : options && options.defaultNameSpace ?
709 options.defaultNameSpace : null;
710 define localStrictNameSpaces = config && config.options && config.options.strictNameSpaces ?
711 config.options.strictNameSpaces : options && options.strictNameSpaces ?
712 options.strictNameSpaces : SetBool::unset;
713 // TODO: I would rather have null here, check if it'll be ok, have the property return "" if required
714 define localTargetFileName = config && config.options && config.options.targetFileName ?
715 config.options.targetFileName : options && options.targetFileName ?
716 options.targetFileName : "";
717 define localTargetDirectory = config && config.options && config.options.targetDirectory && config.options.targetDirectory[0] ?
718 config.options.targetDirectory : options && options.targetDirectory && options.targetDirectory[0] ?
719 options.targetDirectory : null;
720 define settingsTargetDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
721 ideSettings.projectDefaultIntermediateObjDir[0] ?
722 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
723 define localObjectsDirectory = config && config.options && config.options.objectsDirectory && config.options.objectsDirectory[0] ?
724 config.options.objectsDirectory : options && options.objectsDirectory && options.objectsDirectory[0] ?
725 options.objectsDirectory : null;
726 define settingsObjectsDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
727 ideSettings.projectDefaultIntermediateObjDir[0] ?
728 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
729 define localConsole = config && config.options && config.options.console ?
730 config.options.console : options && options.console ?
731 options.console : SetBool::unset;
732 define localCompress = config && config.options && config.options.compress ?
733 config.options.compress : options && options.compress ?
734 options.compress : SetBool::unset;
736 define platformTargetType =
737 configPOs && configPOs.options && configPOs.options.targetType && configPOs.options.targetType != localTargetType ?
738 configPOs.options.targetType :
739 projectPOs && projectPOs.options && projectPOs.options.targetType && projectPOs.options.targetType != localTargetType ?
740 projectPOs.options.targetType : TargetTypes::unset;
743 const char * PlatformToMakefileTargetVariable(Platform platform)
745 return platform == win32 ? "WINDOWS_TARGET" :
746 platform == tux ? "LINUX_TARGET" :
747 platform == apple ? "OSX_TARGET" :
751 const char * TargetTypeToMakefileVariable(TargetTypes targetType)
753 return targetType == executable ? "executable" :
754 targetType == sharedLibrary ? "sharedlib" :
755 targetType == staticLibrary ? "staticlib" :
759 // Move this to ProjectConfig? null vs Common to consider...
760 const char * GetConfigName(ProjectConfig config)
762 return config ? config.name : "Common";
765 public enum SingleFileCompileMode
767 normal, debugPrecompile, debugCompile, debugGenerateSymbols, cObject;
769 property bool eC_ToolsDebug { get { return this == debugCompile || this == debugGenerateSymbols || this == debugPrecompile; } }
772 class Project : struct
774 class_no_expansion; // To use Find on the Container<Project> in Workspace::projects
775 // We might want to tweak this default behavior of regular classes ?
776 // Expansion/the current default kind of Find matching we want for things like BitmapResource, FontResource (Also regular classes)
781 property const char * moduleVersion
783 set { delete moduleVersion; if(value && value[0]) moduleVersion = CopyString(value); } // TODO: use CopyString function that filters chars
784 get { return moduleVersion ? moduleVersion : ""; } // version number should only use digits and dots
785 isset { return moduleVersion != null && moduleVersion[0]; } // add leading/trailing 0 if value start/ends with dot(s)
788 property const char * description
790 set { delete description; if(value && value[0]) description = CopyString(value); }
791 get { return description ? description : ""; }
792 isset { return description != null && description[0]; }
795 property const char * license
797 set { delete license; if(value && value[0]) license = CopyString(value); }
798 get { return license ? license : ""; }
799 isset { return license != null && license[0]; }
802 property const char * compilerConfigsDir
804 set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
805 get { return compilerConfigsDir ? compilerConfigsDir : ""; }
806 isset { return compilerConfigsDir && compilerConfigsDir[0]; }
809 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
810 property Array<PlatformOptions> platforms
812 get { return platforms; }
815 if(platforms) { platforms.Free(); delete platforms; }
818 List<PlatformOptions> empty { };
819 Iterator<PlatformOptions> it { value };
821 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
822 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
832 if(p.options && !p.options.isEmpty)
839 List<ProjectConfig> configurations;
840 LinkList<ProjectNode> files;
841 String resourcesPath;
842 LinkList<ProjectNode> resources;
845 // topNode.name holds the file name (.epj)
846 ProjectOptions options;
847 Array<PlatformOptions> platforms;
848 ProjectNode topNode { type = project, icon = epjFile, files = LinkList<ProjectNode>{ }, project = this };
851 ProjectConfig config;
853 // This is the file name stripped of the epj extension
854 // It should NOT be edited, saved or loaded anywhere
859 String compilerConfigsDir;
860 String moduleVersion;
862 String lastBuildConfigName;
863 String lastBuildCompilerName;
865 Map<String, Map<String, NameCollisionInfo>> configsNameCollisions { };
867 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
868 FileMonitor fileMonitor
870 this, FileChange { modified = true };
871 bool OnFileNotify(FileChange action, const char * param)
873 fileMonitor.StopMonitoring();
874 if(OnProjectModified(action, param))
875 fileMonitor.StartMonitoring();
880 bool StartMonitoring()
882 fileMonitor.fileName = filePath;
883 fileMonitor.StartMonitoring();
887 bool StopMonitoring()
889 fileMonitor.StopMonitoring();
893 bool OnProjectModified(FileChange fileChange, const char * param)
896 sprintf(temp, $"The project %s was modified by another application.\n"
897 "Would you like to reload it and lose your changes?", name);
898 if(MessageBox { type = yesNo, master = ide,
899 text = $"Project has been modified", contents = temp }.Modal() == yes)
901 Project project = LoadProject(filePath, config ? config.name : null);
904 ProjectView projectView = ide.projectView;
905 DataRow prev = topNode.row ? topNode.row.previous : null;
906 FileMonitor fm = fileMonitor;
907 bool confirmation = true;
911 if(projectView.projectSettingsDialog)
913 confirmation = projectView.projectSettingsDialog.CloseConfirmation(true);
915 projectView.projectSettingsDialog.Destroy(0);
918 projectView.DeleteNode(topNode);
925 topNode.project = this;
929 CompilerConfig compiler = ideSettings.GetCompilerConfig(projectView.workspace.activeCompiler);
930 projectView.AddNode(topNode, null);
931 topNode.row.Move(prev);
933 projectView.ShowOutputBuildLog(true);
934 projectView.DisplayCompiler(compiler, false);
935 projectView.ProjectUpdateMakefileForAllConfigs(this);
938 eSystem_Delete(project);
945 return !ide.destroyed;
950 // This frees contents without freeing the instance
951 // For use from destructor and for file monitor reloading
952 // (To work around JSON loader (LoadProject) always returning a new instance)
955 if(platforms) { platforms.Free(); delete platforms; }
956 if(configurations) { configurations.Free(); delete configurations; }
957 if(files) { files.Free(); delete files; }
958 if(resources) { resources.Free(); delete resources; }
960 delete resourcesPath;
964 delete compilerConfigsDir;
966 delete moduleVersion;
970 delete lastBuildConfigName;
971 delete lastBuildCompilerName;
972 for(map : configsNameCollisions)
974 configsNameCollisions.Free();
979 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
980 topNode.configurations = null;
981 topNode.platforms = null;
982 topNode.options = null;
987 property ProjectConfig config
993 topNode.info = CopyString(GetConfigName(config));
997 property const char * filePath
1003 char string[MAX_LOCATION];
1004 GetLastDirectory(value, string);
1005 delete topNode.name;
1006 topNode.name = CopyString(string);
1007 StripExtension(string);
1009 name = CopyString(string);
1010 StripLastDirectory(value, string);
1011 delete topNode.path;
1012 topNode.path = CopyString(string);
1014 filePath = CopyString(value);
1019 ProjectConfig GetConfig(const char * configName)
1021 ProjectConfig result = null;
1022 if(configName && configName[0] && configurations.count)
1024 for(cfg : configurations; !strcmpi(cfg.name, configName))
1033 ProjectNode FindNodeByObjectFileName(const char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config, const char * objectFileExt)
1036 const char * cfgName;
1038 config = this.config;
1039 cfgName = config ? config.name : "";
1040 if(!configsNameCollisions[cfgName])
1041 ProjectLoadLastBuildNamesInfo(this, config);
1042 result = topNode.FindByObjectFileName(fileName, type, dotMain, configsNameCollisions[cfgName], objectFileExt);
1046 TargetTypes GetTargetType(ProjectConfig config)
1048 TargetTypes targetType = localTargetType;
1052 bool GetTargetTypeIsSetByPlatform(ProjectConfig config)
1055 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
1057 PlatformOptions projectPOs, configPOs;
1058 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
1059 if(platformTargetType)
1065 const char * GetObjDirExpression(ProjectConfig config)
1067 // TODO: Support platform options
1068 const char * expression = localObjectsDirectory;
1070 expression = settingsObjectsDirectory;
1074 DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1076 const char * expression = GetObjDirExpression(config);
1077 DirExpression objDir { type = intermediateObjectsDir };
1078 objDir.Evaluate(expression, this, compiler, config, bitDepth);
1082 const char * GetTargetDirExpression(ProjectConfig config)
1084 // TODO: Support platform options
1085 const char * expression = localTargetDirectory;
1087 expression = settingsTargetDirectory;
1091 DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1093 const char * expression = GetTargetDirExpression(config);
1094 DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
1095 targetDir.Evaluate(expression, this, compiler, config, bitDepth);
1099 WarningsOption GetWarnings(ProjectConfig config)
1101 WarningsOption warnings = localWarnings;
1105 bool GetDebug(ProjectConfig config)
1107 SetBool debug = localDebug;
1108 return debug == true;
1111 bool GetMemoryGuard(ProjectConfig config)
1113 SetBool memoryGuard = localMemoryGuard;
1114 return memoryGuard == true;
1117 bool GetNoLineNumbers(ProjectConfig config)
1119 SetBool noLineNumbers = localNoLineNumbers;
1120 return noLineNumbers == true;
1123 bool GetProfile(ProjectConfig config)
1125 SetBool profile = localProfile;
1126 return profile == true;
1129 OptimizationStrategy GetOptimization(ProjectConfig config)
1131 OptimizationStrategy optimization = localOptimization;
1132 return optimization;
1135 bool GetFastMath(ProjectConfig config)
1137 SetBool fastMath = localFastMath;
1138 return fastMath == true;
1141 const String GetDefaultNameSpace(ProjectConfig config)
1143 const String defaultNameSpace = localDefaultNameSpace;
1144 return defaultNameSpace;
1147 bool GetStrictNameSpaces(ProjectConfig config)
1149 SetBool strictNameSpaces = localStrictNameSpaces;
1150 return strictNameSpaces == true;
1153 const String GetTargetFileName(ProjectConfig config)
1155 const String targetFileName = localTargetFileName;
1156 return targetFileName;
1159 //String targetDirectory;
1160 //String objectsDirectory;
1161 bool GetConsole(ProjectConfig config)
1163 SetBool console = localConsole;
1164 return console == true;
1167 bool GetCompress(ProjectConfig config)
1169 SetBool compress = localCompress;
1170 return compress == true;
1172 //SetBool excludeFromBuild;
1174 bool GetConfigIsInActiveDebugSession(ProjectConfig config)
1176 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1177 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
1183 bool GetConfigIsInDebugSession(ProjectConfig config)
1185 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1186 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
1192 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
1194 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1195 ide.SetPath(projectsDirs, compiler, config, bitDepth);
1199 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1200 bool Save(const char * fileName)
1203 f = FileOpen(fileName, write);
1206 files = topNode.files;
1207 resources = resNode.files;
1208 resourcesPath = resNode.path;
1210 files.Remove(resNode);
1213 WriteJSONObject(f, class(Project), this, 0);
1219 resourcesPath = null;
1226 void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
1228 TargetTypes targetType = GetTargetType(config);
1229 const String targetFileName = GetTargetFileName(config);
1230 if(targetType == staticLibrary)
1232 PathCatSlash(string, "lib");
1233 strcat(string, targetFileName);
1235 else if(compiler.targetPlatform != win32 && targetType == sharedLibrary)
1237 PathCatSlash(string, "lib");
1238 strcat(string, targetFileName);
1241 PathCatSlash(string, targetFileName);
1246 if(compiler.targetPlatform == win32)
1247 strcat(string, ".exe");
1250 if(compiler.targetPlatform == win32)
1251 strcat(string, ".dll");
1252 else if(compiler.targetPlatform == apple)
1253 strcat(string, ".dylib");
1255 strcat(string, ".so");
1256 if(compiler.targetPlatform == tux && __runtimePlatform == tux && moduleVersion && moduleVersion[0])
1258 strcat(string, ".");
1259 strcat(string, moduleVersion);
1263 strcat(string, ".a");
1268 bool GetProjectCompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1270 bool result = false;
1271 char temp[MAX_LOCATION];
1272 strcpy(cfDir, topNode.path);
1273 if(compilerConfigsDir && compilerConfigsDir[0])
1275 PathCatSlash(cfDir, compilerConfigsDir);
1280 strcpy(temp, cfDir);
1281 // Using a relative path makes it less likely to run into spaces issues
1282 // Even with escaped spaces, there still seems to be issues including a config file
1283 // in a path containing spaces
1285 MakePathRelative(temp, topNode.path, cfDir);
1288 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1292 strcpy(temp, cfDir);
1293 ReplaceSpaces(cfDir, temp);
1298 bool GetIDECompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1300 char temp[MAX_LOCATION];
1301 bool result = false;
1302 strcpy(cfDir, topNode.path);
1303 if(ideSettings && ideSettings.compilerConfigsDir && ideSettings.compilerConfigsDir[0])
1305 PathCatSlash(cfDir, ideSettings.compilerConfigsDir);
1310 // Default to <ProjectDir>/.configs if unset
1311 PathCatSlash(cfDir, ".configs");
1316 strcpy(temp, cfDir);
1317 // Using a relative path makes it less likely to run into spaces issues
1318 // Even with escaped spaces, there still seems to be issues including a config file
1319 // in a path containing spaces
1320 if(IsPathInsideOf(cfDir, topNode.path))
1321 MakePathRelative(temp, topNode.path, cfDir);
1323 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1327 strcpy(temp, cfDir);
1328 ReplaceSpaces(cfDir, temp);
1333 void CatMakeFileName(char * string, ProjectConfig config)
1335 char projectName[MAX_LOCATION];
1336 strcpy(projectName, name);
1337 sprintf(string, "%s%s%s.Makefile", projectName, config ? "-" : "", config ? config.name : "");
1340 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1341 ProjectNode GetObjectFileNode(const char * filePath, const char * objectFileExt)
1343 ProjectNode node = null;
1344 char ext[MAX_EXTENSION];
1345 GetExtension(filePath, ext);
1348 IntermediateFileType type = IntermediateFileType::FromExtension(ext);
1351 char fileName[MAX_FILENAME];
1352 GetLastDirectory(filePath, fileName);
1355 DotMain dotMain = DotMain::FromFileName(fileName);
1356 node = FindNodeByObjectFileName(fileName, type, dotMain, null, objectFileExt);
1363 bool GetAbsoluteFromRelativePath(const char * relativePath, char * absolutePath, const char * objectFileExt)
1365 ProjectNode node = topNode.FindWithPath(relativePath, false);
1367 node = GetObjectFileNode(relativePath, objectFileExt);
1370 strcpy(absolutePath, node.project.topNode.path);
1371 PathCat(absolutePath, relativePath);
1372 MakeSlashPath(absolutePath);
1374 return node != null;
1377 void MarkChanges(ProjectNode node)
1379 for(cfg : topNode.configurations)
1381 ProjectConfig c = null;
1382 for(i : node.configurations; !strcmpi(i.name, cfg.name)) { c = i; break; }
1384 if(c && ((c.options && cfg.options && cfg.options.console != c.options.console) ||
1385 (!c.options || !cfg.options)))
1386 cfg.symbolGenModified = true;
1387 if(c && ((c.options && cfg.options &&
1388 ( (cfg.options.libraries && c.options.libraries && cfg.options.libraries.OnCompare(c.options.libraries)) || (!cfg.options.libraries || !c.options.libraries)) )
1389 || (!c.options || !cfg.options)))
1390 cfg.linkingModified = true;
1392 cfg.makingModified = true;
1396 void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
1398 Map<String, NameCollisionInfo> cfgNameCollision;
1399 MapIterator<const String, Map<String, NameCollisionInfo>> it { map = configsNameCollisions };
1400 if(it.Index("", false))
1402 cfgNameCollision = it.data;
1403 cfgNameCollision.Free();
1404 delete cfgNameCollision;
1407 for(cfg : configurations)
1411 cfg.makingModified = true;
1412 if(it.Index(cfg.name, false))
1414 cfgNameCollision = it.data;
1415 cfgNameCollision.Free();
1416 delete cfgNameCollision;
1421 cfg.compilingModified = true;
1423 cfg.linkingModified = true;
1425 cfg.symbolGenModified = true;
1427 if(compiling || linking)
1429 ide.projectView.modifiedDocument = true;
1430 ide.workspace.modified = true;
1434 void RotateActiveConfig(bool forward, bool syncAllProjects)
1436 if(configurations.first && configurations.last != configurations.first)
1438 Iterator<ProjectConfig> cfg { configurations };
1439 while(forward ? cfg.Next() : cfg.Prev())
1440 if(cfg.data == config)
1455 ide.workspace.SelectActiveConfig(cfg.data.name);
1458 property::config = cfg.data;
1459 ide.UpdateToolBarActiveConfigs(true);
1460 ide.workspace.modified = true;
1461 ide.projectView.Update(null);
1466 bool ProcessPipeOutputRaw(DualPipe f)
1469 while(!f.Eof() && !ide.projectView.stopBuild)
1472 double lastTime = GetTime();
1476 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1478 ide.outputView.buildBox.Logf("%s\n", line);
1480 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1482 //printf("Processing Input...\n");
1483 if(app.ProcessInput(true))
1485 app.UpdateDisplay();
1488 //printf("Waiting...\n");
1491 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1493 if(ide.projectView.stopBuild)
1495 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1498 return !ide.projectView.stopBuild;
1501 bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, BuildType buildType, List<ProjectNode> onlyNodes,
1502 CompilerConfig compiler, ProjectConfig config, int bitDepth)
1506 bool compiling = false, linking = false, precompiling = false;
1507 int compilingEC = 0;
1508 int numErrors = 0, numWarnings = 0;
1509 bool loggedALine = false;
1510 int lenMakeCommand = strlen(compiler.makeCommand);
1512 const char * t, * s, * s2;
1513 char moduleName[MAX_FILENAME];
1514 const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
1516 DynamicString test { };
1517 DynamicString ecp { };
1518 DynamicString ecc { };
1519 DynamicString ecs { };
1520 DynamicString ear { };
1521 DynamicString prefix { };
1522 DynamicString cpp { };
1523 DynamicString cc { };
1524 DynamicString cxx { };
1525 DynamicString strip { };
1526 DynamicString ar { };
1527 DynamicString windres { };
1530 if(bitDepth == 64 && compiler.targetPlatform == win32)
1531 gnuToolchainPrefix = "x86_64-w64-mingw32-";
1532 else if(bitDepth == 32 && compiler.targetPlatform == win32)
1533 gnuToolchainPrefix = "i686-w64-mingw32-";
1535 ecp.concatx(compiler.ecpCommand, " ");
1536 ecc.concatx(compiler.eccCommand, " ");
1537 ecs.concatx(compiler.ecsCommand, " ");
1538 ear.concatx(compiler.earCommand, " ");
1541 compiler.ccacheEnabled ? "ccache " : "",
1542 compiler.distccEnabled ? "distcc " : "",
1543 gnuToolchainPrefix);
1545 cpp.concatx((String)prefix, compiler.cppCommand, " ");
1546 cc.concatx((String)prefix, compiler.ccCommand, " ");
1547 cxx.concatx((String)prefix, compiler.cxxCommand, " ");
1549 strip.concatx(gnuToolchainPrefix, "strip ");
1550 ar.concatx(gnuToolchainPrefix, "ar rcs");
1551 windres.concatx(gnuToolchainPrefix, "windres ");
1553 testLen = Max(testLen, ecp.size);
1554 testLen = Max(testLen, ecc.size);
1555 testLen = Max(testLen, ecs.size);
1556 testLen = Max(testLen, ear.size);
1557 testLen = Max(testLen, cpp.size);
1558 testLen = Max(testLen, cc.size);
1559 testLen = Max(testLen, cxx.size);
1560 testLen = Max(testLen, strip.size);
1561 testLen = Max(testLen, ar.size);
1562 testLen = Max(testLen, windres.size);
1563 testLen = Max(testLen, strlen("mkdir "));
1566 while(!f.Eof() && !ide.projectView.stopBuild)
1568 double lastTime = GetTime();
1570 while(!f.Eof() && !ide.projectView.stopBuild)
1573 bool lineDone = f.GetLinePeek(line + linePos, sizeof(line)-linePos-1, &nChars);
1577 Sleep(0.5 / PEEK_RESOLUTION);
1584 const char * message = null;
1585 const char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1586 const char * from = strstr(line, stringFrom);
1587 test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
1588 if((t = strstr(line, (s=": recipe for target"))) && (t = strstr(t+strlen(s), (s2 = " failed"))) && (t+strlen(s2))[0] == '\0')
1589 ; // ignore this new gnu make error but what is it about?
1590 else if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
1592 const char * moduleBackTick = strstr(line, "No rule to make target `");
1593 const char * module = moduleBackTick ? moduleBackTick : strstr(line, "No rule to make target '");
1597 module = strchr(module, moduleBackTick ? '`' : '\'') + 1;
1598 end = strchr(module, '\'');
1602 ide.outputView.buildBox.Logf($" %s: No such file or directory\n", module);
1603 // ide.outputView.buildBox.Logf("error: %s\n No such file or directory\n", module);
1609 //ide.outputView.buildBox.Logf("error: %s\n", line);
1613 else if(strstr(test, "mkdir ") == test);
1614 else if((t = strstr(line, "cd ")) && (t = strstr(line, "type ")) && (t = strstr(line, "nul ")) && (t = strstr(line, "copy ")) && (t = strstr(line, "cd ")));
1615 else if(strstr(test, ear) == test);
1616 else if(strstr(test, strip) == test);
1617 else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
1619 char * module = null;
1620 bool isPrecomp = false;
1623 if(strstr(test, cc) == test || strstr(test, cxx) == test)
1625 module = strstr(line, " -c ");
1626 if(module) module += 4;
1629 else if(strstr(test, ecc) == test)
1631 module = strstr(line, " -c ");
1632 if(module) module += 4;
1633 //module = line + 3;
1634 // Don't show GCC warnings about generated C code because it does not compile clean yet...
1635 compilingEC = 3;//2;
1638 else if(strstr(test, ecp) == test)
1640 // module = line + 8;
1641 module = strstr(line, " -c ");
1642 if(module) module += 4;
1653 if(!compiling && !isPrecomp)
1655 ide.outputView.buildBox.Logf($"Compiling...\n");
1658 else if(!precompiling && isPrecomp)
1660 ide.outputView.buildBox.Logf($"Generating symbols...\n");
1661 precompiling = true;
1663 Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
1664 GetLastDirectory(tokens[0], moduleName);
1665 ide.outputView.buildBox.Logf("%s\n", moduleName);
1667 else if((module = strstr(line, " -o ")))
1670 precompiling = false;
1672 ide.outputView.buildBox.Logf($"Linking...\n");
1676 ide.outputView.buildBox.Logf("%s\n", line);
1677 if(strstr(line, "warning:") || strstr(line, "note:"))
1679 else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
1683 if(compilingEC) compilingEC--;
1685 else if(strstr(test, windres) == test)
1688 module = strstr(line, " ");
1689 if(module) module++;
1693 char * dashF = strstr(module, "-F ");
1697 while(*dashF && *dashF != ' ') dashF++;
1698 while(*dashF && *dashF == ' ') dashF++;
1701 Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
1702 GetLastDirectory(module, moduleName);
1703 ide.outputView.buildBox.Logf("%s\n", moduleName);
1706 else if(strstr(test, ar) == test)
1707 ide.outputView.buildBox.Logf($"Building library...\n");
1708 else if(strstr(test, ecs) == test)
1709 ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
1712 if(linking || compiling || precompiling)
1714 const char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
1715 const char * colon = strstr(start, ":"); //, * bracket;
1716 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1717 colon = strstr(colon + 1, ":");
1720 const char * sayError = "";
1721 char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
1724 int len = (int)(colon - start);
1725 char ext[MAX_EXTENSION];
1726 len = Min(len, MAX_LOCATION-1);
1727 // Don't be mistaken by the drive letter colon
1729 // TODO: need to fix colon - line gives char *
1730 // warning: incompatible expression colon - line (char *); expected int
1732 strncpy(moduleName, line, (int)(colon - line));
1733 moduleName[colon - line] = '\0';
1735 strncpy(moduleName, start, len);
1736 moduleName[len] = '\0';
1737 // Remove stuff in brackets
1738 //bracket = strstr(moduleName, "(");
1739 //if(bracket) *bracket = '\0';
1741 GetLastDirectory(moduleName, temp);
1742 GetExtension(temp, ext);
1744 if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
1746 char * cColon = strstr(colon+1, ":");
1747 if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
1748 cColon = strstr(cColon + 1, ":");
1751 int len = (int)(cColon - (colon+1));
1752 char mName[MAX_LOCATION];
1753 len = Min(len, MAX_LOCATION-1);
1754 strncpy(mName, colon+1, len);
1756 GetLastDirectory(mName, temp);
1757 GetExtension(temp, ext);
1758 if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
1761 strcpy(moduleName, mName);
1765 if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
1768 if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
1770 message = $"Linker Message: ";
1773 else if(SearchString(colon, 0, "warning:", false, false))
1775 message = $"Linker Warning: ";
1781 message = $"Linker Error: ";
1784 else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
1788 if(strstr(colon, "Warning:") == colon)
1790 message = $"Linker ";
1793 else if(strstr(line, "error:"))
1795 message = $"Linker Error: ";
1801 strcpy(temp, topNode.path);
1802 PathCatSlash(temp, moduleName);
1803 MakePathRelative(temp, topNode.path, moduleName);
1805 error = strstr(line, "error:");
1806 if(!message && error && error > colon)
1810 // Silence warnings for compiled eC
1811 //char * objDir = strstr(moduleName, objDirExp.dir);
1815 if((pointer = strstr(line, "undefined")) ||
1816 (pointer = strstr(line, "multiple definition")) ||
1817 (pointer = strstr(line, "No such file")) ||
1818 (pointer = strstr(line, "token")))
1820 strncat(moduleName, colon, pointer - colon);
1821 sayError = "error: ";
1826 else if((pointer = strstr(line, "No such file")))
1828 strncat(moduleName, colon, pointer - colon);
1829 sayError = "error: ";
1833 else //if(compilingEC == 1 || (objDir && objDir == moduleName))
1837 // Filter out these warnings caused by eC generated C code:
1839 // Declaration ordering bugs -- Awaiting topo sort implementation
1841 if(strstr(line, "declared inside parameter list")) skip = true;
1842 else if(strstr(line, "its scope is only this definition")) skip = true;
1843 else if(strstr(line, "from incompatible pointer type")) skip = true;
1844 else if(strstr(line, "note: expected 'struct ") || strstr(line, "note: expected ‘struct "))
1846 #define STRUCT_A "'struct "
1847 #define STRUCT_B "‘struct "
1848 char * struct1, * struct2, ch1, ch2;
1849 struct1 = strstr(line, STRUCT_A);
1850 if(struct1) { struct1 += sizeof(STRUCT_A)-1; } else { struct1 = strstr(line, STRUCT_B); struct1 += sizeof(STRUCT_B)-1; };
1852 struct2 = strstr(struct1, STRUCT_A);
1853 if(struct2) { struct2 += sizeof(STRUCT_A)-1; } else { struct2 = strstr(struct1, STRUCT_B); if(struct2) struct2 += sizeof(STRUCT_B)-1; };
1855 if(struct1 && struct2)
1857 while(ch1 = *(struct1++), ch2 = *(struct2++), ch1 && ch2 && (ch1 == '_' || isalnum(ch1)) && (ch2 == '_' || isalnum(ch2)));
1863 // For preprocessed code from objidl.h (MinGW-w64 headers)
1864 else if(strstr(line, "declaration does not declare anything")) skip = true;
1866 // Location information that could apply to ignored warnings
1867 else if(strstr(line, "In function '") || strstr(line, "In function ‘") ) skip = true;
1868 else if(strstr(line, "At top level")) skip = true;
1869 else if(strstr(line, "(near initialization for '") || strstr(line, "(near initialization for ‘")) skip = true;
1874 /*else if(strstr(line, "warning:"))
1880 ide.outputView.buildBox.Logf(" %s%s\n", message, colon);
1881 /*else if(this == ide.workspace.projects.firstIterator.data)
1882 ide.outputView.buildBox.Logf(" %s%s%s\n", moduleName, sayError, colon);*/
1885 char fullModuleName[MAX_LOCATION];
1886 FileAttribs found = 0;
1887 //Project foundProject = this;
1890 char * loc = strstr(moduleName, ":");
1892 strcpy(fullModuleName, topNode.path);
1893 PathCat(fullModuleName, moduleName);
1894 found = FileExists(fullModuleName);
1895 if(!found && !strcmp(ext, "c"))
1897 char ecName[MAX_LOCATION];
1898 ChangeExtension(fullModuleName, "ec", ecName);
1899 found = FileExists(ecName);
1903 char path[MAX_LOCATION];
1904 if(ide && ide.workspace)
1906 for(prj : ide.workspace.projects)
1909 MakePathRelative(fullModuleName, prj.topNode.path, path);
1911 if((node = prj.topNode.FindWithPath(path, false)))
1913 strcpy(fullModuleName, prj.topNode.path);
1914 PathCatSlash(fullModuleName, node.path);
1915 PathCatSlash(fullModuleName, node.name);
1916 found = FileExists(fullModuleName);
1919 //foundProject = prj;
1924 if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
1926 for(prj : ide.workspace.projects)
1929 if((node = prj.topNode.Find(moduleName, false)))
1931 strcpy(fullModuleName, prj.topNode.path);
1932 PathCatSlash(fullModuleName, node.path);
1933 PathCatSlash(fullModuleName, node.name);
1934 found = FileExists(fullModuleName);
1937 //foundProject = prj;
1947 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
1948 MakeSystemPath(fullModuleName);
1951 strcpy(fullModuleName, moduleName);
1954 strcat(fullModuleName, ":");
1955 strcat(fullModuleName, loc + 1);
1959 fullModuleName[0] = 0;
1960 ide.outputView.buildBox.Logf(" %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
1965 ide.outputView.buildBox.Logf("%s\n", line);
1966 linking = compiling = precompiling = false;
1970 ide.outputView.buildBox.Logf("%s\n", line);
1975 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1977 //printf("Processing Input...\n");
1978 if(app.ProcessInput(true))
1980 app.UpdateDisplay();
1983 //printf("Waiting...\n");
1986 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1988 if(ide.projectView.stopBuild)
1990 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1993 else if(loggedALine || buildType != run)
1995 if(f.GetExitCode() && !numErrors)
1997 /*bool result = */f.GetLine(line, sizeof(line)-1);
1998 ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
2000 else if(buildType != install)
2004 char targetFileName[MAX_LOCATION];
2005 targetFileName[0] = '\0';
2006 CatTargetFileName(targetFileName, compiler, config);
2007 ide.outputView.buildBox.Logf("\n%s (%s) - ", targetFileName, lastBuildConfigName);
2010 ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
2012 ide.outputView.buildBox.Logf($"no error, ");
2015 ide.outputView.buildBox.Logf("%d %s\n", numWarnings, (numWarnings > 1) ? $"warnings" : $"warning");
2017 ide.outputView.buildBox.Logf($"no warning\n");
2034 return numErrors == 0 && !ide.projectView.stopBuild;
2037 void ProcessCleanPipeOutput(DualPipe f, CompilerConfig compiler, ProjectConfig config)
2040 int lenMakeCommand = strlen(compiler.makeCommand);
2045 double lastTime = GetTime();
2048 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
2050 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':');
2051 else if(strstr(line, "mkdir") == line);
2052 else if(strstr(line, "del") == line);
2053 else if(strstr(line, "rm") == line);
2054 else if(strstr(line, "Could Not Find") == line);
2057 ide.outputView.buildBox.Logf(line);
2058 ide.outputView.buildBox.Logf("\n");
2062 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
2064 if(app.ProcessInput(true))
2066 app.UpdateDisplay();
2069 //Sleep(1.0 / PEEK_RESOLUTION);
2073 bool Build(BuildType buildType, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, BuildOutputMode outputMode, SingleFileCompileMode mode)
2075 bool result = false;
2077 char targetFileName[MAX_LOCATION] = "";
2078 DynamicString makeTargets { };
2079 char makeFile[MAX_LOCATION];
2080 char makeFilePath[MAX_LOCATION];
2081 char configName[MAX_LOCATION];
2082 DirExpression objDirExp = GetObjDir(compiler, config, bitDepth);
2083 PathBackup pathBackup { };
2084 bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
2085 const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
2087 bool eC_Debug = mode.eC_ToolsDebug;
2088 bool singleProjectOnlyNode = onlyNodes && onlyNodes.count == 1 && onlyNodes[0].type == project;
2089 int numJobs = compiler.numJobs;
2090 char command[MAX_F_STRING*4];
2091 char * compilerName = CopyString(compiler.name);
2092 Map<String, NameCollisionInfo> cfgNameCollisions;
2093 const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) != 0 ? compiler.objectFileExt : null;
2095 delete lastBuildConfigName;
2096 lastBuildConfigName = CopyString(config ? config.name : "Common");
2097 delete lastBuildCompilerName;
2098 lastBuildCompilerName = CopyString(compiler.name);
2099 ProjectLoadLastBuildNamesInfo(this, config);
2100 cfgNameCollisions = configsNameCollisions[config ? config.name : ""];
2102 CamelCase(compilerName);
2104 strcpy(configName, config ? config.name : "Common");
2106 SetPath(false, compiler, config, bitDepth); //true
2107 CatTargetFileName(targetFileName, compiler, config);
2109 strcpy(makeFilePath, topNode.path);
2110 CatMakeFileName(makeFile, config);
2111 PathCatSlash(makeFilePath, makeFile);
2113 // TODO: TEST ON UNIX IF \" around makeTarget is ok
2114 if(buildType == install)
2115 makeTargets.concat(" install");
2118 if(compiler.type.isVC)
2120 PrintLn("compiling a single file is not yet supported");
2124 char pushD[MAX_LOCATION];
2125 char cfDir[MAX_LOCATION];
2126 GetIDECompilerConfigsDir(cfDir, true, true);
2127 GetWorkingDir(pushD, sizeof(pushD));
2128 ChangeWorkingDir(topNode.path);
2129 // Create object dir if it does not exist already
2130 if(!FileExists(objDirExp.dir).isDirectory)
2132 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s%s%s objdir -C \"%s\"%s%s -f \"%s\"",
2133 compiler.makeCommand, cfDir,
2134 crossCompiling ? " TARGET_PLATFORM=" : "",
2136 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2137 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" : */"",
2140 objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
2141 topNode.path, outputMode == verbose ? " V=1" : "", outputMode == justPrint ? " -n" : "", makeFilePath);
2142 if(outputMode != normal)
2143 ide.outputView.buildBox.Logf("%s\n", command);
2147 ChangeWorkingDir(pushD);
2149 for(node : onlyNodes)
2151 if(node.GetIsExcludedForCompiler(config, compiler))
2152 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2156 node.DeleteIntermediateFiles(compiler, config, bitDepth, cfgNameCollisions, mode == cObject ? true : false);
2157 node.GetTargets(config, cfgNameCollisions, objDirExp.dir, compiler.objectFileExt, makeTargets);
2163 if(compiler.type.isVC)
2165 //bool result = false;
2166 char oldwd[MAX_LOCATION];
2167 GetWorkingDir(oldwd, sizeof(oldwd));
2168 ChangeWorkingDir(topNode.path);
2170 // TODO: support justPrint and verbose
2171 sprintf(command, "%s /useenv /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2172 if(outputMode != normal)
2173 ide.outputView.buildBox.Logf("%s\n", command);
2174 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
2176 ProcessPipeOutputRaw(f);
2180 ChangeWorkingDir(oldwd);
2182 else if(onlyNodes && strlen(makeTargets) == 0)
2184 ide.outputView.buildBox.Log("No targets to compile.\n");
2188 GccVersionInfo ccVersion = GetGccVersionInfo(compiler, compiler.ccCommand);
2189 GccVersionInfo cxxVersion = GetGccVersionInfo(compiler, compiler.cxxCommand);
2190 char cfDir[MAX_LOCATION];
2191 GetIDECompilerConfigsDir(cfDir, true, true);
2192 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%s -f \"%s\"",
2193 #if defined(__WIN32__)
2196 buildType == install ? "pkexec --user root " : "",
2198 compiler.makeCommand,
2199 mode == debugPrecompile ? "ECP_DEBUG=y " : mode == debugCompile ? "ECC_DEBUG=y " : mode == debugGenerateSymbols ? "ECS_DEBUG=y " : "",
2201 crossCompiling ? " TARGET_PLATFORM=" : "",
2203 bitDepth ? " ARCH=" : "",
2204 bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2205 ide.workspace.useValgrind ? " DISABLED_POOLING=1" : "",
2206 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
2208 objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
2209 eC_Debug ? "--always-make " : "",
2210 ccVersion == post4_8 ? "GCC_CC_FLAGS=-fno-diagnostics-show-caret " : "",
2211 cxxVersion == post4_8 ? "GCC_CXX_FLAGS=-fno-diagnostics-show-caret " : "",
2213 (compiler.ccacheEnabled && !eC_Debug) ? "CCACHE=y " : "",
2214 (compiler.distccEnabled && !eC_Debug) ? "DISTCC=y " : "",
2215 (String)makeTargets, topNode.path, outputMode == verbose ? " V=1" : "", (outputMode == justPrint || eC_Debug) ? " -n" : "", makeFilePath);
2216 if(outputMode != normal)
2217 ide.outputView.buildBox.Logf("%s\n", command);
2219 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2226 if(outputMode == justPrint)
2227 ide.outputView.buildBox.Logf($"\nMake outputs the following list of commands to choose from:\n");
2233 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
2235 if(outputMode == justPrint)
2236 ide.outputView.buildBox.Logf("%s\n", line);
2237 if(!error && !found && strstr(line, "echo ") == line && strstr(line, "ECERE_SDK_SRC"))
2239 strcpy(command, line+5);
2242 if(!error && (singleProjectOnlyNode || !found) && strstr(line, "ecere-ide ") == line)
2244 strcpy(command, line);
2253 else if(outputMode != normal)
2254 result = ProcessPipeOutputRaw(f);
2256 result = ProcessBuildPipeOutput(f, objDirExp, buildType, onlyNodes, compiler, config, bitDepth);
2259 ide.outputView.buildBox.Logf("%s\n", command);
2260 else if(outputMode == justPrint && found)
2261 ide.outputView.buildBox.Logf($"\nThe following command was chosen to be executed:\n%s\n", command);
2266 ide.outputView.buildBox.Logf($"Error executing make (%s) command\n", compiler.makeCommand);
2271 delete compilerName;
2276 void Clean(CompilerConfig compiler, ProjectConfig config, int bitDepth, CleanType cleanType, BuildOutputMode outputMode)
2278 char makeFile[MAX_LOCATION];
2279 char makeFilePath[MAX_LOCATION];
2280 char command[MAX_LOCATION];
2281 char * compilerName;
2283 PathBackup pathBackup { };
2284 bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
2285 const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
2286 const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) ? compiler.objectFileExt : null;
2288 compilerName = CopyString(compiler.name);
2289 CamelCase(compilerName);
2291 SetPath(false, compiler, config, bitDepth);
2293 strcpy(makeFilePath, topNode.path);
2294 CatMakeFileName(makeFile, config);
2295 PathCatSlash(makeFilePath, makeFile);
2297 if(compiler.type.isVC)
2299 //bool result = false;
2300 char oldwd[MAX_LOCATION];
2301 GetWorkingDir(oldwd, sizeof(oldwd));
2302 ChangeWorkingDir(topNode.path);
2304 // TODO: support justPrint and verbose
2305 sprintf(command, "%s /useenv /clean /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2306 if(outputMode != normal)
2307 ide.outputView.buildBox.Logf("%s\n", command);
2308 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2310 ProcessPipeOutputRaw(f);
2314 ChangeWorkingDir(oldwd);
2319 char cfDir[MAX_LOCATION];
2320 GetIDECompilerConfigsDir(cfDir, true, true);
2321 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s%s%s %sclean%s -C \"%s\"%s%s -f \"%s\"",
2322 compiler.makeCommand, cfDir,
2323 crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
2324 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2326 objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
2327 cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
2328 topNode.path, outputMode == verbose ? " V=1" : "", outputMode == justPrint ? " -n": "", makeFilePath);
2329 if(outputMode != normal)
2330 ide.outputView.buildBox.Logf("%s\n", command);
2331 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2333 ide.outputView.buildBox.Tellf($"Deleting %s%s...",
2334 cleanType == realClean ? $"intermediate objects directory" : $"target",
2335 cleanType == clean ? $" and object files" : "");
2336 if(outputMode != normal)
2337 ProcessPipeOutputRaw(f);
2339 ProcessCleanPipeOutput(f, compiler, config);
2340 ide.outputView.buildBox.Logf($"%s%s deleted\n",
2341 cleanType == realClean ? $"Intermediate objects directory" : $"Target",
2342 cleanType == clean ? $" and object files" : "");
2348 delete compilerName;
2351 void Run(const char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2353 String target = new char[maxPathLen];
2354 char oldDirectory[MAX_LOCATION];
2355 char * executableLauncher = compiler.executableLauncher;
2356 DirExpression targetDirExp = GetTargetDir(compiler, config, bitDepth);
2357 PathBackup pathBackup { };
2359 // Build(project, ...);
2361 strcpy(target, topNode.path);
2362 PathCatSlash(target, targetDirExp.dir);
2363 CatTargetFileName(target, compiler, config);
2364 sprintf(target, "%s %s", target, args);
2365 GetWorkingDir(oldDirectory, MAX_LOCATION);
2367 if(ide.workspace.debugDir && strlen(ide.workspace.debugDir))
2369 char temp[MAX_LOCATION];
2370 strcpy(temp, topNode.path);
2371 PathCatSlash(temp, ide.workspace.debugDir);
2372 ChangeWorkingDir(temp);
2375 ChangeWorkingDir(topNode.path);
2376 SetPath(true, compiler, config, bitDepth);
2377 if(executableLauncher)
2379 char * prefixedTarget = new char[strlen(executableLauncher) + strlen(target) + 8];
2380 prefixedTarget[0] = '\0';
2381 strcat(prefixedTarget, executableLauncher);
2382 strcat(prefixedTarget, " ");
2383 strcat(prefixedTarget, target);
2384 Execute(prefixedTarget);
2385 delete prefixedTarget;
2390 ChangeWorkingDir(oldDirectory);
2393 delete targetDirExp;
2397 bool Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, BuildOutputMode outputMode, SingleFileCompileMode mode)
2399 return Build(build, nodes, compiler, config, bitDepth, outputMode, mode);
2403 void GetMakefileTargetFileName(TargetTypes targetType, char * fileName, ProjectConfig config)
2406 if(targetType == staticLibrary || targetType == sharedLibrary)
2407 strcat(fileName, "$(LP)");
2408 strcat(fileName, GetTargetFileName(config));
2409 strcat(fileName, "$(OUT)");
2412 bool GenerateCrossPlatformMk(File altCrossPlatformMk)
2414 bool result = false;
2415 char path[MAX_LOCATION];
2417 if(!GetProjectCompilerConfigsDir(path, false, false))
2418 GetIDECompilerConfigsDir(path, false, false);
2420 if(!FileExists(path).isDirectory)
2424 char dirName[MAX_FILENAME];
2425 GetLastDirectory(path, dirName);
2426 if(!strcmp(dirName, ".configs"))
2427 FileSetAttribs(path, FileAttribs { isHidden = true });
2430 PathCatSlash(path, "crossplatform.mk");
2432 if(FileExists(path))
2435 File include = altCrossPlatformMk ? altCrossPlatformMk : FileOpen(":crossplatform.mk", read);
2438 File f = FileOpen(path, write);
2441 include.Seek(0, start);
2442 for(; !include.Eof(); )
2445 int count = include.Read(buffer, 1, 4096);
2446 f.Write(buffer, 1, count);
2452 if(!altCrossPlatformMk)
2459 bool GenerateCompilerCf(CompilerConfig compiler, bool eC)
2461 bool result = false;
2462 char path[MAX_LOCATION];
2464 char * compilerName;
2465 bool gccCompiler = compiler.ccCommand && (strstr(compiler.ccCommand, "gcc") != null || strstr(compiler.ccCommand, "g++") != null);
2466 const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
2467 Platform platform = compiler.targetPlatform;
2469 compilerName = CopyString(compiler.name);
2470 CamelCase(compilerName);
2471 name = PrintString(platform, "-", compilerName, ".cf");
2473 if(!GetProjectCompilerConfigsDir(path, false, false))
2474 GetIDECompilerConfigsDir(path, false, false);
2476 if(!FileExists(path).isDirectory)
2480 char dirName[MAX_FILENAME];
2481 GetLastDirectory(path, dirName);
2482 if(!strcmp(dirName, ".configs"))
2483 FileSetAttribs(path, FileAttribs { isHidden = true });
2486 PathCatSlash(path, name);
2488 if(FileExists(path))
2491 File f = FileOpen(path, write);
2494 if(compiler.environmentVars && compiler.environmentVars.count)
2496 f.Puts("# ENVIRONMENT VARIABLES\n");
2498 for(e : compiler.environmentVars)
2500 #if defined(__WIN32__)
2501 ChangeCh(e.string, '\\', '/');
2503 f.Printf("export %s := %s\n", e.name, e.string);
2504 #if defined(__WIN32__)
2505 ChangeCh(e.string, '/', '\\');
2511 f.Puts("# TOOLCHAIN\n");
2514 f.Puts("# OPTIONS\n");
2515 if(compiler.resourcesDotEar)
2516 f.Puts("USE_RESOURCES_EAR := defined\n");
2519 f.Puts("# EXTENSIONS\n");
2520 if(compiler.outputFileExt)
2521 f.Printf("OUT := %s\n", compiler.outputFileExt);
2523 f.Puts("OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))\n");
2525 if(gnuToolchainPrefix && gnuToolchainPrefix[0])
2527 f.Printf("GCC_PREFIX := %s\n", gnuToolchainPrefix);
2530 if(compiler.sysroot && compiler.sysroot[0])
2532 f.Printf("SYSROOT := %s\n", compiler.sysroot);
2533 // Moved this to crossplatform.mk
2534 //f.Puts("_SYSROOT := $(space)--sysroot=$(SYSROOT)\n");
2538 //f.Printf("SHELL := %s\n", "sh"/*compiler.shellCommand*/); // is this really needed?
2539 f.Printf("CPP := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cppCommand);
2540 f.Printf("CC := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.ccCommand);
2541 f.Printf("CXX := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CXX_FLAGS),$(space)$(GCC_CXX_FLAGS),)\n", compiler.cxxCommand);
2544 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);
2545 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);
2546 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);
2550 f.Printf("ECP := %s\n", compiler.ecpCommand);
2551 f.Printf("ECC := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
2552 f.Printf("ECS := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)$(if $(DISABLED_POOLING), -disabled-pooling,)\n", compiler.ecsCommand);
2554 f.Printf("EAR := %s\n", compiler.earCommand);
2556 f.Puts("AS := $(GCC_PREFIX)as\n");
2558 if(compiler.ldCommand && compiler.ldCommand[0])
2560 f.Puts("$(GCC_PREFIX)");
2561 f.Puts(compiler.ldCommand);
2564 f.Puts("$(if $(CONTAINS_CXX),$(CXX),$(CC))");
2565 f.Puts("$(_SYSROOT)$(if $(GCC_LD_FLAGS),$(space)$(GCC_LD_FLAGS),)\n");
2567 f.Printf("AR := $(GCC_PREFIX)%s\n", compiler.arCommand);
2568 f.Puts("STRIP := $(GCC_PREFIX)strip\n");
2569 f.Puts("ifdef WINDOWS_TARGET\n");
2570 f.Puts("WINDRES := $(GCC_PREFIX)windres\n");
2571 f.Puts(" ifdef ARCH\n");
2572 f.Puts(" ifeq ($(ARCH),x32)\n");
2573 f.Puts("WINDRES_FLAGS := -F pe-i386\n");
2575 f.Puts(" ifeq ($(ARCH),x64)\n");
2576 f.Puts("WINDRES_FLAGS := -F pe-x86-64\n");
2581 f.Puts("UPX := upx\n");
2584 f.Puts("UPXFLAGS = -9\n"); // TOFEAT: Compression Level Option? Other UPX Options?
2587 f.Puts("EARFLAGS = \n");
2590 f.Puts("ifndef ARCH\n");
2591 f.Puts("TARGET_ARCH :=$(shell $(CC) -dumpmachine)\n");
2592 f.Puts(" ifdef WINDOWS_HOST\n");
2593 f.Puts(" ifneq ($(filter x86_64%,$(TARGET_ARCH)),)\n");
2594 f.Puts(" TARGET_ARCH := x86_64\n");
2596 f.Puts(" TARGET_ARCH := i386\n");
2599 f.Puts("endif\n\n");
2601 f.Puts("# HARD CODED TARGET_PLATFORM-SPECIFIC OPTIONS\n");
2602 f.Printf("LDFLAGS +=$(if $(%s), -Wl$(comma)--no-undefined,)\n", PlatformToMakefileTargetVariable(tux));
2606 f.Printf("LDFLAGS +=$(if $(%s), -framework cocoa -framework OpenGL,)\n", PlatformToMakefileTargetVariable(apple));
2610 f.Puts("\nCFLAGS += -fmessage-length=0\n");
2613 if(compiler.includeDirs && compiler.includeDirs.count)
2615 f.Puts("\nCFLAGS +=");
2616 OutputFlags(f, gccCompiler ? _isystem : _I, compiler.includeDirs, lineEach);
2619 if(compiler.prepDirectives && compiler.prepDirectives.count)
2621 f.Puts("\nCFLAGS +=");
2622 OutputFlags(f, _D, compiler.prepDirectives, inPlace);
2625 if(compiler.libraryDirs && compiler.libraryDirs.count)
2627 f.Puts("\nLDFLAGS +=");
2628 OutputFlags(f, _L, compiler.libraryDirs, lineEach);
2629 // We would need a bool option to know whether we want to add to rpath as well...
2630 // OutputFlags(f, _Wl-rpath, compiler.libraryDirs, lineEach);
2633 if(compiler.excludeLibs && compiler.excludeLibs.count)
2635 f.Puts("\nEXCLUDED_LIBS =");
2636 for(l : compiler.excludeLibs)
2642 if(compiler.eCcompilerFlags && compiler.eCcompilerFlags.count)
2644 f.Puts("\nECFLAGS +=");
2645 OutputFlags(f, any, compiler.eCcompilerFlags, inPlace);
2648 if(compiler.compilerFlags && compiler.compilerFlags.count)
2650 f.Puts("\nCFLAGS +=");
2651 OutputFlags(f, any, compiler.compilerFlags, inPlace);
2654 if(compiler.linkerFlags && compiler.linkerFlags.count)
2656 f.Puts("\nLDFLAGS +=");
2657 OutputFlags(f, _Wl, compiler.linkerFlags, inPlace);
2661 f.Puts("\nOFLAGS += $(LDFLAGS)");
2663 f.Puts("ifdef ARCH_FLAGS\n");
2664 f.Puts("CFLAGS += $(ARCH_FLAGS)\n");
2665 f.Puts("OFLAGS += $(ARCH_FLAGS)\n");
2674 delete compilerName;
2678 bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config)
2680 bool result = false;
2681 char filePath[MAX_LOCATION];
2682 char makeFile[MAX_LOCATION];
2683 // PathBackup pathBackup { };
2684 // char oldDirectory[MAX_LOCATION];
2687 if(!altMakefilePath)
2689 strcpy(filePath, topNode.path);
2690 CatMakeFileName(makeFile, config);
2691 PathCatSlash(filePath, makeFile);
2694 f = FileOpen(altMakefilePath ? altMakefilePath : filePath, write);
2696 /*SetPath(false, compiler, config);
2697 GetWorkingDir(oldDirectory, MAX_LOCATION);
2698 ChangeWorkingDir(topNode.path);*/
2705 char targetDir[MAX_LOCATION];
2706 char objDirExpNoSpaces[MAX_LOCATION];
2707 char objDirNoSpaces[MAX_LOCATION];
2708 char resDirNoSpaces[MAX_LOCATION];
2709 char targetDirExpNoSpaces[MAX_LOCATION];
2710 char fixedModuleName[MAX_FILENAME];
2711 char fixedConfigName[MAX_FILENAME];
2713 int lenObjDirExpNoSpaces, lenTargetDirExpNoSpaces;
2714 // Non-zero if we're building eC code
2715 // We'll have to be careful with this when merging configs where eC files can be excluded in some configs and included in others
2716 int numCObjects = 0;
2718 int numRCObjects = 0;
2719 bool containsCXX = false; // True if the project contains a C++ file
2720 bool relObjDir, sameOrRelObjTargetDirs;
2721 const String objDirExp = GetObjDirExpression(config);
2722 TargetTypes targetType = GetTargetType(config);
2724 char cfDir[MAX_LOCATION];
2725 int objectsParts = 0;
2726 int eCsourcesParts = 0;
2727 int rcSourcesParts = 0;
2728 Array<String> listItems { };
2729 Map<String, int> varStringLenDiffs { };
2730 Map<String, NameCollisionInfo> namesInfo { };
2732 Map<String, int> cflagsVariations { };
2733 Map<intptr, int> nodeCFlagsMapping { };
2735 Map<String, int> ecflagsVariations { };
2736 Map<intptr, int> nodeECFlagsMapping { };
2738 ReplaceSpaces(objDirNoSpaces, objDirExp);
2739 strcpy(targetDir, GetTargetDirExpression(config));
2740 ReplaceSpaces(targetDirExpNoSpaces, targetDir);
2742 strcpy(objDirExpNoSpaces, GetObjDirExpression(config));
2743 ChangeCh(objDirExpNoSpaces, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
2745 char temp[MAX_LOCATION];
2746 ReplaceSpaces(temp, objDirExpNoSpaces);
2747 strcpy(objDirExpNoSpaces, temp);
2749 ReplaceSpaces(resDirNoSpaces, resNode.path ? resNode.path : "");
2750 ReplaceSpaces(fixedModuleName, moduleName);
2751 ReplaceSpaces(fixedConfigName, GetConfigName(config));
2752 CamelCase(fixedConfigName);
2754 lenObjDirExpNoSpaces = strlen(objDirExpNoSpaces);
2755 relObjDir = lenObjDirExpNoSpaces == 0 ||
2756 (objDirExpNoSpaces[0] == '.' && (lenObjDirExpNoSpaces == 1 || objDirExpNoSpaces[1] == '.'));
2757 lenTargetDirExpNoSpaces = strlen(targetDirExpNoSpaces);
2758 sameOrRelObjTargetDirs = lenTargetDirExpNoSpaces == 0 ||
2759 (targetDirExpNoSpaces[0] == '.' && (lenTargetDirExpNoSpaces == 1 || targetDirExpNoSpaces[1] == '.')) ||
2760 !fstrcmp(objDirExpNoSpaces, targetDirExpNoSpaces);
2762 f.Printf(".PHONY: all objdir%s cleantarget clean realclean distclean\n\n", sameOrRelObjTargetDirs ? "" : " targetdir");
2764 f.Puts("# CORE VARIABLES\n\n");
2766 f.Printf("MODULE := %s\n", fixedModuleName);
2767 f.Printf("VERSION := %s\n", property::moduleVersion);
2768 f.Printf("CONFIG := %s\n", fixedConfigName);
2769 topNode.GenMakefilePrintNode(f, this, noPrint, null, null, config, &containsCXX);
2771 f.Puts("CONTAINS_CXX := defined\n");
2772 f.Puts("ifndef COMPILER\n" "COMPILER := default\n" "endif\n");
2775 test = GetTargetTypeIsSetByPlatform(config);
2779 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2781 TargetTypes targetType;
2782 PlatformOptions projectPOs, configPOs;
2783 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2784 targetType = platformTargetType;
2790 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
2791 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2796 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2801 for(c = 0; c < ifCount; c++)
2807 f.Puts("# FLAGS\n\n");
2809 f.Puts("ECFLAGS =\n");
2810 f.Puts("ifndef DEBIAN_PACKAGE\n" "CFLAGS =\n" "LDFLAGS =\n" "endif\n");
2811 f.Puts("PRJ_CFLAGS =\n");
2812 f.Puts("CECFLAGS =\n");
2813 f.Puts("OFLAGS =\n");
2817 f.Puts("ifdef DEBUG\n" "NOSTRIP := y\n" "endif\n");
2820 // Important: We cannot use this ifdef anymore, EXECUTABLE_TARGET is not yet defined. It's embedded in the crossplatform.mk EXECUTABLE
2821 //f.Puts("ifdef EXECUTABLE_TARGET\n");
2822 f.Printf("CONSOLE = %s\n", GetConsole(config) ? "-mconsole" : "-mwindows");
2823 //f.Puts("endif\n");
2826 f.Puts("# INCLUDES\n\n");
2828 if(compilerConfigsDir && compilerConfigsDir[0])
2830 strcpy(cfDir, compilerConfigsDir);
2831 if(cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
2836 GetIDECompilerConfigsDir(cfDir, true, true);
2837 // Use CF_DIR environment variable for absolute paths only
2838 if(cfDir[0] == '/' || (cfDir[0] && cfDir[1] == ':'))
2839 strcpy(cfDir, "$(CF_DIR)");
2842 f.Printf("_CF_DIR = %s\n", cfDir);
2845 f.Printf("include %s\n", includemkPath ? includemkPath : "$(_CF_DIR)crossplatform.mk");
2846 f.Puts("include $(_CF_DIR)$(TARGET_PLATFORM)-$(COMPILER).cf\n");
2849 f.Puts("# POST-INCLUDES VARIABLES\n\n");
2851 f.Printf("OBJ = %s%s\n", objDirExpNoSpaces, objDirExpNoSpaces[0] ? "/" : "");
2854 f.Printf("RES = %s%s\n", resDirNoSpaces, resDirNoSpaces[0] ? "/" : "");
2857 // test = GetTargetTypeIsSetByPlatform(config);
2859 char target[MAX_LOCATION];
2860 char temp[MAX_LOCATION];
2865 for(type = (TargetTypes)1; type < TargetTypes::enumSize; type++)
2867 if(type != targetType)
2872 f.Printf("ifeq ($(TARGET_TYPE),%s)\n", TargetTypeToMakefileVariable(type));
2874 GetMakefileTargetFileName(type, target, config);
2875 strcpy(temp, targetDir);
2876 PathCatSlash(temp, target);
2877 ReplaceSpaces(target, temp);
2878 f.Printf("TARGET = %s\n", target);
2883 GetMakefileTargetFileName(targetType, target, config);
2884 strcpy(temp, targetDir);
2885 PathCatSlash(temp, target);
2886 ReplaceSpaces(target, temp);
2887 f.Printf("TARGET = %s\n", target);
2893 for(c = 0; c < ifCount; c++)
2900 // Use something fixed here, to not cause Makefile differences across compilers...
2901 varStringLenDiffs["$(OBJ)"] = 30; // strlen("obj/memoryGuard.android.gcc-4.6.2") - 6;
2902 // varStringLenDiffs["$(OBJ)"] = strlen(objDirNoSpaces) - 6;
2904 topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
2908 const char * map[5][2] = { { "COBJECTS", "C" }, { "SYMBOLS", "S" }, { "IMPORTS", "I" }, { "ECOBJECTS", "O" }, { "BOWLS", "B" } };
2910 numCObjects = topNode.GenMakefilePrintNode(f, this, eCsources, namesInfo, listItems, config, null);
2913 eCsourcesParts = OutputFileList(f, "_ECSOURCES", listItems, varStringLenDiffs, null);
2915 f.Puts("ECSOURCES = $(call shwspace,$(_ECSOURCES))\n");
2916 if(eCsourcesParts > 1)
2918 for(c = 1; c <= eCsourcesParts; c++)
2919 f.Printf("ECSOURCES%d = $(call shwspace,$(_ECSOURCES%d))\n", c, c);
2923 for(c = 0; c < 5; c++)
2925 if(eCsourcesParts > 1)
2928 f.Printf("_%s =", map[c][0]);
2929 for(n = 1; n <= eCsourcesParts; n++)
2930 f.Printf(" $(%s%d)", map[c][0], n);
2932 for(n = 1; n <= eCsourcesParts; n++)
2933 f.Printf("_%s%d = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES%d))))\n", map[c][0], n, map[c][1], n);
2935 else if(eCsourcesParts == 1)
2936 f.Printf("_%s = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES))))\n", map[c][0], map[c][1]);
2940 for(c = 0; c < 5; c++)
2942 if(eCsourcesParts > 1)
2945 f.Printf("%s =", map[c][0]);
2946 for(n = 1; n <= eCsourcesParts; n++)
2947 f.Printf(" $(%s%d)", map[c][0], n);
2949 for(n = 1; n <= eCsourcesParts; n++)
2950 f.Printf("%s%d = $(call shwspace,$(_%s%d))\n", map[c][0], n, map[c][0], n);
2952 else if(eCsourcesParts == 1)
2953 f.Printf("%s = $(call shwspace,$(_%s))\n", map[c][0], map[c][0]);
2959 numRCObjects = topNode.GenMakefilePrintNode(f, this, rcSources, namesInfo, listItems, config, null);
2962 f.Puts("ifdef WINDOWS_TARGET\n\n");
2964 rcSourcesParts = OutputFileList(f, "_RCSOURCES", listItems, varStringLenDiffs, null);
2966 f.Puts("RCSOURCES = $(call shwspace,$(_RCSOURCES))\n");
2967 if(rcSourcesParts > 1)
2969 for(c = 1; c <= rcSourcesParts; c++)
2970 f.Printf("RCSOURCES%d = $(call shwspace,$(_RCSOURCES%d))\n", c, c);
2973 if(rcSourcesParts > 1)
2976 f.Printf("%s =", "RCOBJECTS");
2977 for(n = 1; n <= rcSourcesParts; n++)
2978 f.Printf(" $(%s%d)", "RCOBJECTS", n);
2980 for(n = 1; n <= rcSourcesParts; n++)
2981 f.Printf("%s%d = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.rc,%%$(%s),$(notdir $(_RCSOURCES%d)))))\n", "RCOBJECTS", n, "O", n);
2983 else if(rcSourcesParts == 1)
2984 f.Printf("%s = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.rc,%%$(%s),$(notdir $(_RCSOURCES)))))\n", "RCOBJECTS", "O");
2988 f.Puts("RCSOURCES =\n");
2989 f.Puts("RCOBJECTS =\n");
2990 f.Puts("endif\n\n");
2993 numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, null);
2995 objectsParts = OutputFileList(f, "_OBJECTS", listItems, varStringLenDiffs, null);
2996 f.Printf("OBJECTS =%s%s%s%s\n",
2997 numObjects ? " $(_OBJECTS)" : "", numCObjects ? " $(ECOBJECTS)" : "",
2998 numCObjects ? " $(OBJ)$(MODULE).main$(O)" : "",
2999 numRCObjects ? " $(RCOBJECTS)" : "");
3002 topNode.GenMakefilePrintNode(f, this, sources, null, listItems, config, null);
3004 const char * prefix;
3005 if(numCObjects && numRCObjects)
3006 prefix = "$(ECSOURCES) $(RCSOURCES)";
3007 else if(numCObjects)
3008 prefix = "$(ECSOURCES)";
3011 OutputFileList(f, "SOURCES", listItems, varStringLenDiffs, prefix);
3015 resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config, null);
3016 OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs, null);
3018 f.Puts("ifdef USE_RESOURCES_EAR\n");
3019 f.Puts("RESOURCES_EAR = $(OBJ)resources.ear\n");
3021 f.Puts("RESOURCES_EAR = $(RESOURCES)\n");
3025 f.Puts("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n");
3027 if((config && config.options && config.options.libraries) ||
3028 (options && options.libraries))
3030 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3032 if(config && config.options && config.options.libraries)
3033 OutputLibraries(f, config.options.libraries);
3034 else if(options && options.libraries)
3035 OutputLibraries(f, options.libraries);
3041 topNode.GenMakeCollectAssignNodeFlags(config, numCObjects != 0,
3042 cflagsVariations, nodeCFlagsMapping,
3043 ecflagsVariations, nodeECFlagsMapping, null);
3045 GenMakePrintCustomFlags(f, "PRJ_CFLAGS", false, cflagsVariations);
3046 f.Puts("ECFLAGS += -module $(MODULE)\n");
3047 GenMakePrintCustomFlags(f, "ECFLAGS", true, ecflagsVariations);
3049 if(platforms || (config && config.platforms))
3052 //for(platform = firstPlatform; platform <= lastPlatform; platform++)
3053 //for(platform = win32; platform <= apple; platform++)
3055 f.Puts("# PLATFORM-SPECIFIC OPTIONS\n\n");
3056 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3058 PlatformOptions projectPlatformOptions, configPlatformOptions;
3059 MatchProjectAndConfigPlatformOptions(config, platform, &projectPlatformOptions, &configPlatformOptions);
3061 if(projectPlatformOptions || configPlatformOptions)
3066 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3069 if((projectPlatformOptions && projectPlatformOptions.options.compilerOptions && projectPlatformOptions.options.compilerOptions.count) ||
3070 (configPlatformOptions && configPlatformOptions.options.compilerOptions && configPlatformOptions.options.compilerOptions.count))
3072 f.Puts("CFLAGS +=");
3073 if(projectPlatformOptions && projectPlatformOptions.options.compilerOptions && projectPlatformOptions.options.compilerOptions.count)
3076 for(s : projectPlatformOptions.options.compilerOptions)
3079 if(configPlatformOptions && configPlatformOptions.options.compilerOptions && configPlatformOptions.options.compilerOptions.count)
3082 for(s : configPlatformOptions.options.compilerOptions)
3089 if((projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count) ||
3090 (configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count))
3092 f.Puts("OFLAGS +=");
3093 if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
3095 bool needWl = false;
3097 for(s : projectPlatformOptions.options.linkerOptions)
3099 if(!IsLinkerOption(s))
3107 for(s : projectPlatformOptions.options.linkerOptions)
3108 if(IsLinkerOption(s))
3112 if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
3114 bool needWl = false;
3116 for(s : configPlatformOptions.options.linkerOptions)
3118 if(IsLinkerOption(s))
3126 for(s : configPlatformOptions.options.linkerOptions)
3127 if(!IsLinkerOption(s))
3135 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
3136 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count) ||
3137 (projectPlatformOptions && projectPlatformOptions.options.libraries && projectPlatformOptions.options.libraries.count) ||
3138 (configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
3140 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3141 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
3142 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count))
3144 f.Puts("OFLAGS +=");
3145 if(configPlatformOptions && configPlatformOptions.options.libraryDirs)
3146 OutputFlags(f, _L, configPlatformOptions.options.libraryDirs, lineEach);
3147 if(projectPlatformOptions && projectPlatformOptions.options.libraryDirs)
3148 OutputFlags(f, _L, projectPlatformOptions.options.libraryDirs, lineEach);
3152 if(configPlatformOptions && configPlatformOptions.options.libraries)
3154 if(configPlatformOptions.options.libraries.count)
3157 OutputLibraries(f, configPlatformOptions.options.libraries);
3161 else if(projectPlatformOptions && projectPlatformOptions.options.libraries)
3163 if(projectPlatformOptions.options.libraries.count)
3166 OutputLibraries(f, projectPlatformOptions.options.libraries);
3177 for(c = 0; c < ifCount; c++)
3183 if((config && config.options && config.options.compilerOptions && config.options.compilerOptions.count) ||
3184 (options && options.compilerOptions && options.compilerOptions.count))
3186 f.Puts("CFLAGS +=");
3189 if(config && config.options && config.options.compilerOptions && config.options.compilerOptions.count)
3191 for(s : config.options.compilerOptions)
3194 if(options && options.compilerOptions && options.compilerOptions.count)
3196 for(s : options.compilerOptions)
3203 if((config && config.options && config.options.linkerOptions && config.options.linkerOptions.count) ||
3204 (options && options.linkerOptions && options.linkerOptions.count))
3206 f.Puts("OFLAGS +=");
3209 if(config && config.options && config.options.linkerOptions && config.options.linkerOptions.count)
3211 bool needWl = false;
3212 for(s : config.options.linkerOptions)
3214 if(!IsLinkerOption(s))
3222 for(s : config.options.linkerOptions)
3223 if(IsLinkerOption(s))
3227 if(options && options.linkerOptions && options.linkerOptions.count)
3229 bool needWl = false;
3230 for(s : options.linkerOptions)
3232 if(!IsLinkerOption(s))
3240 for(s : options.linkerOptions)
3241 if(IsLinkerOption(s))
3249 f.Puts("CECFLAGS += -cpp $(_CPP)");
3253 if(GetProfile(config))
3254 f.Puts("OFLAGS += -pg\n\n");
3256 if((config && config.options && config.options.libraryDirs) || (options && options.libraryDirs))
3258 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3259 f.Puts("OFLAGS +=");
3260 if(config && config.options && config.options.libraryDirs)
3261 OutputFlags(f, _L, config.options.libraryDirs, lineEach);
3262 if(options && options.libraryDirs)
3263 OutputFlags(f, _L, options.libraryDirs, lineEach);
3269 f.Puts("# TARGETS\n");
3272 f.Printf("all: objdir%s $(TARGET)\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3275 f.Puts("objdir:\n");
3277 f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdir,$(OBJ)))\n");
3280 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");
3281 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");
3283 //f.Puts("# PRE-BUILD COMMANDS\n");
3284 if(options && options.prebuildCommands)
3286 for(s : options.prebuildCommands)
3287 if(s && s[0]) f.Printf("\t%s\n", s);
3289 if(config && config.options && config.options.prebuildCommands)
3291 for(s : config.options.prebuildCommands)
3292 if(s && s[0]) f.Printf("\t%s\n", s);
3294 if(platforms || (config && config.platforms))
3297 //f.Puts("# TARGET_PLATFORM-SPECIFIC PRE-BUILD COMMANDS\n");
3298 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3300 PlatformOptions projectPOs, configPOs;
3301 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3303 if((projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count) ||
3304 (configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count))
3309 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3311 if(projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count)
3313 for(s : projectPOs.options.prebuildCommands)
3314 if(s && s[0]) f.Printf("\t%s\n", s);
3316 if(configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count)
3318 for(s : configPOs.options.prebuildCommands)
3319 if(s && s[0]) f.Printf("\t%s\n", s);
3326 for(c = 0; c < ifCount; c++)
3332 if(!sameOrRelObjTargetDirs)
3334 f.Puts("targetdir:\n");
3335 f.Printf("\t$(if $(wildcard %s),,$(call mkdir,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
3341 // Main Module (Linking) for ECERE C modules
3342 f.Puts("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
3343 f.Printf("\t@$(call rm,$(OBJ)symbols.lst)\n");
3344 f.Printf("\t@$(call touch,$(OBJ)symbols.lst)\n");
3345 OutputFileListActions(f, "SYMBOLS", eCsourcesParts, "$(OBJ)symbols.lst");
3346 OutputFileListActions(f, "IMPORTS", eCsourcesParts, "$(OBJ)symbols.lst");
3347 // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
3348 f.Printf("\t$(ECS)%s $(ARCH_FLAGS) $(ECSLIBOPT) @$(OBJ)symbols.lst -symbols %s -o $(call quote_path,$@)\n",
3349 GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
3351 // Main Module (Linking) for ECERE C modules
3352 f.Puts("$(OBJ)$(MODULE).main.c: $(OBJ)$(MODULE).main.ec\n");
3353 f.Puts("\t$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS)"
3354 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
3355 f.Puts("\t$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY)"
3356 " -c $(OBJ)$(MODULE).main.ec -o $(call quote_path,$@) -symbols $(OBJ)\n");
3360 if(resNode.files && resNode.files.count && !noResources)
3362 f.Puts("ifdef USE_RESOURCES_EAR\n");
3363 f.Puts("$(RESOURCES_EAR): $(RESOURCES) | objdir\n");
3364 resNode.GenMakefileAddResources(f, resNode.path, config, "RESOURCES_EAR");
3371 // This would not rebuild the target on updated objects
3372 // f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) | objdir $(SYMBOLS) $(OBJECTS)%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3374 // This should fix it for good!
3375 f.Puts("$(SYMBOLS): | objdir\n");
3376 f.Puts("$(OBJECTS): | objdir\n");
3378 // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
3379 f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES_EAR) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
3380 rcSourcesParts ? " $(RCSOURCES)" : "", sameOrRelObjTargetDirs ? "" : " targetdir");
3382 f.Printf("\t@$(call rm,$(OBJ)objects.lst)\n");
3383 f.Printf("\t@$(call touch,$(OBJ)objects.lst)\n");
3384 OutputFileListActions(f, "_OBJECTS", objectsParts, "$(OBJ)objects.lst");
3387 f.Puts("ifdef WINDOWS_TARGET\n");
3388 OutputFileListActions(f, "RCOBJECTS", rcSourcesParts, "$(OBJ)objects.lst");
3393 f.Printf("\t$(call addtolistfile,$(OBJ)$(MODULE).main$(O),$(OBJ)objects.lst)\n");
3394 OutputFileListActions(f, "ECOBJECTS", eCsourcesParts, "$(OBJ)objects.lst");
3397 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3399 f.Puts("\t$(LD) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
3400 if(!GetDebug(config))
3402 f.Puts("ifndef NOSTRIP\n");
3403 f.Puts("\t$(STRIP) $(STRIPOPT) $(TARGET)\n");
3406 if(GetCompress(config))
3408 f.Printf("ifndef %s\n", PlatformToMakefileTargetVariable(win32));
3409 f.Puts("ifdef EXECUTABLE_TARGET\n");
3410 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3413 //f.Puts("ifneq ($(TARGET_ARCH),x86_64)\n");
3414 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3415 //f.Puts("endif\n");
3419 if(resNode.files && resNode.files.count && !noResources)
3421 f.Puts("ifndef USE_RESOURCES_EAR\n");
3422 resNode.GenMakefileAddResources(f, resNode.path, config, "TARGET");
3426 f.Puts("ifdef WINDOWS_HOST\n");
3427 f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)objects.lst $(LIBS)\n");
3429 f.Puts("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
3432 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3433 f.Puts("ifdef LINUX_TARGET\n");
3434 f.Puts("ifdef LINUX_HOST\n");
3435 // TODO?: support symlinks for longer version numbers
3436 f.Puts("\t$(if $(basename $(VER)),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)),)\n");
3437 f.Puts("\t$(if $(VER),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO),)\n");
3442 //f.Puts("# POST-BUILD COMMANDS\n");
3443 if(options && options.postbuildCommands)
3445 for(s : options.postbuildCommands)
3446 if(s && s[0]) f.Printf("\t%s\n", s);
3448 if(config && config.options && config.options.postbuildCommands)
3450 for(s : config.options.postbuildCommands)
3451 if(s && s[0]) f.Printf("\t%s\n", s);
3453 if(platforms || (config && config.platforms))
3456 //f.Puts("# TARGET_PLATFORM-SPECIFIC POST-BUILD COMMANDS\n");
3457 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3459 PlatformOptions projectPOs, configPOs;
3460 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3462 if((projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count) ||
3463 (configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count))
3468 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3470 if(projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count)
3472 for(s : projectPOs.options.postbuildCommands)
3473 if(s && s[0]) f.Printf("\t%s\n", s);
3475 if(configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count)
3477 for(s : configPOs.options.postbuildCommands)
3478 if(s && s[0]) f.Printf("\t%s\n", s);
3485 for(c = 0; c < ifCount; c++)
3492 if(platforms || (config && config.platforms))
3494 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3496 PlatformOptions projectPOs, configPOs;
3497 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3499 if((projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count) ||
3500 (configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count))
3507 if(test || (options && options.installCommands) ||
3508 (config && config.options && config.options.installCommands))
3510 f.Puts("install:\n");
3511 if(options && options.installCommands)
3513 for(s : options.installCommands)
3514 if(s && s[0]) f.Printf("\t%s\n", s);
3516 if(config && config.options && config.options.installCommands)
3518 for(s : config.options.installCommands)
3519 if(s && s[0]) f.Printf("\t%s\n", s);
3521 if(platforms || (config && config.platforms))
3524 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3526 PlatformOptions projectPOs, configPOs;
3527 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3529 if((projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count) ||
3530 (configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count))
3535 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3537 if(projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count)
3539 for(s : projectPOs.options.installCommands)
3540 if(s && s[0]) f.Printf("\t%s\n", s);
3542 if(configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count)
3544 for(s : configPOs.options.installCommands)
3545 if(s && s[0]) f.Printf("\t%s\n", s);
3552 for(c = 0; c < ifCount; c++)
3559 f.Puts("# SYMBOL RULES\n");
3562 topNode.GenMakefilePrintSymbolRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3564 f.Puts("# C OBJECT RULES\n");
3567 topNode.GenMakefilePrintCObjectRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3569 f.Puts("# OBJECT RULES\n");
3571 // todo call this still but only generate rules whith specific options
3572 // see we-have-file-specific-options in ProjectNode.ec
3573 topNode.GenMakefilePrintObjectRules(f, this, namesInfo, config, nodeCFlagsMapping, nodeECFlagsMapping);
3576 GenMakefilePrintMainObjectRule(f, config);
3578 f.Printf("cleantarget: objdir%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3581 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)");
3582 f.Printf("\t$(call rm,$(OBJ)symbols.lst)\n");
3584 f.Printf("\t$(call rm,$(OBJ)objects.lst)\n");
3585 f.Puts("\t$(call rm,$(TARGET))\n");
3586 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3587 f.Puts("ifdef LINUX_TARGET\n");
3588 f.Puts("ifdef LINUX_HOST\n");
3589 // TODO?: support symlinks for longer version numbers
3590 f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
3591 f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO))\n");
3597 f.Puts("clean: cleantarget\n");
3598 OutputCleanActions(f, "OBJECTS", objectsParts);
3601 f.Puts("ifdef WINDOWS_TARGET\n");
3602 OutputCleanActions(f, "RCOBJECTS", rcSourcesParts);
3607 OutputCleanActions(f, "ECOBJECTS", eCsourcesParts);
3608 OutputCleanActions(f, "COBJECTS", eCsourcesParts);
3609 OutputCleanActions(f, "BOWLS", eCsourcesParts);
3610 OutputCleanActions(f, "IMPORTS", eCsourcesParts);
3611 OutputCleanActions(f, "SYMBOLS", eCsourcesParts);
3613 if(resNode.files && resNode.files.count && !noResources)
3615 f.Puts("ifdef USE_RESOURCES_EAR\n");
3616 f.Printf("\t$(call rm,$(RESOURCES_EAR))\n");
3621 f.Puts("realclean: cleantarget\n");
3622 f.Puts("\t$(call rmr,$(OBJ))\n");
3623 if(!sameOrRelObjTargetDirs)
3624 f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
3627 f.Puts("distclean: cleantarget\n");
3628 if(!sameOrRelObjTargetDirs)
3629 f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
3631 f.Puts("\t$(call rmr,obj/)\n");
3632 f.Puts("\t$(call rmr,.configs/)\n");
3633 f.Puts("\t$(call rm,*.ews)\n");
3634 f.Puts("\t$(call rm,*.Makefile)\n");
3640 varStringLenDiffs.Free();
3641 delete varStringLenDiffs;
3645 delete cflagsVariations;
3646 delete nodeCFlagsMapping;
3647 delete ecflagsVariations;
3648 delete nodeECFlagsMapping;
3653 // ChangeWorkingDir(oldDirectory);
3654 // delete pathBackup;
3657 config.makingModified = false;
3661 void GenMakefilePrintMainObjectRule(File f, ProjectConfig config)
3663 char extension[MAX_EXTENSION] = "c";
3664 //char modulePath[MAX_LOCATION];
3665 char fixedModuleName[MAX_FILENAME];
3667 //char command[2048];
3668 char objDirNoSpaces[MAX_LOCATION];
3669 const String objDirExp = GetObjDirExpression(config);
3671 ReplaceSpaces(objDirNoSpaces, objDirExp);
3672 ReplaceSpaces(fixedModuleName, moduleName);
3674 //sprintf(fixedModuleName, "%s.main", fixedPrjName);
3675 //strcat(fixedModuleName, ".main");
3677 #if 0 // TODO: Fix nospaces stuff
3678 // *** Dependency command ***
3679 sprintf(command, "gcc -MT $(OBJ)%s$(O) -MM $(OBJ)%s.c", fixedModuleName, fixedModuleName);
3681 // System Includes (from global settings)
3682 for(item : compiler.dirs[Includes])
3684 strcat(command, " -isystem ");
3685 if(strchr(item.name, ' '))
3687 strcat(command, "\"");
3688 strcat(command, item);
3689 strcat(command, "\"");
3692 strcat(command, item);
3695 for(item = includeDirs.first; item; item = item.next)
3697 strcat(command, " -I");
3698 if(strchr(item.name, ' '))
3700 strcat(command, "\"");
3701 strcat(command, item.name);
3702 strcat(command, "\"");
3705 strcat(command, item.name);
3707 for(item = preprocessorDefs.first; item; item = item.next)
3709 strcat(command, " -D");
3710 strcat(command, item.name);
3714 if((dep = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
3718 bool firstLine = true;
3720 // To do some time: auto save external dependencies?
3723 if(dep.GetLine(line, sizeof(line)-1))
3727 char * colon = strstr(line, ":");
3728 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
3742 // If we failed to generate dependencies...
3746 f.Puts("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
3747 f.Printf("\t$(CC) $(CFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(call quote_path,$@)\n", extension);
3755 void GenMakePrintCustomFlags(File f, const String variableName, bool printNonCustom, Map<String, int> cflagsVariations)
3758 for(c = printNonCustom ? 0 : 1; c <= cflagsVariations.count; c++)
3760 for(v : cflagsVariations)
3765 f.Printf("%s +=", variableName);
3767 f.Printf("CUSTOM%d_%s =", v-1, variableName);
3768 f.Puts(&v ? &v : "");
3776 void MatchProjectAndConfigPlatformOptions(ProjectConfig config, Platform platform,
3777 PlatformOptions * projectPlatformOptions, PlatformOptions * configPlatformOptions)
3779 *projectPlatformOptions = null;
3780 *configPlatformOptions = null;
3785 if(!strcmpi(p.name, platform))
3787 *projectPlatformOptions = p;
3792 if(config && config.platforms)
3794 for(p : config.platforms)
3796 if(!strcmpi(p.name, platform))
3798 *configPlatformOptions = p;
3806 static inline void ProjectLoadLastBuildNamesInfo(Project prj, ProjectConfig cfg)
3808 const char * cfgName = cfg ? cfg.name : "";
3809 Map<String, NameCollisionInfo> cfgNameCollisions = prj.configsNameCollisions[cfgName];
3810 if(cfgNameCollisions)
3812 cfgNameCollisions.Free();
3813 delete cfgNameCollisions;
3815 prj.configsNameCollisions[cfgName] = cfgNameCollisions = { };
3816 prj.topNode.GenMakefileGetNameCollisionInfo(cfgNameCollisions, cfg);
3819 Project LegacyBinaryLoadProject(File f, const char * filePath)
3821 Project project = null;
3822 char signature[sizeof(epjSignature)];
3824 f.Read(signature, sizeof(signature), 1);
3825 if(!strncmp(signature, (char *)epjSignature, sizeof(epjSignature)))
3827 char topNodePath[MAX_LOCATION];
3828 /*ProjectConfig newConfig
3830 name = CopyString("Default");
3831 makingModified = true;
3832 compilingModified = true;
3833 linkingModified = true;
3837 project = Project { options = { } };
3838 LegacyBinaryLoadNode(project.topNode, f);
3839 delete project.topNode.path;
3840 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3841 MakeSlashPath(topNodePath);
3843 PathCatSlash(topNodePath, filePath);
3844 project.filePath = topNodePath;
3846 /* THIS IS ALREADY DONE BY filePath property
3847 StripLastDirectory(topNodePath, topNodePath);
3848 project.topNode.path = CopyString(topNodePath);
3850 // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
3852 // newConfig.options.defaultNameSpace = "";
3853 /*newConfig.objDir.dir = "obj";
3854 newConfig.targetDir.dir = "";*/
3856 //project.configurations = { [ newConfig ] };
3857 //project.config = newConfig;
3864 String targetFileName, targetDirectory, objectsDirectory;
3866 // { executable = 0, sharedLibrary = 1, staticLibrary = 2 };
3867 f.Read(&temp, sizeof(int),1);
3870 case 0: project.options.targetType = executable; break;
3871 case 1: project.options.targetType = sharedLibrary; break;
3872 case 2: project.options.targetType = staticLibrary; break;
3875 f.Read(&len, sizeof(int),1);
3876 targetFileName = new char[len+1];
3877 f.Read(targetFileName, sizeof(char), len+1);
3878 project.options.targetFileName = targetFileName;
3879 delete targetFileName;
3881 f.Read(&len, sizeof(int),1);
3882 targetDirectory = new char[len+1];
3883 f.Read(targetDirectory, sizeof(char), len+1);
3884 project.options.targetDirectory = targetDirectory;
3885 delete targetDirectory;
3887 f.Read(&len, sizeof(int),1);
3888 objectsDirectory = new byte[len+1];
3889 f.Read(objectsDirectory, sizeof(char), len+1);
3890 project.options.objectsDirectory = objectsDirectory;
3891 delete objectsDirectory;
3893 f.Read(&temp, sizeof(int),1);
3894 project./*config.*/options.debug = temp ? true : false;
3895 f.Read(&temp, sizeof(int),1);
3896 project./*config.*/options.optimization = temp ? speed : none;
3897 f.Read(&temp, sizeof(int),1);
3898 project./*config.*/options.profile = temp ? true : false;
3899 f.Read(&temp, sizeof(int),1);
3900 project.options.warnings = temp ? all : unset;
3902 f.Read(&count, sizeof(int),1);
3905 project.options.includeDirs = { };
3906 for(c = 0; c < count; c++)
3909 f.Read(&len, sizeof(int),1);
3910 name = new char[len+1];
3911 f.Read(name, sizeof(char), len+1);
3912 project.options.includeDirs.Add(name);
3916 f.Read(&count, sizeof(int),1);
3919 project.options.libraryDirs = { };
3920 for(c = 0; c < count; c++)
3923 f.Read(&len, sizeof(int),1);
3924 name = new char[len+1];
3925 f.Read(name, sizeof(char), len+1);
3926 project.options.libraryDirs.Add(name);
3930 f.Read(&count, sizeof(int),1);
3933 project.options.libraries = { };
3934 for(c = 0; c < count; c++)
3937 f.Read(&len, sizeof(int),1);
3938 name = new char[len+1];
3939 f.Read(name, sizeof(char), len+1);
3940 project.options.libraries.Add(name);
3944 f.Read(&count, sizeof(int),1);
3947 project.options.preprocessorDefinitions = { };
3948 for(c = 0; c < count; c++)
3951 f.Read(&len, sizeof(int),1);
3952 name = new char[len+1];
3953 f.Read(name, sizeof(char), len+1);
3954 project.options.preprocessorDefinitions.Add(name);
3958 f.Read(&temp, sizeof(int),1);
3959 project.options.console = temp ? true : false;
3962 for(node : project.topNode.files)
3964 if(node.type == resources)
3966 project.resNode = node;
3976 void ProjectConfig::LegacyProjectConfigLoad(File f)
3984 char subSection[128];
3989 f.GetLine(buffer, 65536 - 1);
3990 TrimLSpaces(buffer, buffer);
3991 TrimRSpaces(buffer, buffer);
3994 if(buffer[0] == '-')
3998 TrimLSpaces(equal, equal);
3999 if(!strcmpi(subSection, "LibraryDirs"))
4001 if(!options.libraryDirs)
4002 options.libraryDirs = { [ CopyString(equal) ] };
4004 options.libraryDirs.Add(CopyString(equal));
4006 else if(!strcmpi(subSection, "IncludeDirs"))
4008 if(!options.includeDirs)
4009 options.includeDirs = { [ CopyString(equal) ] };
4011 options.includeDirs.Add(CopyString(equal));
4014 else if(buffer[0] == '+')
4025 TrimLSpaces(equal, equal);
4026 delete name; name = CopyString(equal); // property::name = equal;
4029 else if(!strcmpi(buffer, "Compiler Options"))
4030 strcpy(section, buffer);
4031 else if(!strcmpi(buffer, "IncludeDirs"))
4032 strcpy(subSection, buffer);
4033 else if(!strcmpi(buffer, "Linker Options"))
4034 strcpy(section, buffer);
4035 else if(!strcmpi(buffer, "LibraryDirs"))
4036 strcpy(subSection, buffer);
4037 else if(!strcmpi(buffer, "Files") || !strcmpi(buffer, "Resources"))
4044 equal = strstr(buffer, "=");
4048 TrimRSpaces(buffer, buffer);
4050 TrimLSpaces(equal, equal);
4051 if(!strcmpi(buffer, "Target Name"))
4052 options.targetFileName = /*CopyString(*/equal/*)*/;
4053 else if(!strcmpi(buffer, "Target Type"))
4055 if(!strcmpi(equal, "Executable"))
4056 options.targetType = executable;
4057 else if(!strcmpi(equal, "Shared"))
4058 options.targetType = sharedLibrary;
4059 else if(!strcmpi(equal, "Static"))
4060 options.targetType = staticLibrary;
4062 options.targetType = executable;
4064 else if(!strcmpi(buffer, "Target Directory"))
4065 options.targetDirectory = /*CopyString(*/equal/*)*/;
4066 else if(!strcmpi(buffer, "Console"))
4067 options.console = ParseTrueFalseValue(equal);
4068 else if(!strcmpi(buffer, "Libraries"))
4070 if(!options.libraries) options.libraries = { };
4071 ParseArrayValue(options.libraries, equal);
4073 else if(!strcmpi(buffer, "Intermediate Directory"))
4074 options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
4075 else if(!strcmpi(buffer, "Debug"))
4076 options.debug = ParseTrueFalseValue(equal);
4077 else if(!strcmpi(buffer, "Optimize"))
4079 if(!strcmpi(equal, "None"))
4080 options.optimization = none;
4081 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
4082 options.optimization = speed;
4083 else if(!strcmpi(equal, "Size"))
4084 options.optimization = size;
4086 options.optimization = none;
4088 else if(!strcmpi(buffer, "Compress"))
4089 options.compress = ParseTrueFalseValue(equal);
4090 else if(!strcmpi(buffer, "Profile"))
4091 options.profile = ParseTrueFalseValue(equal);
4092 else if(!strcmpi(buffer, "AllWarnings"))
4093 options.warnings = ParseTrueFalseValue(equal) ? all : unset;
4094 else if(!strcmpi(buffer, "MemoryGuard"))
4095 options.memoryGuard = ParseTrueFalseValue(equal);
4096 else if(!strcmpi(buffer, "Default Name Space"))
4097 options.defaultNameSpace = CopyString(equal);
4098 else if(!strcmpi(buffer, "Strict Name Spaces"))
4099 options.strictNameSpaces = ParseTrueFalseValue(equal);
4100 else if(!strcmpi(buffer, "Preprocessor Definitions"))
4102 if(!options.preprocessorDefinitions) options.preprocessorDefinitions = { };
4103 ParseArrayValue(options.preprocessorDefinitions, equal);
4109 if(!options.targetDirectory && options.objectsDirectory)
4110 options.targetDirectory = /*CopyString(*/options.objectsDirectory/*)*/;
4111 //if(!objDir.dir) objDir.dir = "obj";
4112 //if(!targetDir.dir) targetDir.dir = "";
4113 // if(!targetName) property::targetName = ""; // How can a targetFileName be nothing???
4114 // if(!defaultNameSpace) property::defaultNameSpace = "";
4115 makingModified = true;
4118 Project LegacyAsciiLoadProject(File f, const char * filePath)
4120 Project project = null;
4122 char parentPath[MAX_LOCATION];
4123 char section[128] = "";
4124 char subSection[128] = "";
4125 ProjectNode parent = null;
4126 bool configurationsPresent = false;
4136 f.GetLine(buffer, 65536 - 1);
4137 TrimLSpaces(buffer, buffer);
4138 TrimRSpaces(buffer, buffer);
4141 if(buffer[0] == '-' || buffer[0] == '=')
4143 bool simple = buffer[0] == '-';
4146 TrimLSpaces(equal, equal);
4147 if(!strcmpi(section, "Target") && !strcmpi(subSection, "LibraryDirs"))
4149 if(!project.config.options.libraryDirs)
4150 project.config.options.libraryDirs = { [ CopyString(equal) ] };
4152 project.config.options.libraryDirs.Add(CopyString(equal));
4154 else if(!strcmpi(section, "Target") && !strcmpi(subSection, "IncludeDirs"))
4156 if(!project.config.options.includeDirs)
4157 project.config.options.includeDirs = { [ CopyString(equal) ] };
4159 project.config.options.includeDirs.Add(CopyString(equal));
4161 else if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
4163 len = strlen(equal);
4166 char temp[MAX_LOCATION];
4167 ProjectNode child { };
4168 // We don't need to do this anymore, fileName is just a property that sets name & path
4169 // child.fileName = CopyString(equal);
4172 child.name = CopyString(equal);
4173 child.path = CopyString(parentPath);
4177 GetLastDirectory(equal, temp);
4178 child.name = CopyString(temp);
4179 StripLastDirectory(equal, temp);
4180 child.path = CopyString(temp);
4182 child.nodeType = file;
4183 child.parent = parent;
4184 child.indent = parent.indent + 1;
4186 child.icon = NodeIcons::SelectFileIcon(child.name);
4187 parent.files.Add(child);
4193 StripLastDirectory(parentPath, parentPath);
4194 parent = parent.parent;
4198 else if(buffer[0] == '+')
4202 TrimLSpaces(equal, equal);
4203 if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
4205 char temp[MAX_LOCATION];
4206 ProjectNode child { };
4207 // NEW: Folders now have a path set like files
4208 child.name = CopyString(equal);
4209 strcpy(temp, parentPath);
4210 PathCatSlash(temp, child.name);
4211 child.path = CopyString(temp);
4213 child.parent = parent;
4214 child.indent = parent.indent + 1;
4215 child.type = folder;
4216 child.nodeType = folder;
4218 child.icon = folder;
4219 PathCatSlash(parentPath, child.name);
4220 parent.files.Add(child);
4225 else if(!strcmpi(section, "Configurations"))
4227 ProjectConfig newConfig
4229 makingModified = true;
4233 LegacyProjectConfigLoad(newConfig, f);
4234 project.configurations.Add(newConfig);
4237 else if(!strcmpi(buffer, "ECERE Project File"));
4238 else if(!strcmpi(buffer, "Version 0a"))
4239 ; //strcpy(version, "0a");
4240 else if(!strcmpi(buffer, "Version 0.1a"))
4241 ; //strcpy(version, "0.1a");
4242 else if(!strcmpi(buffer, "Configurations"))
4244 project.configurations.Free();
4245 project.config = null;
4246 strcpy(section, buffer);
4247 configurationsPresent = true;
4249 else if(!strcmpi(buffer, "Target") || !strnicmp(buffer, "Target \"", strlen("Target \"")))
4251 ProjectConfig newConfig { name = CopyString("Default"), options = { } };
4252 char topNodePath[MAX_LOCATION];
4253 // newConfig.defaultNameSpace = "";
4254 //newConfig.objDir.dir = "obj";
4255 //newConfig.targetDir.dir = "";
4256 project = Project { /*options = { }*/ };
4257 project.configurations = { [ newConfig ] };
4258 project.config = newConfig;
4259 // if(project.topNode.path) delete project.topNode.path;
4260 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
4261 MakeSlashPath(topNodePath);
4262 PathCatSlash(topNodePath, filePath);
4263 project.filePath = topNodePath;
4264 parentPath[0] = '\0';
4265 parent = project.topNode;
4267 strcpy(section, "Target");
4272 if(equal[0] == '\"')
4274 StripQuotes(equal, equal);
4275 delete project.moduleName; project.moduleName = CopyString(equal);
4279 else if(!strcmpi(buffer, "Compiler Options"));
4280 else if(!strcmpi(buffer, "IncludeDirs"))
4281 strcpy(subSection, buffer);
4282 else if(!strcmpi(buffer, "Linker Options"));
4283 else if(!strcmpi(buffer, "LibraryDirs"))
4284 strcpy(subSection, buffer);
4285 else if(!strcmpi(buffer, "Files"))
4287 strcpy(section, "Target");
4288 strcpy(subSection, buffer);
4290 else if(!strcmpi(buffer, "Resources"))
4292 ProjectNode child { };
4293 parent.files.Add(child);
4294 child.parent = parent;
4295 child.indent = parent.indent + 1;
4296 child.name = CopyString(buffer);
4297 child.path = CopyString("");
4298 child.type = resources;
4300 child.icon = archiveFile;
4301 project.resNode = child;
4304 strcpy(subSection, buffer);
4308 equal = strstr(buffer, "=");
4312 TrimRSpaces(buffer, buffer);
4314 TrimLSpaces(equal, equal);
4316 if(!strcmpi(section, "Target"))
4318 if(!strcmpi(buffer, "Build Exclusions"))
4320 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
4322 /*if(node && node.type != NodeTypes::project)
4323 ParseListValue(node.buildExclusions, equal);*/
4326 else if(!strcmpi(buffer, "Path") && !strcmpi(subSection, "Resources"))
4328 delete project.resNode.path;
4329 project.resNode.path = CopyString(equal);
4330 PathCatSlash(parentPath, equal);
4334 else if(!strcmpi(buffer, "Intermediate Directory"))
4335 project.config.options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
4336 else if(!strcmpi(buffer, "Debug"))
4337 project.config.options.debug = ParseTrueFalseValue(equal);
4338 else if(!strcmpi(buffer, "Optimize"))
4340 if(!strcmpi(equal, "None"))
4341 project.config.options.optimization = none;
4342 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
4343 project.config.options.optimization = speed;
4344 else if(!strcmpi(equal, "Size"))
4345 project.config.options.optimization = size;
4347 project.config.options.optimization = none;
4349 else if(!strcmpi(buffer, "Profile"))
4350 project.config.options.profile = ParseTrueFalseValue(equal);
4351 else if(!strcmpi(buffer, "MemoryGuard"))
4352 project.config.options.memoryGuard = ParseTrueFalseValue(equal);
4355 if(!project.options) project.options = { };
4357 // Project Wide Settings (All configs)
4358 if(!strcmpi(buffer, "Target Name"))
4359 project.options.targetFileName = /*CopyString(*/equal/*)*/;
4360 else if(!strcmpi(buffer, "Target Type"))
4362 if(!strcmpi(equal, "Executable"))
4363 project.options.targetType = executable;
4364 else if(!strcmpi(equal, "Shared"))
4365 project.options.targetType = sharedLibrary;
4366 else if(!strcmpi(equal, "Static"))
4367 project.options.targetType = staticLibrary;
4369 project.options.targetType = executable;
4371 else if(!strcmpi(buffer, "Target Directory"))
4372 project.options.targetDirectory = /*CopyString(*/equal/*)*/;
4373 else if(!strcmpi(buffer, "Console"))
4374 project.options.console = ParseTrueFalseValue(equal);
4375 else if(!strcmpi(buffer, "Libraries"))
4377 if(!project.options.libraries) project.options.libraries = { };
4378 ParseArrayValue(project.options.libraries, equal);
4380 else if(!strcmpi(buffer, "AllWarnings"))
4381 project.options.warnings = ParseTrueFalseValue(equal) ? all : unset;
4382 else if(!strcmpi(buffer, "Preprocessor Definitions"))
4384 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
4386 /*if(node && (node.type == NodeTypes::project || (node.type == file && !node.isInResources) || node.type == folder))
4387 ParseListValue(node.preprocessorDefs, equal);*/
4391 if(!project.options.preprocessorDefinitions) project.options.preprocessorDefinitions = { };
4392 ParseArrayValue(project.options.preprocessorDefinitions, equal);
4403 SplitPlatformLibraries(project);
4405 if(configurationsPresent)
4406 CombineIdenticalConfigOptions(project);
4410 void SplitPlatformLibraries(Project project)
4412 if(project && project.configurations)
4414 for(cfg : project.configurations)
4416 if(cfg.options.libraries && cfg.options.libraries.count)
4418 Iterator<String> it { cfg.options.libraries };
4422 char * platformName = strstr(l, ":");
4425 PlatformOptions platform = null;
4427 if(!cfg.platforms) cfg.platforms = { };
4428 for(p : cfg.platforms)
4430 if(!strcmpi(platformName, p.name))
4438 platform = { name = CopyString(platformName), options = { libraries = { } } };
4439 cfg.platforms.Add(platform);
4441 *(platformName-1) = 0;
4442 platform.options.libraries.Add(CopyString(l));
4444 cfg.options.libraries.Delete(it.pointer);
4453 void CombineIdenticalConfigOptions(Project project)
4455 if(project && project.configurations && project.configurations.count)
4458 ProjectOptions nullOptions { };
4459 ProjectConfig firstConfig = null;
4460 for(cfg : project.configurations)
4462 if(cfg.options.targetType != staticLibrary)
4469 firstConfig = project.configurations.firstIterator.data;
4471 for(member = class(ProjectOptions).membersAndProperties.first; member; member = member.next)
4473 if(!member.isProperty)
4475 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
4480 for(cfg : project.configurations)
4482 if(cfg != firstConfig)
4484 if(cfg.options.targetType != staticLibrary)
4488 if(type.type == noHeadClass || type.type == normalClass)
4490 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4491 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4492 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4496 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4497 (byte *)firstConfig.options + member.offset + member._class.offset,
4498 (byte *)cfg.options + member.offset + member._class.offset);
4510 if(type.type == noHeadClass || type.type == normalClass)
4512 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4513 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4514 *(void **)((byte *)nullOptions + member.offset + member._class.offset)))
4519 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4520 (byte *)firstConfig.options + member.offset + member._class.offset,
4521 (byte *)nullOptions + member.offset + member._class.offset))
4525 if(!project.options) project.options = { };
4527 /*if(type.type == noHeadClass || type.type == normalClass)
4529 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4530 (byte *)project.options + member.offset + member._class.offset,
4531 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
4535 void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
4536 // TOFIX: ListBox::SetData / OnCopy mess
4537 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4538 (byte *)project.options + member.offset + member._class.offset,
4539 (type.typeSize > 4) ? address :
4540 ((type.typeSize == 4) ? (void *)*(uint32 *)address :
4541 ((type.typeSize == 2) ? (void *)*(uint16*)address :
4542 (void *)*(byte *)address )));
4545 (byte *)project.options + member.offset + member._class.offset,
4546 (byte *)firstConfig.options + member.offset + member._class.offset, type.typeSize);
4548 for(cfg : project.configurations)
4550 if(cfg.options.targetType == staticLibrary)
4554 if(type.type == noHeadClass || type.type == normalClass)
4556 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4557 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4558 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4562 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4563 (byte *)firstConfig.options + member.offset + member._class.offset,
4564 (byte *)cfg.options + member.offset + member._class.offset);
4569 if(cfg != firstConfig)
4571 if(type.type == noHeadClass || type.type == normalClass)
4573 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4574 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4578 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4579 (byte *)cfg.options + member.offset + member._class.offset);
4581 memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
4584 memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
4591 // Compare Platform Specific Settings
4594 for(cfg : project.configurations)
4596 if(cfg != firstConfig && cfg.options.targetType != staticLibrary && (firstConfig.platforms || cfg.platforms) &&
4597 ((!firstConfig.platforms && cfg.platforms) || firstConfig.platforms.OnCompare(cfg.platforms)))
4603 if(same && firstConfig.platforms)
4605 for(cfg : project.configurations)
4607 if(cfg.options.targetType == staticLibrary && firstConfig.platforms.OnCompare(cfg.platforms))
4609 if(cfg != firstConfig)
4611 cfg.platforms = null;
4614 project.platforms = firstConfig.platforms;
4615 *&firstConfig.platforms = null;
4619 // Static libraries can't contain libraries
4620 for(cfg : project.configurations)
4622 if(cfg.options.targetType == staticLibrary)
4624 if(!cfg.options.libraries) cfg.options.libraries = { };
4625 cfg.options.libraries.Free();
4631 Project LoadProject(const char * filePath, const char * activeConfigName)
4633 Project project = null;
4634 File f = FileOpen(filePath, read);
4637 project = LegacyBinaryLoadProject(f, filePath);
4640 ECONParser parser { f = f };
4641 /*JSONResult result = */parser.GetObject(class(Project), &project);
4644 char insidePath[MAX_LOCATION];
4646 delete project.topNode.files;
4647 if(!project.files) project.files = { };
4648 project.topNode.files = project.files;
4651 char topNodePath[MAX_LOCATION];
4652 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
4653 MakeSlashPath(topNodePath);
4654 PathCatSlash(topNodePath, filePath);
4655 project.filePath = topNodePath;//filePath;
4658 project.topNode.FixupNode(insidePath);
4660 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4661 delete project.resNode.path;
4662 project.resNode.path = project.resourcesPath;
4663 project.resourcesPath = null;
4664 project.resNode.nodeType = (ProjectNodeType)-1;
4665 delete project.resNode.files;
4666 project.resNode.files = project.resources;
4667 project.files = null;
4668 project.resources = null;
4669 if(!project.configurations) project.configurations = { };
4671 project.resNode.FixupNode(insidePath);
4676 project = LegacyAsciiLoadProject(f, filePath);
4682 if(!project.options) project.options = { };
4683 if(activeConfigName && activeConfigName[0] && project.configurations)
4684 project.config = project.GetConfig(activeConfigName);
4685 if(!project.config && project.configurations)
4686 project.config = project.configurations.firstIterator.data;
4688 if(!project.resNode)
4690 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4693 if(!project.moduleName)
4694 project.moduleName = CopyString(project.name);
4695 if(project.config &&
4696 (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
4697 (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
4699 //delete project.config.options.targetFileName;
4701 project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
4702 project.config.options.optimization = none;
4703 project.config.options.debug = true;
4704 //project.config.options.warnings = unset;
4705 project.config.options.memoryGuard = false;
4706 project.config.compilingModified = true;
4707 project.config.linkingModified = true;
4709 else if(!project.topNode.name && project.config)
4711 project.topNode.name = CopyString(project.config.options.targetFileName);
4714 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
4715 project.topNode.configurations = project.configurations;
4716 project.topNode.platforms = project.platforms;
4717 project.topNode.options = project.options;*/
4723 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
4724 static GccVersionInfo GetGccVersionInfo(CompilerConfig compiler, const String compilerCommand)
4726 GccVersionInfo result = unknown;
4727 if(compiler.ccCommand)
4729 char command[MAX_F_STRING*4];
4731 sprintf(command, "%s%s --version", compiler.gccPrefix ? compiler.gccPrefix : "", compilerCommand);
4732 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
4734 bool firstLine = true;
4739 if(f.GetLine(line,sizeof(line)))
4743 uint count = Tokenize(line, sizeof(tokens)/sizeof(tokens[0]), tokens,false);
4744 char * token = null;
4747 for(i = 0; i < count; i++)
4749 if(tokens[i][0] == '(')
4751 if(tokens[i][strlen(tokens[i])-1] != ')')
4754 else if(tokens[i][0] && tokens[i][strlen(tokens[i])-1] == ')')
4756 else if(!inPar && isdigit(tokens[i][0]) && strchr(tokens[i], '.'))
4760 result = GccVersionInfo::GetVersionInfo(token);
4771 static enum GccVersionInfo
4773 unknown, pre4_8, post4_8;
4775 GccVersionInfo ::GetVersionInfo(char * version)
4777 GccVersionInfo result = unknown;
4779 char * s = CopyString(version);
4781 uint count = TokenizeWith(s, sizeof(tokens)/sizeof(tokens[0]), tokens, ".", false);
4782 ver = count > 1 ? atoi(tokens[1]) : 0;
4783 ver += count ? atoi(tokens[0]) * 1000 : 0;