2 public import static "ecere"
9 #if defined(ECERE_EPJ2MAKE)
13 // We should have the .sln/.vcproj generation even on other platforms
14 // e.g. detect from an environment variable pointing to a Windows drive
20 import "ProjectConfig"
26 static __attribute__((unused)) void DummyFunction()
34 extern int __ecereVMethodID_class_OnCompare;
35 extern int __ecereVMethodID_class_OnFree;
37 #if defined(ECERE_DOCUMENTOR) || defined(ECERE_EPJ2MAKE)
38 CompilerConfig defaultCompiler;
41 // LEGACY BINARY EPJ LOADING
43 SetBool ParseTrueFalseValue(char * string)
45 if(!strcmpi(string, "True")) return true;
49 void ParseArrayValue(Array<String> array, char * equal)
51 char * start, * comma;
53 string = CopyString(equal);
57 comma = strstr(start, ",");
60 array.Add(CopyString(start));
70 void ProjectNode::LegacyBinaryLoadNode(File f)
75 f.Read(&len, sizeof(len), 1);
76 name = new char[len+1];
78 f.Read(name, sizeof(char), len+1);
79 f.Read(&len, sizeof(len), 1);
81 path = new char[len+1];
82 f.Read(path, sizeof(char), len+1);
85 fileName = new char[fileNameLen+2];
86 strcpy(fileName, path);
87 if(fileName[0]) strcat(fileName, "/");
88 strcat(fileName, name);
91 f.Read(&type, sizeof(type), 1);
92 f.Read(&count, sizeof(count), 1);
97 icon = NodeIcons::SelectFileIcon(name);
102 icon = NodeIcons::SelectNodeIcon(type);
105 if(count && !files) files = { };
106 for(c = 0; c < count; c++)
108 ProjectNode child { };
111 child.indent = indent + 1;
112 LegacyBinaryLoadNode(child, f);
116 /*void LegacyBinarySaveNode(File f)
121 f.Write(&len, sizeof(len), 1);
122 f.Write(name, sizeof(char), len+1);
126 // Projects Absolute Path Are Not Saved
128 f.Write(&len, sizeof(len), 1);
129 f.Write(&len, sizeof(char), 1);
134 f.Write(&len, sizeof(len), 1);
135 f.Write(path, sizeof(char), len+1);
137 f.Write(&type, sizeof(type), 1);
138 f.Write(&children.count, sizeof(children.count), 1);
139 for(child = children.first; child; child.next)
143 void ProjectNode::LegacyAsciiSaveNode(File f, char * indentation, char * insidePath)
146 char printPath[MAX_LOCATION];
148 if(type == project && (files.count /*|| preprocessorDefs.first*/))
150 f.Printf("\n Files\n");
152 else if(type == file)
154 if(!strcmp(path, insidePath))
155 f.Printf("%s - %s\n", indentation, name);
158 strcpy(printPath, path);
159 len = strlen(printPath);
161 if(printPath[len-1] != '/')
162 strcat(printPath, "/");
163 strcat(printPath, name);
164 f.Printf("%s = %s\n", indentation, printPath);
167 f.Printf("\nError\n\n");
169 else if(type == folder)
171 f.Printf("%s + %s\n", indentation, name);
173 else if(type == resources && files.count)
175 PathCatSlash(insidePath, path);
176 f.Printf("\n%sResources\n", indentation);
178 f.Printf("%s Path = %s\n", indentation, path);
181 /*if(buildExclusions.first && type != project)
183 for(item = buildExclusions.first; item; item = item.next)
185 if(item == buildExclusions.first)
186 f.Printf("%s Build Exclusions = %s", indentation, item.name);
188 f.Printf(", %s", item.name);
193 if(preprocessorDefs.first && (type == project || ((type == file || type == folder) && !isInResources)))
195 for(item = preprocessorDefs.first; item; item = item.next)
197 if(item == preprocessorDefs.first)
198 f.Printf("%s%s Preprocessor Definitions = %s", indentation, type == project ? "" : " ", item.name);
200 f.Printf(", %s", item.name);
206 if(type == project && (files.count /*|| preprocessorDefs.first*/))
210 LegacyAsciiSaveNode(child, f, indentation, insidePath);
212 else if(type == folder)
214 strcat(indentation, " ");
215 // WHAT WAS THIS: strcpy(printPath, path);
216 // TOCHECK: why is Unix/PathCat not used here
217 len = strlen(insidePath);
219 if(insidePath[len-1] != '/')
220 strcat(insidePath, "/");
221 strcat(insidePath, name);
224 LegacyAsciiSaveNode(child, f, indentation, insidePath);
225 f.Printf("%s -\n", indentation);
226 indentation[strlen(indentation) - 3] = '\0';
227 StripLastDirectory(insidePath, insidePath);
229 else if(type == resources && files.count)
233 LegacyAsciiSaveNode(child, f, indentation, insidePath);
234 StripLastDirectory(insidePath, insidePath);
239 void ProjectConfig::LegacyProjectConfigSave(File f)
241 char * indentation = " ";
243 //f.Printf("\n * Common\n");
245 f.Printf("\n + %s\n", name);
246 f.Printf("\n Compiler\n\n");
247 if(objDir.expression[0])
248 f.Printf("%sIntermediate Directory = %s\n", indentation, objDir.expression);
249 f.Printf("%sDebug = %s\n", indentation, (options.debug == true) ? "True" : "False");
250 switch(options.optimization)
252 // case none: f.Printf("%sOptimize = %s\n", indentation, "None"); break;
253 case speed: f.Printf("%sOptimize = %s\n", indentation, "Speed"); break;
254 case size: f.Printf("%sOptimize = %s\n", indentation, "Size"); break;
256 f.Printf("%sAllWarnings = %s\n", indentation, (options.warnings == all) ? "True" : "False");
258 f.Printf("%sProfile = %s\n", indentation, (options.profile == true) ? "True" : "False");
259 if(options.memoryGuard == true)
260 f.Printf("%sMemoryGuard = %s\n", indentation, (options.memoryGuard == true) ? "True" : "False");
261 if(options.strictNameSpaces == true)
262 f.Printf("%sStrict Name Spaces = %s\n", indentation, (options.strictNameSpaces == true) ? "True" : "False");
263 if(options.defaultNameSpace && strlen(options.defaultNameSpace))
264 f.Printf("%sDefault Name Space = %s\n", indentation, options.defaultNameSpace);
265 TOFIX: Compiler Bug {
266 if(options.preprocessorDefinitions.count)
269 for(item : options.preprocessorDefinitions)
273 f.Printf("\n%sPreprocessor Definitions = %s", indentation, item);
277 f.Printf(", %s", item);
282 if(options.includeDirs.count)
284 f.Printf("\n%sInclude Directories\n", indentation);
285 for(item : options.includeDirs)
286 f.Printf("%s - %s\n", indentation, name);
290 f.Printf("\n%sLinker\n\n", indentation);
291 f.Printf("%sTarget Name = %s\n", indentation, options.targetFileName);
292 switch(options.targetType)
294 case executable: f.Printf("%sTarget Type = %s\n", indentation, "Executable"); break;
295 case sharedLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Shared"); break;
296 case staticLibrary: f.Printf("%sTarget Type = %s\n", indentation, "Static"); break;
298 if(targetDir.expression[0])
299 f.Printf("%sTarget Directory = %s\n", indentation, targetDir.expression);
301 f.Printf("%sConsole = %s\n", indentation, options.console ? "True" : "False");
303 f.Printf("%sCompress = %s\n", indentation, options.compress ? "True" : "False");
304 if(options.libraries.count)
307 for(item : options.libraries)
311 f.Printf("\n%sLibraries = %s", indentation, name);
315 f.Printf(", %s", item);
319 if(options.libraryDirs.count)
321 f.Printf("\n%sLibrary Directories\n\n", indentation);
322 for(item : options.libraryDirs)
323 f.Printf(" - %s\n", indentation, item);
327 void LegacyAsciiSaveProject(File f, Project project)
329 char indentation[128*3];
330 char path[MAX_LOCATION];
332 f.Printf("\nECERE Project File : Format Version 0.1b\n");
333 f.Printf("\nDescription\n%s\n.\n", project.description);
334 f.Printf("\nLicense\n%s\n.\n", project.license);
335 f.Printf("\nModule Name = %s\n", project.moduleName);
336 f.Printf("\n Configurations\n");
337 //////////////////////////////////////commonConfig.Save(f, true);
338 for(cfg : project.configurations)
339 LegacyProjectConfigSave(cfg, f);
341 strcpy(indentation, " ");
343 LegacyAsciiSaveNode(project.topNode, f, indentation, path);
349 // *** NEW JSON PROJECT FORMAT ***
350 public enum ProjectNodeType { file, folder };
352 // *******************************
354 define PEEK_RESOLUTION = (18.2 * 10);
360 static Array<const String> notLinkerOptions
382 static bool IsLinkerOption(String s)
384 for(i : notLinkerOptions)
385 if(strstr(s, "-Wl,") || !strcmp(s, i))
390 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
392 enum GenMakefilePrintTypes { noPrint, objects, cObjects, symbols, imports, sources, resources, eCsources, rcSources };
394 define WorkspaceExtension = "ews";
395 define ProjectExtension = "epj";
397 define stringInFileIncludedFrom = "In file included from ";
398 define stringFrom = " from ";
400 // chars refused for project name: windowsFileNameCharsNotAllowed + " &,."
402 //define gnuMakeCharsNeedEscaping = "$%";
404 //define windowsFileNameCharsNotAllowed = "*/:<>?\\\"|";
405 //define linuxFileNameCharsNotAllowed = "/";
407 //define windowsFileNameCharsNeedEscaping = " !%&'()+,;=[]^`{}~"; // "#$-.@_" are ok
408 //define linuxFileNameCharsNeedEscaping = " !\"$&'()*:;<=>?[\\`{|"; // "#%+,-.@]^_}~" are ok
410 // NOTES: - this function should get only unescaped unix style paths
411 // - paths with literal $(somestring) in them are not supported
412 // my_$(messed_up)_path would likely become my__path
413 void EscapeForMake(char * output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
415 char ch, *o = output;
416 const char *i = input;
419 int len = strlen(input);
420 if(len && ((input[0] == '"' && input[len-1] == '"') || strchr(input, '\\') || strchr(input, 127) || (!allowDblQuote && strchr(input, '"'))))
421 PrintLn("Invalid input for EscapeForMake! -- ", input);
427 if(i-1 != input && *(i-2) == '$' && allowVars)
434 if(inVar == true && allowVars)
439 else if(ch == '$' && *i != '(')
461 void EscapeForMakeToFile(File output, char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
463 char * buf = new char[strlen(input)*2+1];
464 EscapeForMake(buf, input, hideSpace, allowVars, allowDblQuote);
469 void EscapeForMakeToDynString(DynamicString output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
471 char * buf = new char[strlen(input)*2+1];
472 EscapeForMake(buf, input, hideSpace, allowVars, allowDblQuote);
477 int OutputFileList(File f, const char * name, Array<String> list, Map<String, int> varStringLenDiffs, const char * prefix)
480 const int breakListLength = 1536;
481 const int breakLineLength = 78; // TODO: turn this into an option.
483 int c, len, itemCount = 0;
484 Array<int> breaks { };
488 MapNode<String, int> mn;
489 for(c=0; c<list.count; c++)
491 len = strlen(list[c]) + 3;
492 if(strstr(list[c], "$(") && varStringLenDiffs && varStringLenDiffs.count)
494 for(mn = varStringLenDiffs.root.minimum; mn; mn = mn.next)
496 if(strstr(list[c], mn.key))
500 if(charCount + len > breakListLength)
502 breaks.Add(itemCount);
510 breaks.Add(itemCount);
511 numOfBreaks = breaks.count;
516 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
517 for(c=0; c<numOfBreaks; c++)
518 f.Printf(" $(%s%d)", name, c+1);
522 f.Printf("%s =%s%s", name, prefix ? " " : "", prefix ? prefix : "");
528 for(c=0; c<numOfBreaks; c++)
531 f.Printf("%s%d =", name, c+1);
534 itemCount = breaks[c];
535 for(n=offset; n<offset+itemCount; n++)
537 if(false) // TODO: turn this into an option.
539 int itemLen = strlen(list[n]);
540 if(len > 3 && len + itemLen > breakLineLength)
542 f.Printf(" \\\n\t%s", list[n]);
548 f.Printf(" %s", list[n]);
552 f.Printf(" \\\n\t%s", list[n]);
567 void OutputFileListActions(File f, const char * name, int parts, const char * fileName)
572 for(c=0; c<parts; c++)
573 f.Printf("\t$(call addtolistfile,$(%s%d),%s)\n", name, c+1, fileName);
577 f.Printf("\t$(call addtolistfile,$(%s),%s)\n", name, fileName);
581 void OutputCleanActions(File f, const char * name, int parts)
586 for(c=0; c<parts; c++)
587 f.Printf("\t$(call rm,$(_%s%d))\n", name, c+1);
590 f.Printf("\t$(call rm,$(_%s))\n", name);
593 enum LineOutputMethod { inPlace, newLine, lineEach };
594 enum StringOutputMethod { asIs, escape, escapePath};
596 enum ToolchainFlag { any, _D, _I, _isystem, _Wl, _L/*, _Wl-rpath*/ };
597 const String flagNames[ToolchainFlag] = { "", "-D", "-I", "-isystem ", "-Wl,", /*"-Wl,--library-path="*/"-L"/*, "-Wl,-rpath "*/ };
598 void OutputFlags(File f, ToolchainFlag flag, Array<String> list, LineOutputMethod lineMethod)
602 if(lineMethod == newLine)
606 if(lineMethod == lineEach)
608 f.Printf(" %s", flagNames[flag]);
609 if(flag != _D && flag != _Wl && flag != any)
611 char * tmp = new char[strlen(item)*2+1];
612 EscapeForMake(tmp, item, false, true, false);
613 f.Printf("$(call quote_path,%s)", tmp);
617 EscapeForMakeToFile(f, item, false, true, true);
622 static void OutputLibraries(File f, Array<String> libraries)
624 for(item : libraries)
626 char ext[MAX_EXTENSION];
627 char temp[MAX_LOCATION];
629 bool usedFunction = false;
630 GetExtension(item, ext);
631 if(!strcmp(ext, "o") || !strcmp(ext, "a"))
635 if(!strcmp(ext, "so") || !strcmp(ext, "dylib"))
637 if(!strncmp(item, "lib", 3))
638 strcpy(temp, item + 3);
641 StripExtension(temp);
644 f.Puts(" \\\n\t$(call _L,");
647 EscapeForMakeToFile(f, s, false, false, false);
653 void CamelCase(char * string)
657 int c, len = strlen(string);
658 for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
659 string[c] = (char)tolower(string[c]);
663 CompilerConfig GetCompilerConfig()
665 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
666 CompilerConfig compiler = null;
667 if(ide && ide.workspace)
668 compiler = ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler);
671 incref defaultCompiler;
672 return defaultCompiler;
678 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
679 return ide.workspace ? ide.workspace.bitDepth : 0;
681 return 0; // todo: improve this somehow? add bit depth command line option?
685 define localTargetType = config && config.options && config.options.targetType ?
686 config.options.targetType : options && options.targetType ?
687 options.targetType : TargetTypes::executable;
688 define localWarnings = config && config.options && config.options.warnings ?
689 config.options.warnings : options && options.warnings ?
690 options.warnings : WarningsOption::unset;
691 define localDebug = config && config.options && config.options.debug ?
692 config.options.debug : options && options.debug ?
693 options.debug : SetBool::unset;
694 define localMemoryGuard = config && config.options && config.options.memoryGuard ?
695 config.options.memoryGuard : options && options.memoryGuard ?
696 options.memoryGuard : SetBool::unset;
697 define localNoLineNumbers = config && config.options && config.options.noLineNumbers ?
698 config.options.noLineNumbers : options && options.noLineNumbers ?
699 options.noLineNumbers : SetBool::unset;
700 define localProfile = config && config.options && config.options.profile ?
701 config.options.profile : options && options.profile ?
702 options.profile : SetBool::unset;
703 define localOptimization = config && config.options && config.options.optimization ?
704 config.options.optimization : options && options.optimization ?
705 options.optimization : OptimizationStrategy::none;
706 define localFastMath = config && config.options && config.options.fastMath ?
707 config.options.fastMath : options && options.fastMath ?
708 options.fastMath : SetBool::unset;
709 define localDefaultNameSpace = config && config.options && config.options.defaultNameSpace ?
710 config.options.defaultNameSpace : options && options.defaultNameSpace ?
711 options.defaultNameSpace : null;
712 define localStrictNameSpaces = config && config.options && config.options.strictNameSpaces ?
713 config.options.strictNameSpaces : options && options.strictNameSpaces ?
714 options.strictNameSpaces : SetBool::unset;
715 // TODO: I would rather have null here, check if it'll be ok, have the property return "" if required
716 define localTargetFileName = config && config.options && config.options.targetFileName ?
717 config.options.targetFileName : options && options.targetFileName ?
718 options.targetFileName : "";
719 define localTargetDirectory = config && config.options && config.options.targetDirectory && config.options.targetDirectory[0] ?
720 config.options.targetDirectory : options && options.targetDirectory && options.targetDirectory[0] ?
721 options.targetDirectory : null;
722 define settingsTargetDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
723 ideSettings.projectDefaultIntermediateObjDir[0] ?
724 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
725 define localObjectsDirectory = config && config.options && config.options.objectsDirectory && config.options.objectsDirectory[0] ?
726 config.options.objectsDirectory : options && options.objectsDirectory && options.objectsDirectory[0] ?
727 options.objectsDirectory : null;
728 define settingsObjectsDirectory = ideSettings && ideSettings.projectDefaultIntermediateObjDir &&
729 ideSettings.projectDefaultIntermediateObjDir[0] ?
730 ideSettings.projectDefaultIntermediateObjDir : defaultObjDirExpression;
731 define localConsole = config && config.options && config.options.console ?
732 config.options.console : options && options.console ?
733 options.console : SetBool::unset;
734 define localCompress = config && config.options && config.options.compress ?
735 config.options.compress : options && options.compress ?
736 options.compress : SetBool::unset;
738 define platformTargetType =
739 configPOs && configPOs.options && configPOs.options.targetType && configPOs.options.targetType != localTargetType ?
740 configPOs.options.targetType :
741 projectPOs && projectPOs.options && projectPOs.options.targetType && projectPOs.options.targetType != localTargetType ?
742 projectPOs.options.targetType : TargetTypes::unset;
745 const char * PlatformToMakefileTargetVariable(Platform platform)
747 return platform == win32 ? "WINDOWS_TARGET" :
748 platform == tux ? "LINUX_TARGET" :
749 platform == apple ? "OSX_TARGET" :
753 const char * TargetTypeToMakefileVariable(TargetTypes targetType)
755 return targetType == executable ? "executable" :
756 targetType == sharedLibrary ? "sharedlib" :
757 targetType == staticLibrary ? "staticlib" :
761 // Move this to ProjectConfig? null vs Common to consider...
762 const char * GetConfigName(ProjectConfig config)
764 return config ? config.name : "Common";
767 public enum SingleFileCompileMode
769 normal, debugPrecompile, debugCompile, debugGenerateSymbols, cObject;
771 property bool eC_ToolsDebug { get { return this == debugCompile || this == debugGenerateSymbols || this == debugPrecompile; } }
774 class Project : struct
776 class_no_expansion; // To use Find on the Container<Project> in Workspace::projects
777 // We might want to tweak this default behavior of regular classes ?
778 // Expansion/the current default kind of Find matching we want for things like BitmapResource, FontResource (Also regular classes)
783 property const char * moduleVersion
785 set { delete moduleVersion; if(value && value[0]) moduleVersion = CopyString(value); } // TODO: use CopyString function that filters chars
786 get { return moduleVersion ? moduleVersion : ""; } // version number should only use digits and dots
787 isset { return moduleVersion != null && moduleVersion[0]; } // add leading/trailing 0 if value start/ends with dot(s)
790 property const char * description
792 set { delete description; if(value && value[0]) description = CopyString(value); }
793 get { return description ? description : ""; }
794 isset { return description != null && description[0]; }
797 property const char * license
799 set { delete license; if(value && value[0]) license = CopyString(value); }
800 get { return license ? license : ""; }
801 isset { return license != null && license[0]; }
804 property const char * compilerConfigsDir
806 set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
807 get { return compilerConfigsDir ? compilerConfigsDir : ""; }
808 isset { return compilerConfigsDir && compilerConfigsDir[0]; }
811 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
812 property Array<PlatformOptions> platforms
814 get { return platforms; }
817 if(platforms) { platforms.Free(); delete platforms; }
820 List<PlatformOptions> empty { };
821 Iterator<PlatformOptions> it { value };
823 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
824 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
834 if(p.options && !p.options.isEmpty)
841 List<ProjectConfig> configurations;
842 LinkList<ProjectNode> files;
843 String resourcesPath;
844 LinkList<ProjectNode> resources;
847 // topNode.name holds the file name (.epj)
848 ProjectOptions options;
849 Array<PlatformOptions> platforms;
850 ProjectNode topNode { type = project, icon = epjFile, files = LinkList<ProjectNode>{ }, project = this };
853 ProjectConfig config;
855 // This is the file name stripped of the epj extension
856 // It should NOT be edited, saved or loaded anywhere
861 String compilerConfigsDir;
862 String moduleVersion;
864 String lastBuildConfigName;
865 String lastBuildCompilerName;
867 Map<String, Map<String, NameCollisionInfo>> configsNameCollisions { };
869 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
870 FileMonitor fileMonitor
872 this, FileChange { modified = true };
873 bool OnFileNotify(FileChange action, const char * param)
875 fileMonitor.StopMonitoring();
876 if(OnProjectModified(action, param))
877 fileMonitor.StartMonitoring();
882 bool StartMonitoring()
884 fileMonitor.fileName = filePath;
885 fileMonitor.StartMonitoring();
889 bool StopMonitoring()
891 fileMonitor.StopMonitoring();
895 bool OnProjectModified(FileChange fileChange, const char * param)
898 sprintf(temp, $"The project %s was modified by another application.\n"
899 "Would you like to reload it and lose your changes?", name);
900 if(MessageBox { type = yesNo, master = ide,
901 text = $"Project has been modified", contents = temp }.Modal() == yes)
903 Project project = LoadProject(filePath, config ? config.name : null);
906 ProjectView projectView = ide.projectView;
907 DataRow prev = topNode.row ? topNode.row.previous : null;
908 FileMonitor fm = fileMonitor;
909 bool confirmation = true;
913 if(projectView.projectSettingsDialog)
915 confirmation = projectView.projectSettingsDialog.CloseConfirmation(true);
917 projectView.projectSettingsDialog.Destroy(0);
920 projectView.DeleteNode(topNode);
927 topNode.project = this;
931 CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(projectView.workspace.activeCompiler);
932 projectView.AddNode(topNode, null);
933 topNode.row.Move(prev);
935 projectView.ShowOutputBuildLog(true);
936 projectView.DisplayCompiler(compiler, false);
937 projectView.ProjectUpdateMakefileForAllConfigs(this);
940 eSystem_Delete(project);
947 return !ide.destroyed;
952 // This frees contents without freeing the instance
953 // For use from destructor and for file monitor reloading
954 // (To work around JSON loader (LoadProject) always returning a new instance)
957 if(platforms) { platforms.Free(); delete platforms; }
958 if(configurations) { configurations.Free(); delete configurations; }
959 if(files) { files.Free(); delete files; }
960 if(resources) { resources.Free(); delete resources; }
962 delete resourcesPath;
966 delete compilerConfigsDir;
968 delete moduleVersion;
972 delete lastBuildConfigName;
973 delete lastBuildCompilerName;
974 for(map : configsNameCollisions)
976 configsNameCollisions.Free();
981 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
982 topNode.configurations = null;
983 topNode.platforms = null;
984 topNode.options = null;
989 property ProjectConfig config
995 topNode.info = CopyString(GetConfigName(config));
999 property const char * filePath
1005 char string[MAX_LOCATION];
1006 GetLastDirectory(value, string);
1007 delete topNode.name;
1008 topNode.name = CopyString(string);
1009 StripExtension(string);
1011 name = CopyString(string);
1012 StripLastDirectory(value, string);
1013 delete topNode.path;
1014 topNode.path = CopyString(string);
1016 filePath = CopyString(value);
1021 ProjectConfig GetConfig(const char * configName)
1023 ProjectConfig result = null;
1024 if(configName && configName[0] && configurations.count)
1026 for(cfg : configurations; !strcmpi(cfg.name, configName))
1035 ProjectNode FindNodeByObjectFileName(const char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config, const char * objectFileExt)
1038 const char * cfgName;
1040 config = this.config;
1041 cfgName = config ? config.name : "";
1042 if(!configsNameCollisions[cfgName])
1043 ProjectLoadLastBuildNamesInfo(this, config);
1044 result = topNode.FindByObjectFileName(fileName, type, dotMain, configsNameCollisions[cfgName], objectFileExt);
1048 TargetTypes GetTargetType(ProjectConfig config)
1050 TargetTypes targetType = localTargetType;
1054 bool GetTargetTypeIsSetByPlatform(ProjectConfig config)
1057 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
1059 PlatformOptions projectPOs, configPOs;
1060 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
1061 if(platformTargetType)
1067 const char * GetObjDirExpression(ProjectConfig config)
1069 // TODO: Support platform options
1070 const char * expression = localObjectsDirectory;
1072 expression = settingsObjectsDirectory;
1076 DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1078 const char * expression = GetObjDirExpression(config);
1079 DirExpression objDir { type = intermediateObjectsDir };
1080 objDir.Evaluate(expression, this, compiler, config, bitDepth);
1084 const char * GetTargetDirExpression(ProjectConfig config)
1086 // TODO: Support platform options
1087 const char * expression = localTargetDirectory;
1089 expression = settingsTargetDirectory;
1093 DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
1095 const char * expression = GetTargetDirExpression(config);
1096 DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
1097 targetDir.Evaluate(expression, this, compiler, config, bitDepth);
1101 WarningsOption GetWarnings(ProjectConfig config)
1103 WarningsOption warnings = localWarnings;
1107 bool GetDebug(ProjectConfig config)
1109 SetBool debug = localDebug;
1110 return debug == true;
1113 bool GetMemoryGuard(ProjectConfig config)
1115 SetBool memoryGuard = localMemoryGuard;
1116 return memoryGuard == true;
1119 bool GetNoLineNumbers(ProjectConfig config)
1121 SetBool noLineNumbers = localNoLineNumbers;
1122 return noLineNumbers == true;
1125 bool GetProfile(ProjectConfig config)
1127 SetBool profile = localProfile;
1128 return profile == true;
1131 OptimizationStrategy GetOptimization(ProjectConfig config)
1133 OptimizationStrategy optimization = localOptimization;
1134 return optimization;
1137 bool GetFastMath(ProjectConfig config)
1139 SetBool fastMath = localFastMath;
1140 return fastMath == true;
1143 const String GetDefaultNameSpace(ProjectConfig config)
1145 const String defaultNameSpace = localDefaultNameSpace;
1146 return defaultNameSpace;
1149 bool GetStrictNameSpaces(ProjectConfig config)
1151 SetBool strictNameSpaces = localStrictNameSpaces;
1152 return strictNameSpaces == true;
1155 const String GetTargetFileName(ProjectConfig config)
1157 const String targetFileName = localTargetFileName;
1158 return targetFileName;
1161 //String targetDirectory;
1162 //String objectsDirectory;
1163 bool GetConsole(ProjectConfig config)
1165 SetBool console = localConsole;
1166 return console == true;
1169 bool GetCompress(ProjectConfig config)
1171 SetBool compress = localCompress;
1172 return compress == true;
1174 //SetBool excludeFromBuild;
1176 bool GetConfigIsInActiveDebugSession(ProjectConfig config)
1178 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1179 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
1185 bool GetConfigIsInDebugSession(ProjectConfig config)
1187 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1188 return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
1194 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
1196 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1197 ide.SetPath(projectsDirs, compiler, config, bitDepth);
1201 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1202 bool Save(const char * fileName)
1205 f = FileOpen(fileName, write);
1208 files = topNode.files;
1209 resources = resNode.files;
1210 resourcesPath = resNode.path;
1212 files.Remove(resNode);
1215 WriteJSONObject(f, class(Project), this, 0);
1221 resourcesPath = null;
1228 void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
1230 TargetTypes targetType = GetTargetType(config);
1231 const String targetFileName = GetTargetFileName(config);
1232 if(targetType == staticLibrary)
1234 PathCatSlash(string, "lib");
1235 strcat(string, targetFileName);
1237 else if(compiler.targetPlatform != win32 && targetType == sharedLibrary)
1239 PathCatSlash(string, "lib");
1240 strcat(string, targetFileName);
1243 PathCatSlash(string, targetFileName);
1248 if(compiler.executableFileExt)
1250 strcat(string, ".");
1251 strcat(string, compiler.executableFileExt);
1253 else if(compiler.targetPlatform == win32)
1254 strcat(string, ".exe");
1257 if(compiler.sharedLibFileExt)
1259 strcat(string, ".");
1260 strcat(string, compiler.sharedLibFileExt);
1262 else if(compiler.targetPlatform == win32)
1263 strcat(string, ".dll");
1264 else if(compiler.targetPlatform == apple)
1265 strcat(string, ".dylib");
1267 strcat(string, ".so");
1268 if(compiler.targetPlatform == tux && __runtimePlatform == tux && moduleVersion && moduleVersion[0])
1270 strcat(string, ".");
1271 strcat(string, moduleVersion);
1275 if(compiler.staticLibFileExt)
1277 strcat(string, ".");
1278 strcat(string, compiler.staticLibFileExt);
1281 strcat(string, ".a");
1286 bool GetProjectCompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1288 bool result = false;
1289 char temp[MAX_LOCATION];
1290 strcpy(cfDir, topNode.path);
1291 if(compilerConfigsDir && compilerConfigsDir[0])
1293 PathCatSlash(cfDir, compilerConfigsDir);
1298 strcpy(temp, cfDir);
1299 // Using a relative path makes it less likely to run into spaces issues
1300 // Even with escaped spaces, there still seems to be issues including a config file
1301 // in a path containing spaces
1303 MakePathRelative(temp, topNode.path, cfDir);
1306 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1310 strcpy(temp, cfDir);
1311 ReplaceSpaces(cfDir, temp);
1316 bool GetIDECompilerConfigsDir(char * cfDir, bool replaceSpaces, bool makeRelative)
1318 char temp[MAX_LOCATION];
1319 bool result = false;
1320 strcpy(cfDir, topNode.path);
1321 if(ideSettings && ideSettings.compilerConfigsDir && ideSettings.compilerConfigsDir[0])
1323 PathCatSlash(cfDir, ideSettings.compilerConfigsDir);
1328 // Default to <ProjectDir>/.configs if unset
1329 PathCatSlash(cfDir, ".configs");
1334 strcpy(temp, cfDir);
1335 // Using a relative path makes it less likely to run into spaces issues
1336 // Even with escaped spaces, there still seems to be issues including a config file
1337 // in a path containing spaces
1338 if(IsPathInsideOf(cfDir, topNode.path))
1339 MakePathRelative(temp, topNode.path, cfDir);
1341 if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
1345 strcpy(temp, cfDir);
1346 ReplaceSpaces(cfDir, temp);
1351 void CatMakeFileName(char * string, ProjectConfig config)
1353 char projectName[MAX_LOCATION];
1354 strcpy(projectName, name);
1355 sprintf(string, "%s%s%s.Makefile", projectName, config ? "-" : "", config ? config.name : "");
1358 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
1359 ProjectNode GetObjectFileNode(const char * filePath, const char * objectFileExt)
1361 ProjectNode node = null;
1362 char ext[MAX_EXTENSION];
1363 GetExtension(filePath, ext);
1366 IntermediateFileType type = IntermediateFileType::FromExtension(ext);
1369 char fileName[MAX_FILENAME];
1370 GetLastDirectory(filePath, fileName);
1373 DotMain dotMain = DotMain::FromFileName(fileName);
1374 node = FindNodeByObjectFileName(fileName, type, dotMain, null, objectFileExt);
1381 bool GetAbsoluteFromRelativePath(const char * relativePath, char * absolutePath, const char * objectFileExt)
1383 ProjectNode node = topNode.FindWithPath(relativePath, false);
1385 node = GetObjectFileNode(relativePath, objectFileExt);
1388 strcpy(absolutePath, node.project.topNode.path);
1389 PathCat(absolutePath, relativePath);
1390 MakeSlashPath(absolutePath);
1392 return node != null;
1395 void MarkChanges(ProjectNode node)
1397 for(cfg : topNode.configurations)
1399 ProjectConfig c = null;
1400 for(i : node.configurations; !strcmpi(i.name, cfg.name)) { c = i; break; }
1402 if(c && ((c.options && cfg.options && cfg.options.console != c.options.console) ||
1403 (!c.options || !cfg.options)))
1404 cfg.symbolGenModified = true;
1405 if(c && ((c.options && cfg.options &&
1406 ( (cfg.options.libraries && c.options.libraries && cfg.options.libraries.OnCompare(c.options.libraries)) || (!cfg.options.libraries || !c.options.libraries)) )
1407 || (!c.options || !cfg.options)))
1408 cfg.linkingModified = true;
1410 cfg.makingModified = true;
1414 void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
1416 Map<String, NameCollisionInfo> cfgNameCollision;
1417 MapIterator<const String, Map<String, NameCollisionInfo>> it { map = configsNameCollisions };
1418 if(it.Index("", false))
1420 cfgNameCollision = it.data;
1421 cfgNameCollision.Free();
1422 delete cfgNameCollision;
1425 for(cfg : configurations)
1429 cfg.makingModified = true;
1430 if(it.Index(cfg.name, false))
1432 cfgNameCollision = it.data;
1433 cfgNameCollision.Free();
1434 delete cfgNameCollision;
1439 cfg.compilingModified = true;
1441 cfg.linkingModified = true;
1443 cfg.symbolGenModified = true;
1445 if(compiling || linking)
1447 ide.projectView.modifiedDocument = true;
1448 ide.workspace.modified = true;
1452 void RotateActiveConfig(bool forward, bool syncAllProjects)
1454 if(configurations.first && configurations.last != configurations.first)
1456 Iterator<ProjectConfig> cfg { configurations };
1457 while(forward ? cfg.Next() : cfg.Prev())
1458 if(cfg.data == config)
1473 ide.workspace.SelectActiveConfig(cfg.data.name);
1476 property::config = cfg.data;
1477 ide.UpdateToolBarActiveConfigs(true);
1478 ide.workspace.modified = true;
1479 ide.projectView.Update(null);
1484 bool ProcessPipeOutputRaw(DualPipe f)
1487 while(!f.Eof() && !ide.projectView.stopBuild)
1490 double lastTime = GetTime();
1494 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
1496 ide.outputView.buildBox.Logf("%s\n", line);
1498 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1500 //printf("Processing Input...\n");
1501 if(app.ProcessInput(true))
1503 app.UpdateDisplay();
1506 //printf("Waiting...\n");
1509 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
1511 if(ide.projectView.stopBuild)
1513 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
1516 return !ide.projectView.stopBuild;
1519 bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, BuildType buildType, List<ProjectNode> onlyNodes,
1520 CompilerConfig compiler, ProjectConfig config, int bitDepth)
1524 bool compiling = false, linking = false, precompiling = false;
1525 int compilingEC = 0;
1526 int numErrors = 0, numWarnings = 0;
1527 bool loggedALine = false;
1528 int lenMakeCommand = strlen(compiler.makeCommand);
1530 const char * t, * s, * s2;
1531 char moduleName[MAX_FILENAME];
1532 const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
1534 DynamicString test { };
1535 DynamicString ecp { };
1536 DynamicString ecc { };
1537 DynamicString ecs { };
1538 DynamicString ear { };
1539 DynamicString prefix { };
1540 DynamicString cpp { };
1541 DynamicString cc { };
1542 DynamicString cxx { };
1543 DynamicString strip { };
1544 DynamicString ar { };
1545 DynamicString windres { };
1548 if(bitDepth == 64 && compiler.targetPlatform == win32)
1549 gnuToolchainPrefix = "x86_64-w64-mingw32-";
1550 else if(bitDepth == 32 && compiler.targetPlatform == win32)
1551 gnuToolchainPrefix = "i686-w64-mingw32-";
1553 ecp.concatx(compiler.ecpCommand, " ");
1554 ecc.concatx(compiler.eccCommand, " ");
1555 ecs.concatx(compiler.ecsCommand, " ");
1556 ear.concatx(compiler.earCommand, " ");
1559 compiler.ccacheEnabled ? "ccache " : "",
1560 compiler.distccEnabled ? "distcc " : "",
1561 gnuToolchainPrefix);
1563 cpp.concatx((String)prefix, compiler.cppCommand, " ");
1564 cc.concatx((String)prefix, compiler.ccCommand, " ");
1565 cxx.concatx((String)prefix, compiler.cxxCommand, " ");
1567 ar.concatx((String)gnuToolchainPrefix, compiler.arCommand, " ");
1568 strip.concatx(gnuToolchainPrefix, "strip ");
1569 windres.concatx(gnuToolchainPrefix, "windres ");
1571 testLen = Max(testLen, ecp.size);
1572 testLen = Max(testLen, ecc.size);
1573 testLen = Max(testLen, ecs.size);
1574 testLen = Max(testLen, ear.size);
1575 testLen = Max(testLen, cpp.size);
1576 testLen = Max(testLen, cc.size);
1577 testLen = Max(testLen, cxx.size);
1578 testLen = Max(testLen, strip.size);
1579 testLen = Max(testLen, ar.size);
1580 testLen = Max(testLen, windres.size);
1581 testLen = Max(testLen, strlen("mkdir "));
1584 while(!f.Eof() && !ide.projectView.stopBuild)
1586 double lastTime = GetTime();
1588 while(!f.Eof() && !ide.projectView.stopBuild)
1591 bool lineDone = f.GetLinePeek(line + linePos, sizeof(line)-linePos-1, &nChars);
1595 Sleep(0.5 / PEEK_RESOLUTION);
1602 const char * message = null;
1603 const char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1604 const char * from = strstr(line, stringFrom);
1605 test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
1606 if((t = strstr(line, (s=": recipe for target"))) && (t = strstr(t+strlen(s), (s2 = " failed"))) && (t+strlen(s2))[0] == '\0')
1607 ; // ignore this new gnu make error but what is it about?
1608 else if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
1610 const char * moduleBackTick = strstr(line, "No rule to make target `");
1611 const char * module = moduleBackTick ? moduleBackTick : strstr(line, "No rule to make target '");
1615 module = strchr(module, moduleBackTick ? '`' : '\'') + 1;
1616 end = strchr(module, '\'');
1620 ide.outputView.buildBox.Logf($" %s: No such file or directory\n", module);
1621 // ide.outputView.buildBox.Logf("error: %s\n No such file or directory\n", module);
1627 //ide.outputView.buildBox.Logf("error: %s\n", line);
1631 else if(strstr(test, "mkdir ") == test);
1632 else if((t = strstr(line, "cd ")) && (t = strstr(line, "type ")) && (t = strstr(line, "nul ")) && (t = strstr(line, "copy ")) && (t = strstr(line, "cd ")));
1633 else if(strstr(test, ear) == test);
1634 else if(strstr(test, strip) == test);
1635 else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
1637 char * module = null;
1638 bool isPrecomp = false;
1641 if(strstr(test, cc) == test || strstr(test, cxx) == test)
1643 module = strstr(line, " -c ");
1644 if(module) module += 4;
1647 else if(strstr(test, ecc) == test)
1649 module = strstr(line, " -c ");
1650 if(module) module += 4;
1651 //module = line + 3;
1652 // Don't show GCC warnings about generated C code because it does not compile clean yet...
1653 compilingEC = 3;//2;
1656 else if(strstr(test, ecp) == test)
1658 // module = line + 8;
1659 module = strstr(line, " -c ");
1660 if(module) module += 4;
1671 if(!compiling && !isPrecomp)
1673 ide.outputView.buildBox.Logf($"Compiling...\n");
1676 else if(!precompiling && isPrecomp)
1678 ide.outputView.buildBox.Logf($"Generating symbols...\n");
1679 precompiling = true;
1681 Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
1682 GetLastDirectory(tokens[0], moduleName);
1683 ide.outputView.buildBox.Logf("%s\n", moduleName);
1685 else if((module = strstr(line, " -o ")))
1688 precompiling = false;
1690 ide.outputView.buildBox.Logf($"Linking...\n");
1694 ide.outputView.buildBox.Logf("%s\n", line);
1695 if(strstr(line, "warning:") || strstr(line, "note:"))
1697 else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
1701 if(compilingEC) compilingEC--;
1703 else if(strstr(test, windres) == test)
1706 module = strstr(line, " ");
1707 if(module) module++;
1711 char * dashF = strstr(module, "-F ");
1715 while(*dashF && *dashF != ' ') dashF++;
1716 while(*dashF && *dashF == ' ') dashF++;
1719 Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
1720 GetLastDirectory(module, moduleName);
1721 ide.outputView.buildBox.Logf("%s\n", moduleName);
1724 else if(strstr(test, ar) == test)
1725 ide.outputView.buildBox.Logf($"Building library...\n");
1726 else if(strstr(test, ecs) == test)
1727 ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
1730 if(linking || compiling || precompiling)
1732 const char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
1733 const char * colon = strstr(start, ":"); //, * bracket;
1734 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1735 colon = strstr(colon + 1, ":");
1738 const char * sayError = "";
1739 char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
1742 int len = (int)(colon - start);
1743 char ext[MAX_EXTENSION];
1744 len = Min(len, MAX_LOCATION-1);
1745 // Don't be mistaken by the drive letter colon
1747 // TODO: need to fix colon - line gives char *
1748 // warning: incompatible expression colon - line (char *); expected int
1750 strncpy(moduleName, line, (int)(colon - line));
1751 moduleName[colon - line] = '\0';
1753 strncpy(moduleName, start, len);
1754 moduleName[len] = '\0';
1755 // Remove stuff in brackets
1756 //bracket = strstr(moduleName, "(");
1757 //if(bracket) *bracket = '\0';
1759 GetLastDirectory(moduleName, temp);
1760 GetExtension(temp, ext);
1762 if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
1764 char * cColon = strstr(colon+1, ":");
1765 if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
1766 cColon = strstr(cColon + 1, ":");
1769 int len = (int)(cColon - (colon+1));
1770 char mName[MAX_LOCATION];
1771 len = Min(len, MAX_LOCATION-1);
1772 strncpy(mName, colon+1, len);
1774 GetLastDirectory(mName, temp);
1775 GetExtension(temp, ext);
1776 if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
1779 strcpy(moduleName, mName);
1783 if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
1786 if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
1788 message = $"Linker Message: ";
1791 else if(SearchString(colon, 0, "warning:", false, false))
1793 message = $"Linker Warning: ";
1799 message = $"Linker Error: ";
1802 else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
1806 if(strstr(colon, "Warning:") == colon)
1808 message = $"Linker ";
1811 else if(strstr(line, "error:"))
1813 message = $"Linker Error: ";
1819 strcpy(temp, topNode.path);
1820 PathCatSlash(temp, moduleName);
1821 MakePathRelative(temp, topNode.path, moduleName);
1823 error = strstr(line, "error:");
1824 if(!message && error && error > colon)
1828 // Silence warnings for compiled eC
1829 //char * objDir = strstr(moduleName, objDirExp.dir);
1833 if((pointer = strstr(line, "undefined")) ||
1834 (pointer = strstr(line, "multiple definition")) ||
1835 (pointer = strstr(line, "No such file")) ||
1836 (pointer = strstr(line, "token")))
1838 strncat(moduleName, colon, pointer - colon);
1839 sayError = "error: ";
1844 else if((pointer = strstr(line, "No such file")))
1846 strncat(moduleName, colon, pointer - colon);
1847 sayError = "error: ";
1851 else //if(compilingEC == 1 || (objDir && objDir == moduleName))
1855 // Filter out these warnings caused by eC generated C code:
1857 // Declaration ordering bugs -- Awaiting topo sort implementation
1859 if(strstr(line, "declared inside parameter list")) skip = true;
1860 else if(strstr(line, "its scope is only this definition")) skip = true;
1861 else if(strstr(line, "from incompatible pointer type")) skip = true;
1862 else if(strstr(line, "note: expected 'struct ") || strstr(line, "note: expected ‘struct "))
1864 #define STRUCT_A "'struct "
1865 #define STRUCT_B "‘struct "
1866 char * struct1, * struct2, ch1, ch2;
1867 struct1 = strstr(line, STRUCT_A);
1868 if(struct1) { struct1 += sizeof(STRUCT_A)-1; } else { struct1 = strstr(line, STRUCT_B); struct1 += sizeof(STRUCT_B)-1; };
1870 struct2 = strstr(struct1, STRUCT_A);
1871 if(struct2) { struct2 += sizeof(STRUCT_A)-1; } else { struct2 = strstr(struct1, STRUCT_B); if(struct2) struct2 += sizeof(STRUCT_B)-1; };
1873 if(struct1 && struct2)
1875 while(ch1 = *(struct1++), ch2 = *(struct2++), ch1 && ch2 && (ch1 == '_' || isalnum(ch1)) && (ch2 == '_' || isalnum(ch2)));
1881 // For preprocessed code from objidl.h (MinGW-w64 headers)
1882 else if(strstr(line, "declaration does not declare anything")) skip = true;
1884 // Location information that could apply to ignored warnings
1885 else if(strstr(line, "In function '") || strstr(line, "In function ‘") ) skip = true;
1886 else if(strstr(line, "At top level")) skip = true;
1887 else if(strstr(line, "(near initialization for '") || strstr(line, "(near initialization for ‘")) skip = true;
1892 /*else if(strstr(line, "warning:"))
1898 ide.outputView.buildBox.Logf(" %s%s\n", message, colon);
1899 /*else if(this == ide.workspace.projects.firstIterator.data)
1900 ide.outputView.buildBox.Logf(" %s%s%s\n", moduleName, sayError, colon);*/
1903 char fullModuleName[MAX_LOCATION];
1904 FileAttribs found = 0;
1905 //Project foundProject = this;
1908 char * loc = strstr(moduleName, ":");
1910 strcpy(fullModuleName, topNode.path);
1911 PathCat(fullModuleName, moduleName);
1912 found = FileExists(fullModuleName);
1913 if(!found && !strcmp(ext, "c"))
1915 char ecName[MAX_LOCATION];
1916 ChangeExtension(fullModuleName, "ec", ecName);
1917 found = FileExists(ecName);
1921 char path[MAX_LOCATION];
1922 if(ide && ide.workspace)
1924 for(prj : ide.workspace.projects)
1927 MakePathRelative(fullModuleName, prj.topNode.path, path);
1929 if((node = prj.topNode.FindWithPath(path, false)))
1931 strcpy(fullModuleName, prj.topNode.path);
1932 PathCatSlash(fullModuleName, node.path);
1933 PathCatSlash(fullModuleName, node.name);
1934 found = FileExists(fullModuleName);
1937 //foundProject = prj;
1942 if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
1944 for(prj : ide.workspace.projects)
1947 if((node = prj.topNode.Find(moduleName, false)))
1949 strcpy(fullModuleName, prj.topNode.path);
1950 PathCatSlash(fullModuleName, node.path);
1951 PathCatSlash(fullModuleName, node.name);
1952 found = FileExists(fullModuleName);
1955 //foundProject = prj;
1965 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
1966 MakeSystemPath(fullModuleName);
1969 strcpy(fullModuleName, moduleName);
1972 strcat(fullModuleName, ":");
1973 strcat(fullModuleName, loc + 1);
1977 fullModuleName[0] = 0;
1978 ide.outputView.buildBox.Logf(" %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
1983 ide.outputView.buildBox.Logf("%s\n", line);
1984 linking = compiling = precompiling = false;
1988 ide.outputView.buildBox.Logf("%s\n", line);
1993 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
1995 //printf("Processing Input...\n");
1996 if(app.ProcessInput(true))
1998 app.UpdateDisplay();
2001 //printf("Waiting...\n");
2004 //if(!result) Sleep(1.0 / PEEK_RESOLUTION);
2006 if(ide.projectView.stopBuild)
2008 ide.outputView.buildBox.Logf($"\nBuild cancelled by user.\n", line);
2011 else if(loggedALine || buildType != run)
2013 if(f.GetExitCode() && !numErrors)
2015 /*bool result = */f.GetLine(line, sizeof(line)-1);
2016 ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
2018 else if(buildType != install)
2022 char targetFileName[MAX_LOCATION];
2023 targetFileName[0] = '\0';
2024 CatTargetFileName(targetFileName, compiler, config);
2025 ide.outputView.buildBox.Logf("\n%s (%s) - ", targetFileName, lastBuildConfigName);
2028 ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
2030 ide.outputView.buildBox.Logf($"no error, ");
2033 ide.outputView.buildBox.Logf("%d %s\n", numWarnings, (numWarnings > 1) ? $"warnings" : $"warning");
2035 ide.outputView.buildBox.Logf($"no warning\n");
2052 return numErrors == 0 && !ide.projectView.stopBuild;
2055 void ProcessCleanPipeOutput(DualPipe f, CompilerConfig compiler, ProjectConfig config)
2058 int lenMakeCommand = strlen(compiler.makeCommand);
2063 double lastTime = GetTime();
2066 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
2068 if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':');
2069 else if(strstr(line, "mkdir") == line);
2070 else if(strstr(line, "del") == line);
2071 else if(strstr(line, "rm") == line);
2072 else if(strstr(line, "Could Not Find") == line);
2075 ide.outputView.buildBox.Logf(line);
2076 ide.outputView.buildBox.Logf("\n");
2080 if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
2082 if(app.ProcessInput(true))
2084 app.UpdateDisplay();
2087 //Sleep(1.0 / PEEK_RESOLUTION);
2091 bool Build(BuildType buildType, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, BuildOutputMode outputMode, SingleFileCompileMode mode)
2093 bool result = false;
2095 char targetFileName[MAX_LOCATION] = "";
2096 DynamicString makeTargets { };
2097 char makeFile[MAX_LOCATION];
2098 char makeFilePath[MAX_LOCATION];
2099 char configName[MAX_LOCATION];
2100 DirExpression objDirExp = GetObjDir(compiler, config, bitDepth);
2101 PathBackup pathBackup { };
2102 bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
2103 const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
2105 bool eC_Debug = mode.eC_ToolsDebug;
2106 bool singleProjectOnlyNode = onlyNodes && onlyNodes.count == 1 && onlyNodes[0].type == project;
2107 int numJobs = compiler.numJobs;
2108 char command[MAX_F_STRING*4];
2109 char * compilerName = CopyString(compiler.name);
2110 Map<String, NameCollisionInfo> cfgNameCollisions;
2112 delete lastBuildConfigName;
2113 lastBuildConfigName = CopyString(config ? config.name : "Common");
2114 delete lastBuildCompilerName;
2115 lastBuildCompilerName = CopyString(compiler.name);
2116 ProjectLoadLastBuildNamesInfo(this, config);
2117 cfgNameCollisions = configsNameCollisions[config ? config.name : ""];
2119 CamelCase(compilerName);
2121 strcpy(configName, config ? config.name : "Common");
2123 SetPath(false, compiler, config, bitDepth); //true
2124 CatTargetFileName(targetFileName, compiler, config);
2126 strcpy(makeFilePath, topNode.path);
2127 CatMakeFileName(makeFile, config);
2128 PathCatSlash(makeFilePath, makeFile);
2130 // TODO: TEST ON UNIX IF \" around makeTarget is ok
2131 if(buildType == install)
2132 makeTargets.concat(" install");
2135 if(compiler.type.isVC)
2137 PrintLn("compiling a single file is not yet supported");
2141 char pushD[MAX_LOCATION];
2142 char cfDir[MAX_LOCATION];
2143 GetIDECompilerConfigsDir(cfDir, true, true);
2144 GetWorkingDir(pushD, sizeof(pushD));
2145 ChangeWorkingDir(topNode.path);
2146 // Create object dir if it does not exist already
2147 if(!FileExists(objDirExp.dir).isDirectory)
2149 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s objdir -C \"%s\"%s%s -f \"%s\"",
2150 compiler.makeCommand, cfDir,
2151 crossCompiling ? " TARGET_PLATFORM=" : "",
2153 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2154 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" : */"",
2156 topNode.path, outputMode == verbose ? " V=1" : "", outputMode == justPrint ? " -n" : "", makeFilePath);
2157 if(outputMode != normal)
2158 ide.outputView.buildBox.Logf("%s\n", command);
2162 ChangeWorkingDir(pushD);
2164 for(node : onlyNodes)
2166 if(node.GetIsExcludedForCompiler(config, compiler))
2167 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2171 node.DeleteIntermediateFiles(compiler, config, bitDepth, cfgNameCollisions, mode == cObject ? true : false);
2172 node.GetTargets(config, cfgNameCollisions, objDirExp.dir, compiler.objectFileExt, makeTargets);
2178 if(compiler.type.isVC)
2180 //bool result = false;
2181 char oldwd[MAX_LOCATION];
2182 GetWorkingDir(oldwd, sizeof(oldwd));
2183 ChangeWorkingDir(topNode.path);
2185 // TODO: support justPrint and verbose
2186 sprintf(command, "%s /useenv /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2187 if(outputMode != normal)
2188 ide.outputView.buildBox.Logf("%s\n", command);
2189 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
2191 ProcessPipeOutputRaw(f);
2195 ChangeWorkingDir(oldwd);
2197 else if(onlyNodes && strlen(makeTargets) == 0)
2199 ide.outputView.buildBox.Log("No targets to compile.\n");
2203 GccVersionInfo ccVersion = GetGccVersionInfo(compiler, compiler.ccCommand);
2204 GccVersionInfo cxxVersion = GetGccVersionInfo(compiler, compiler.cxxCommand);
2205 char cfDir[MAX_LOCATION];
2206 GetIDECompilerConfigsDir(cfDir, true, true);
2207 sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s%s COMPILER=%s%s %s%s%s-j%d %s%s%s -C \"%s\"%s%s -f \"%s\"",
2208 #if defined(__WIN32__)
2211 buildType == install ? "pkexec --user root " : "",
2213 compiler.makeCommand,
2214 mode == debugPrecompile ? "ECP_DEBUG=y " : mode == debugCompile ? "ECC_DEBUG=y " : mode == debugGenerateSymbols ? "ECS_DEBUG=y " : "",
2216 crossCompiling ? " TARGET_PLATFORM=" : "",
2218 bitDepth ? " ARCH=" : "",
2219 bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2220 ide.workspace.useValgrind ? " DISABLED_POOLING=1" : "",
2221 /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
2223 compiler.noStripTarget ? " NOSTRIP=y" : "",
2224 eC_Debug ? "--always-make " : "",
2225 ccVersion == post4_8 ? "GCC_CC_FLAGS=-fno-diagnostics-show-caret " : "",
2226 cxxVersion == post4_8 ? "GCC_CXX_FLAGS=-fno-diagnostics-show-caret " : "",
2228 (compiler.ccacheEnabled && !eC_Debug) ? "CCACHE=y " : "",
2229 (compiler.distccEnabled && !eC_Debug) ? "DISTCC=y " : "",
2230 (String)makeTargets, topNode.path, outputMode == verbose ? " V=1" : "", (outputMode == justPrint || eC_Debug) ? " -n" : "", makeFilePath);
2231 if(outputMode != normal)
2232 ide.outputView.buildBox.Logf("%s\n", command);
2234 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2241 if(outputMode == justPrint)
2242 ide.outputView.buildBox.Logf($"\nMake outputs the following list of commands to choose from:\n");
2248 if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
2250 if(outputMode == justPrint)
2251 ide.outputView.buildBox.Logf("%s\n", line);
2252 if(!error && !found && strstr(line, "echo ") == line && strstr(line, "ECERE_SDK_SRC"))
2254 strcpy(command, line+5);
2257 if(!error && (singleProjectOnlyNode || !found) && strstr(line, "ecere-ide ") == line)
2259 strcpy(command, line);
2268 else if(outputMode != normal)
2269 result = ProcessPipeOutputRaw(f);
2271 result = ProcessBuildPipeOutput(f, objDirExp, buildType, onlyNodes, compiler, config, bitDepth);
2274 ide.outputView.buildBox.Logf("%s\n", command);
2275 else if(outputMode == justPrint && found)
2276 ide.outputView.buildBox.Logf($"\nThe following command was chosen to be executed:\n%s\n", command);
2281 ide.outputView.buildBox.Logf($"Error executing make (%s) command\n", compiler.makeCommand);
2286 delete compilerName;
2291 void Clean(CompilerConfig compiler, ProjectConfig config, int bitDepth, CleanType cleanType, BuildOutputMode outputMode)
2293 char makeFile[MAX_LOCATION];
2294 char makeFilePath[MAX_LOCATION];
2295 char command[MAX_LOCATION];
2296 char * compilerName;
2298 PathBackup pathBackup { };
2299 bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
2300 const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
2302 compilerName = CopyString(compiler.name);
2303 CamelCase(compilerName);
2305 SetPath(false, compiler, config, bitDepth);
2307 strcpy(makeFilePath, topNode.path);
2308 CatMakeFileName(makeFile, config);
2309 PathCatSlash(makeFilePath, makeFile);
2311 if(compiler.type.isVC)
2313 //bool result = false;
2314 char oldwd[MAX_LOCATION];
2315 GetWorkingDir(oldwd, sizeof(oldwd));
2316 ChangeWorkingDir(topNode.path);
2318 // TODO: support justPrint and verbose
2319 sprintf(command, "%s /useenv /clean /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
2320 if(outputMode != normal)
2321 ide.outputView.buildBox.Logf("%s\n", command);
2322 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2324 ProcessPipeOutputRaw(f);
2328 ChangeWorkingDir(oldwd);
2333 char cfDir[MAX_LOCATION];
2334 GetIDECompilerConfigsDir(cfDir, true, true);
2335 sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s %sclean%s -C \"%s\"%s%s -f \"%s\"",
2336 compiler.makeCommand, cfDir,
2337 crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
2338 bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
2340 cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
2341 topNode.path, outputMode == verbose ? " V=1" : "", outputMode == justPrint ? " -n": "", makeFilePath);
2342 if(outputMode != normal)
2343 ide.outputView.buildBox.Logf("%s\n", command);
2344 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
2346 ide.outputView.buildBox.Tellf($"Deleting %s%s...",
2347 cleanType == realClean ? $"intermediate objects directory" : $"target",
2348 cleanType == clean ? $" and object files" : "");
2349 if(outputMode != normal)
2350 ProcessPipeOutputRaw(f);
2352 ProcessCleanPipeOutput(f, compiler, config);
2353 ide.outputView.buildBox.Logf($"%s%s deleted\n",
2354 cleanType == realClean ? $"Intermediate objects directory" : $"Target",
2355 cleanType == clean ? $" and object files" : "");
2361 delete compilerName;
2364 void Run(const char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool shellOpen)
2366 String target = new char[maxPathLen];
2367 char oldDirectory[MAX_LOCATION];
2368 char * executableLauncher = compiler.executableLauncher;
2369 DirExpression targetDirExp = GetTargetDir(compiler, config, bitDepth);
2370 PathBackup pathBackup { };
2372 // Build(project, ...);
2374 strcpy(target, topNode.path);
2375 PathCatSlash(target, targetDirExp.dir);
2376 CatTargetFileName(target, compiler, config);
2377 if(args[0] && (executableLauncher || !shellOpen))
2378 sprintf(target, "%s %s", target, args);
2379 GetWorkingDir(oldDirectory, MAX_LOCATION);
2381 if(ide.workspace.debugDir && strlen(ide.workspace.debugDir))
2383 char temp[MAX_LOCATION];
2384 strcpy(temp, topNode.path);
2385 PathCatSlash(temp, ide.workspace.debugDir);
2386 ChangeWorkingDir(temp);
2389 ChangeWorkingDir(topNode.path);
2390 SetPath(true, compiler, config, bitDepth);
2391 if(executableLauncher)
2393 char * prefixedTarget = new char[strlen(executableLauncher) + strlen(target) + 8];
2394 prefixedTarget[0] = '\0';
2395 strcat(prefixedTarget, executableLauncher);
2396 strcat(prefixedTarget, " ");
2397 strcat(prefixedTarget, target);
2398 Execute(prefixedTarget);
2399 delete prefixedTarget;
2406 ChangeWorkingDir(oldDirectory);
2409 delete targetDirExp;
2413 bool Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, BuildOutputMode outputMode, SingleFileCompileMode mode)
2415 return Build(build, nodes, compiler, config, bitDepth, outputMode, mode);
2419 void GetMakefileTargetFileName(TargetTypes targetType, char * fileName, ProjectConfig config)
2422 if(targetType == staticLibrary || targetType == sharedLibrary)
2423 strcat(fileName, "$(LP)");
2424 strcat(fileName, GetTargetFileName(config));
2425 strcat(fileName, "$(OUT)");
2428 bool GenerateCrossPlatformMk(File altCrossPlatformMk)
2430 bool result = false;
2431 char path[MAX_LOCATION];
2433 if(!GetProjectCompilerConfigsDir(path, false, false))
2434 GetIDECompilerConfigsDir(path, false, false);
2436 if(!FileExists(path).isDirectory)
2440 char dirName[MAX_FILENAME];
2441 GetLastDirectory(path, dirName);
2442 if(!strcmp(dirName, ".configs"))
2443 FileSetAttribs(path, FileAttribs { isHidden = true });
2446 PathCatSlash(path, "crossplatform.mk");
2448 if(FileExists(path))
2451 File include = altCrossPlatformMk ? altCrossPlatformMk : FileOpen(":crossplatform.mk", read);
2454 File f = FileOpen(path, write);
2457 include.Seek(0, start);
2458 for(; !include.Eof(); )
2461 int count = include.Read(buffer, 1, 4096);
2462 f.Write(buffer, 1, count);
2468 if(!altCrossPlatformMk)
2475 bool GenerateCompilerCf(CompilerConfig compiler, bool eC)
2477 bool result = false;
2478 char path[MAX_LOCATION];
2480 char * compilerName;
2481 const char * ccCommand = compiler.ccCommand;
2482 bool gccCompiler = compiler.ccCommand && (strstr(ccCommand, "gcc") != null || strstr(ccCommand, "g++") != null || strstr(ccCommand, "emcc") != null || strstr(ccCommand, "clang") != null);
2483 const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
2484 Platform platform = compiler.targetPlatform;
2486 compilerName = CopyString(compiler.name);
2487 CamelCase(compilerName);
2488 name = PrintString(platform, "-", compilerName, ".cf");
2490 if(!GetProjectCompilerConfigsDir(path, false, false))
2491 GetIDECompilerConfigsDir(path, false, false);
2493 if(!FileExists(path).isDirectory)
2497 char dirName[MAX_FILENAME];
2498 GetLastDirectory(path, dirName);
2499 if(!strcmp(dirName, ".configs"))
2500 FileSetAttribs(path, FileAttribs { isHidden = true });
2503 PathCatSlash(path, name);
2505 if(FileExists(path))
2508 File f = FileOpen(path, write);
2511 if(compiler.environmentVars && compiler.environmentVars.count)
2513 f.Puts("# ENVIRONMENT VARIABLES\n");
2515 for(e : compiler.environmentVars)
2517 #if defined(__WIN32__)
2518 ChangeCh(e.string, '\\', '/');
2520 f.Printf("export %s := %s\n", e.name, e.string);
2521 #if defined(__WIN32__)
2522 ChangeCh(e.string, '/', '\\');
2528 f.Puts("# PREFIXES AND EXTENSIONS\n");
2529 f.Puts("EC := .ec\n");
2530 f.Puts("S := .sym\n");
2531 f.Puts("I := .imp\n");
2532 f.Puts("B := .bowl\n");
2533 f.Puts("C := .c\n");
2534 f.Printf("O := .%s\n", compiler.objectFileExt ? compiler.objectFileExt : "o");
2535 f.Printf("A := .%s\n", compiler.staticLibFileExt ? compiler.staticLibFileExt : "a");
2536 f.Printf("SO := .%s\n", compiler.sharedLibFileExt ? compiler.sharedLibFileExt : "$(if $(WINDOWS_TARGET),dll,$(if $(OSX_TARGET),dylib,so))");
2537 f.Printf("E := %s%s\n", compiler.executableFileExt ? "." : "",
2538 compiler.executableFileExt ? compiler.executableFileExt : "$(if $(WINDOWS_TARGET),.exe,)");
2539 f.Puts("OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))\n");
2540 f.Puts("LP := $(if $(WINDOWS_TARGET),$(if $(STATIC_LIBRARY_TARGET),lib,),lib)\n");
2541 f.Puts("HOST_E := $(if $(WINDOWS_HOST),.exe,)\n");
2542 f.Puts("HOST_SO := $(if $(WINDOWS_HOST),.dll,$(if $(OSX_HOST),.dylib,.so))\n");
2543 f.Puts("HOST_LP := $(if $(WINDOWS_HOST),$(if $(STATIC_LIBRARY_TARGET),lib,),lib)\n");
2544 f.Puts(".SUFFIXES: .c .ec .sym .imp .bowl $(O) $(A)\n");
2546 f.Puts("# TOOLCHAIN\n");
2549 f.Puts("# OPTIONS\n");
2550 if(compiler.resourcesDotEar)
2552 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
2553 f.Puts(" USE_RESOURCES_EAR := defined\n");
2556 if(compiler.noStripTarget)
2557 f.Puts("NOSTRIP := defined");
2561 f.Puts("# EXTENSIONS\n");
2562 if(compiler.outputFileExt)
2563 f.Printf("OUT := %s\n", compiler.outputFileExt);
2565 f.Puts("OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))\n");
2567 if(gnuToolchainPrefix && gnuToolchainPrefix[0])
2569 f.Printf("GCC_PREFIX := %s\n", gnuToolchainPrefix);
2572 if(compiler.sysroot && compiler.sysroot[0])
2574 f.Printf("SYSROOT := %s\n", compiler.sysroot);
2575 // Moved this to crossplatform.mk
2576 //f.Puts("_SYSROOT := $(space)--sysroot=$(SYSROOT)\n");
2580 //f.Printf("SHELL := %s\n", "sh"/*compiler.shellCommand*/); // is this really needed?
2581 f.Printf("CPP := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cppCommand);
2582 f.Printf("CC := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.ccCommand);
2583 f.Printf("CXX := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CXX_FLAGS),$(space)$(GCC_CXX_FLAGS),)\n", compiler.cxxCommand);
2586 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);
2587 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);
2588 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);
2592 f.Printf("ECP := %s\n", compiler.ecpCommand);
2593 f.Printf("ECC := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
2594 f.Printf("ECS := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)$(if $(DISABLED_POOLING), -disabled-pooling,)\n", compiler.ecsCommand);
2596 f.Printf("EAR := %s\n", compiler.earCommand);
2598 f.Puts("AS := $(GCC_PREFIX)as\n");
2600 if(compiler.ldCommand && compiler.ldCommand[0])
2602 f.Puts("$(GCC_PREFIX)");
2603 f.Puts(compiler.ldCommand);
2606 f.Puts("$(if $(CONTAINS_CXX),$(CXX),$(CC))");
2607 f.Puts("$(_SYSROOT)$(if $(GCC_LD_FLAGS),$(space)$(GCC_LD_FLAGS),)\n");
2609 f.Printf("AR := $(GCC_PREFIX)%s\n", compiler.arCommand);
2610 f.Puts("STRIP := $(GCC_PREFIX)strip\n");
2611 f.Puts("ifdef WINDOWS_TARGET\n");
2612 f.Puts("WINDRES := $(GCC_PREFIX)windres\n");
2613 f.Puts(" ifdef ARCH\n");
2614 f.Puts(" ifeq ($(ARCH),x32)\n");
2615 f.Puts("WINDRES_FLAGS := -F pe-i386\n");
2617 f.Puts(" ifeq ($(ARCH),x64)\n");
2618 f.Puts("WINDRES_FLAGS := -F pe-x86-64\n");
2623 f.Puts("UPX := upx\n");
2626 f.Puts("UPXFLAGS = -9\n"); // TOFEAT: Compression Level Option? Other UPX Options?
2629 f.Puts("EARFLAGS = \n");
2632 f.Puts("ifndef ARCH\n");
2633 f.Puts("TARGET_ARCH :=$(shell $(CC) -dumpmachine)\n");
2634 f.Puts(" ifdef WINDOWS_HOST\n");
2635 f.Puts(" ifneq ($(filter x86_64%,$(TARGET_ARCH)),)\n");
2636 f.Puts(" TARGET_ARCH := x86_64\n");
2638 f.Puts(" TARGET_ARCH := i386\n");
2641 f.Puts("endif\n\n");
2643 f.Puts("# HARD CODED TARGET_PLATFORM-SPECIFIC OPTIONS\n");
2644 f.Printf("LDFLAGS +=$(if $(%s), -Wl$(comma)--no-undefined,)\n", PlatformToMakefileTargetVariable(tux));
2648 f.Printf("LDFLAGS +=$(if $(%s), -framework cocoa -framework OpenGL,)\n", PlatformToMakefileTargetVariable(apple));
2652 f.Puts("\nCFLAGS += -fmessage-length=0\n");
2655 if(compiler.includeDirs && compiler.includeDirs.count)
2657 f.Puts("\nCFLAGS +=");
2658 OutputFlags(f, gccCompiler ? _isystem : _I, compiler.includeDirs, lineEach);
2661 if(compiler.prepDirectives && compiler.prepDirectives.count)
2663 f.Puts("\nCFLAGS +=");
2664 OutputFlags(f, _D, compiler.prepDirectives, inPlace);
2667 if(compiler.libraryDirs && compiler.libraryDirs.count)
2669 f.Puts("\nLDFLAGS +=");
2670 OutputFlags(f, _L, compiler.libraryDirs, lineEach);
2671 // We would need a bool option to know whether we want to add to rpath as well...
2672 // OutputFlags(f, _Wl-rpath, compiler.libraryDirs, lineEach);
2675 if(compiler.excludeLibs && compiler.excludeLibs.count)
2677 f.Puts("\nEXCLUDED_LIBS =");
2678 for(l : compiler.excludeLibs)
2684 if(compiler.eCcompilerFlags && compiler.eCcompilerFlags.count)
2686 f.Puts("\nECFLAGS +=");
2687 OutputFlags(f, any, compiler.eCcompilerFlags, inPlace);
2690 if(compiler.compilerFlags && compiler.compilerFlags.count)
2692 f.Puts("\nCFLAGS +=");
2693 OutputFlags(f, any, compiler.compilerFlags, inPlace);
2696 if(compiler.cxxFlags && compiler.cxxFlags.count)
2698 f.Puts("\nCXXFLAGS +=");
2699 OutputFlags(f, any, compiler.cxxFlags, inPlace);
2702 if(compiler.linkerFlags && compiler.linkerFlags.count)
2704 f.Puts("\nLDFLAGS +=");
2705 OutputFlags(f, _Wl, compiler.linkerFlags, inPlace);
2709 f.Puts("\nOFLAGS += $(LDFLAGS)");
2711 f.Puts("ifdef ARCH_FLAGS\n");
2712 f.Puts("CFLAGS += $(ARCH_FLAGS)\n");
2713 f.Puts("OFLAGS += $(ARCH_FLAGS)\n");
2722 delete compilerName;
2726 bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config)
2728 bool result = false;
2729 char filePath[MAX_LOCATION];
2730 char makeFile[MAX_LOCATION];
2731 // PathBackup pathBackup { };
2732 // char oldDirectory[MAX_LOCATION];
2735 if(!altMakefilePath)
2737 strcpy(filePath, topNode.path);
2738 CatMakeFileName(makeFile, config);
2739 PathCatSlash(filePath, makeFile);
2742 f = FileOpen(altMakefilePath ? altMakefilePath : filePath, write);
2744 /*SetPath(false, compiler, config);
2745 GetWorkingDir(oldDirectory, MAX_LOCATION);
2746 ChangeWorkingDir(topNode.path);*/
2753 char targetDir[MAX_LOCATION];
2754 char objDirExpNoSpaces[MAX_LOCATION];
2755 char objDirNoSpaces[MAX_LOCATION];
2756 char resDirNoSpaces[MAX_LOCATION];
2757 char targetDirExpNoSpaces[MAX_LOCATION];
2758 char fixedModuleName[MAX_FILENAME];
2759 char fixedConfigName[MAX_FILENAME];
2761 int lenObjDirExpNoSpaces, lenTargetDirExpNoSpaces;
2762 // Non-zero if we're building eC code
2763 // We'll have to be careful with this when merging configs where eC files can be excluded in some configs and included in others
2764 int numCObjects = 0;
2766 int numRCObjects = 0;
2767 bool containsCXX = false; // True if the project contains a C++ file
2768 bool relObjDir, sameOrRelObjTargetDirs;
2769 const String objDirExp = GetObjDirExpression(config);
2770 TargetTypes targetType = GetTargetType(config);
2772 char cfDir[MAX_LOCATION];
2773 int objectsParts = 0;
2774 int eCsourcesParts = 0;
2775 int rcSourcesParts = 0;
2776 Array<String> listItems { };
2777 Map<String, int> varStringLenDiffs { };
2778 Map<String, NameCollisionInfo> namesInfo { };
2780 Map<String, int> cflagsVariations { };
2781 Map<intptr, int> nodeCFlagsMapping { };
2783 Map<String, int> ecflagsVariations { };
2784 Map<intptr, int> nodeECFlagsMapping { };
2786 ReplaceSpaces(objDirNoSpaces, objDirExp);
2787 strcpy(targetDir, GetTargetDirExpression(config));
2788 ReplaceSpaces(targetDirExpNoSpaces, targetDir);
2790 strcpy(objDirExpNoSpaces, GetObjDirExpression(config));
2791 ChangeCh(objDirExpNoSpaces, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
2793 char temp[MAX_LOCATION];
2794 ReplaceSpaces(temp, objDirExpNoSpaces);
2795 strcpy(objDirExpNoSpaces, temp);
2797 ReplaceSpaces(resDirNoSpaces, resNode.path ? resNode.path : "");
2798 ReplaceSpaces(fixedModuleName, moduleName);
2799 ReplaceSpaces(fixedConfigName, GetConfigName(config));
2800 CamelCase(fixedConfigName);
2802 lenObjDirExpNoSpaces = strlen(objDirExpNoSpaces);
2803 relObjDir = lenObjDirExpNoSpaces == 0 ||
2804 (objDirExpNoSpaces[0] == '.' && (lenObjDirExpNoSpaces == 1 || objDirExpNoSpaces[1] == '.'));
2805 lenTargetDirExpNoSpaces = strlen(targetDirExpNoSpaces);
2806 sameOrRelObjTargetDirs = lenTargetDirExpNoSpaces == 0 ||
2807 (targetDirExpNoSpaces[0] == '.' && (lenTargetDirExpNoSpaces == 1 || targetDirExpNoSpaces[1] == '.')) ||
2808 !fstrcmp(objDirExpNoSpaces, targetDirExpNoSpaces);
2810 f.Printf(".PHONY: all objdir%s cleantarget clean realclean distclean\n\n", sameOrRelObjTargetDirs ? "" : " targetdir");
2812 f.Puts("# CORE VARIABLES\n\n");
2814 f.Printf("MODULE := %s\n", fixedModuleName);
2815 f.Printf("VERSION := %s\n", property::moduleVersion);
2816 f.Printf("CONFIG := %s\n", fixedConfigName);
2817 topNode.GenMakefilePrintNode(f, this, noPrint, null, null, config, &containsCXX);
2819 f.Puts("CONTAINS_CXX := defined\n");
2820 f.Puts("ifndef COMPILER\n" "COMPILER := default\n" "endif\n");
2823 test = GetTargetTypeIsSetByPlatform(config);
2827 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
2829 TargetTypes targetType;
2830 PlatformOptions projectPOs, configPOs;
2831 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
2832 targetType = platformTargetType;
2838 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
2839 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2844 f.Printf("TARGET_TYPE = %s\n", TargetTypeToMakefileVariable(targetType));
2849 for(c = 0; c < ifCount; c++)
2855 f.Puts("# FLAGS\n\n");
2857 f.Puts("ECFLAGS =\n");
2858 f.Puts("ifndef DEBIAN_PACKAGE\n" "CFLAGS =\n" "LDFLAGS =\n" "endif\n");
2859 f.Puts("PRJ_CFLAGS =\n");
2860 f.Puts("CECFLAGS =\n");
2861 f.Puts("OFLAGS =\n");
2865 f.Puts("ifdef DEBUG\n" "NOSTRIP := y\n" "endif\n");
2868 // Important: We cannot use this ifdef anymore, EXECUTABLE_TARGET is not yet defined. It's embedded in the crossplatform.mk EXECUTABLE
2869 //f.Puts("ifdef EXECUTABLE_TARGET\n");
2870 f.Printf("CONSOLE = %s\n", GetConsole(config) ? "-mconsole" : "-mwindows");
2871 //f.Puts("endif\n");
2874 f.Puts("# INCLUDES\n\n");
2876 if(compilerConfigsDir && compilerConfigsDir[0])
2878 strcpy(cfDir, compilerConfigsDir);
2879 if(cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
2884 GetIDECompilerConfigsDir(cfDir, true, true);
2885 // Use CF_DIR environment variable for absolute paths only
2886 if(cfDir[0] == '/' || (cfDir[0] && cfDir[1] == ':'))
2887 strcpy(cfDir, "$(CF_DIR)");
2890 f.Printf("_CF_DIR = %s\n", cfDir);
2893 f.Printf("include %s\n", includemkPath ? includemkPath : "$(_CF_DIR)crossplatform.mk");
2894 f.Puts("include $(_CF_DIR)$(TARGET_PLATFORM)-$(COMPILER).cf\n");
2897 f.Puts("# POST-INCLUDES VARIABLES\n\n");
2899 f.Printf("OBJ = %s%s\n", objDirExpNoSpaces, objDirExpNoSpaces[0] ? "/" : "");
2902 f.Printf("RES = %s%s\n", resDirNoSpaces, resDirNoSpaces[0] ? "/" : "");
2905 // test = GetTargetTypeIsSetByPlatform(config);
2907 char target[MAX_LOCATION];
2908 char temp[MAX_LOCATION];
2913 for(type = (TargetTypes)1; type < TargetTypes::enumSize; type++)
2915 if(type != targetType)
2920 f.Printf("ifeq ($(TARGET_TYPE),%s)\n", TargetTypeToMakefileVariable(type));
2922 GetMakefileTargetFileName(type, target, config);
2923 strcpy(temp, targetDir);
2924 PathCatSlash(temp, target);
2925 ReplaceSpaces(target, temp);
2926 f.Printf("TARGET = %s\n", target);
2931 GetMakefileTargetFileName(targetType, target, config);
2932 strcpy(temp, targetDir);
2933 PathCatSlash(temp, target);
2934 ReplaceSpaces(target, temp);
2935 f.Printf("TARGET = %s\n", target);
2941 for(c = 0; c < ifCount; c++)
2948 // Use something fixed here, to not cause Makefile differences across compilers...
2949 varStringLenDiffs["$(OBJ)"] = 30; // strlen("obj/memoryGuard.android.gcc-4.6.2") - 6;
2950 // varStringLenDiffs["$(OBJ)"] = strlen(objDirNoSpaces) - 6;
2952 topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
2956 const char * map[5][2] = { { "COBJECTS", "C" }, { "SYMBOLS", "S" }, { "IMPORTS", "I" }, { "ECOBJECTS", "O" }, { "BOWLS", "B" } };
2958 numCObjects = topNode.GenMakefilePrintNode(f, this, eCsources, namesInfo, listItems, config, null);
2961 eCsourcesParts = OutputFileList(f, "_ECSOURCES", listItems, varStringLenDiffs, null);
2963 f.Puts("ECSOURCES = $(call shwspace,$(_ECSOURCES))\n");
2964 if(eCsourcesParts > 1)
2966 for(c = 1; c <= eCsourcesParts; c++)
2967 f.Printf("ECSOURCES%d = $(call shwspace,$(_ECSOURCES%d))\n", c, c);
2971 for(c = 0; c < 5; c++)
2973 if(eCsourcesParts > 1)
2976 f.Printf("_%s =", map[c][0]);
2977 for(n = 1; n <= eCsourcesParts; n++)
2978 f.Printf(" $(%s%d)", map[c][0], n);
2980 for(n = 1; n <= eCsourcesParts; n++)
2981 f.Printf("_%s%d = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES%d))))\n", map[c][0], n, map[c][1], n);
2983 else if(eCsourcesParts == 1)
2984 f.Printf("_%s = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES))))\n", map[c][0], map[c][1]);
2988 for(c = 0; c < 5; c++)
2990 if(eCsourcesParts > 1)
2993 f.Printf("%s =", map[c][0]);
2994 for(n = 1; n <= eCsourcesParts; n++)
2995 f.Printf(" $(%s%d)", map[c][0], n);
2997 for(n = 1; n <= eCsourcesParts; n++)
2998 f.Printf("%s%d = $(call shwspace,$(_%s%d))\n", map[c][0], n, map[c][0], n);
3000 else if(eCsourcesParts == 1)
3001 f.Printf("%s = $(call shwspace,$(_%s))\n", map[c][0], map[c][0]);
3007 numRCObjects = topNode.GenMakefilePrintNode(f, this, rcSources, namesInfo, listItems, config, null);
3010 f.Puts("ifdef WINDOWS_TARGET\n\n");
3012 rcSourcesParts = OutputFileList(f, "_RCSOURCES", listItems, varStringLenDiffs, null);
3014 f.Puts("RCSOURCES = $(call shwspace,$(_RCSOURCES))\n");
3015 if(rcSourcesParts > 1)
3017 for(c = 1; c <= rcSourcesParts; c++)
3018 f.Printf("RCSOURCES%d = $(call shwspace,$(_RCSOURCES%d))\n", c, c);
3021 if(rcSourcesParts > 1)
3024 f.Printf("%s =", "RCOBJECTS");
3025 for(n = 1; n <= rcSourcesParts; n++)
3026 f.Printf(" $(%s%d)", "RCOBJECTS", n);
3028 for(n = 1; n <= rcSourcesParts; n++)
3029 f.Printf("%s%d = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.rc,%%$(%s),$(notdir $(_RCSOURCES%d)))))\n", "RCOBJECTS", n, "O", n);
3031 else if(rcSourcesParts == 1)
3032 f.Printf("%s = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.rc,%%$(%s),$(notdir $(_RCSOURCES)))))\n", "RCOBJECTS", "O");
3036 f.Puts("RCSOURCES =\n");
3037 f.Puts("RCOBJECTS =\n");
3038 f.Puts("endif\n\n");
3041 numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, null);
3043 objectsParts = OutputFileList(f, "_OBJECTS", listItems, varStringLenDiffs, null);
3044 f.Printf("OBJECTS =%s%s%s%s\n",
3045 numObjects ? " $(_OBJECTS)" : "", numCObjects ? " $(ECOBJECTS)" : "",
3046 numCObjects ? " $(OBJ)$(MODULE).main$(O)" : "",
3047 numRCObjects ? " $(RCOBJECTS)" : "");
3050 topNode.GenMakefilePrintNode(f, this, sources, null, listItems, config, null);
3052 const char * prefix;
3053 if(numCObjects && numRCObjects)
3054 prefix = "$(ECSOURCES) $(RCSOURCES)";
3055 else if(numCObjects)
3056 prefix = "$(ECSOURCES)";
3059 OutputFileList(f, "SOURCES", listItems, varStringLenDiffs, prefix);
3063 resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config, null);
3064 OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs, null);
3066 f.Puts("ifdef USE_RESOURCES_EAR\n");
3067 f.Puts("RESOURCES_EAR = $(OBJ)resources.ear\n");
3069 f.Puts("RESOURCES_EAR = $(RESOURCES)\n");
3073 f.Puts("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n");
3075 if((config && config.options && config.options.libraries) ||
3076 (options && options.libraries))
3078 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3080 if(config && config.options && config.options.libraries)
3081 OutputLibraries(f, config.options.libraries);
3082 else if(options && options.libraries)
3083 OutputLibraries(f, options.libraries);
3089 topNode.GenMakeCollectAssignNodeFlags(config, numCObjects != 0,
3090 cflagsVariations, nodeCFlagsMapping,
3091 ecflagsVariations, nodeECFlagsMapping, null);
3093 GenMakePrintCustomFlags(f, "PRJ_CFLAGS", false, cflagsVariations);
3094 f.Puts("ECFLAGS += -module $(MODULE)\n");
3095 GenMakePrintCustomFlags(f, "ECFLAGS", true, ecflagsVariations);
3097 if(platforms || (config && config.platforms))
3100 //for(platform = firstPlatform; platform <= lastPlatform; platform++)
3101 //for(platform = win32; platform <= apple; platform++)
3103 f.Puts("# PLATFORM-SPECIFIC OPTIONS\n\n");
3104 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3106 PlatformOptions projectPlatformOptions, configPlatformOptions;
3107 MatchProjectAndConfigPlatformOptions(config, platform, &projectPlatformOptions, &configPlatformOptions);
3109 if(projectPlatformOptions || configPlatformOptions)
3114 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3117 if((projectPlatformOptions && projectPlatformOptions.options.compilerOptions && projectPlatformOptions.options.compilerOptions.count) ||
3118 (configPlatformOptions && configPlatformOptions.options.compilerOptions && configPlatformOptions.options.compilerOptions.count))
3120 f.Puts("CFLAGS +=");
3121 if(projectPlatformOptions && projectPlatformOptions.options.compilerOptions && projectPlatformOptions.options.compilerOptions.count)
3124 for(s : projectPlatformOptions.options.compilerOptions)
3127 if(configPlatformOptions && configPlatformOptions.options.compilerOptions && configPlatformOptions.options.compilerOptions.count)
3130 for(s : configPlatformOptions.options.compilerOptions)
3137 if((projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count) ||
3138 (configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count))
3140 f.Puts("OFLAGS +=");
3141 if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
3143 bool needWl = false;
3145 for(s : projectPlatformOptions.options.linkerOptions)
3147 if(!IsLinkerOption(s))
3155 for(s : projectPlatformOptions.options.linkerOptions)
3156 if(IsLinkerOption(s))
3160 if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
3162 bool needWl = false;
3164 for(s : configPlatformOptions.options.linkerOptions)
3166 if(IsLinkerOption(s))
3174 for(s : configPlatformOptions.options.linkerOptions)
3175 if(!IsLinkerOption(s))
3183 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
3184 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count) ||
3185 (projectPlatformOptions && projectPlatformOptions.options.libraries && projectPlatformOptions.options.libraries.count) ||
3186 (configPlatformOptions && configPlatformOptions.options.libraries && configPlatformOptions.options.libraries.count))
3188 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3189 if((projectPlatformOptions && projectPlatformOptions.options.libraryDirs && projectPlatformOptions.options.libraryDirs.count) ||
3190 (configPlatformOptions && configPlatformOptions.options.libraryDirs && configPlatformOptions.options.libraryDirs.count))
3192 f.Puts("OFLAGS +=");
3193 if(configPlatformOptions && configPlatformOptions.options.libraryDirs)
3194 OutputFlags(f, _L, configPlatformOptions.options.libraryDirs, lineEach);
3195 if(projectPlatformOptions && projectPlatformOptions.options.libraryDirs)
3196 OutputFlags(f, _L, projectPlatformOptions.options.libraryDirs, lineEach);
3200 if(configPlatformOptions && configPlatformOptions.options.libraries)
3202 if(configPlatformOptions.options.libraries.count)
3205 OutputLibraries(f, configPlatformOptions.options.libraries);
3209 else if(projectPlatformOptions && projectPlatformOptions.options.libraries)
3211 if(projectPlatformOptions.options.libraries.count)
3214 OutputLibraries(f, projectPlatformOptions.options.libraries);
3225 for(c = 0; c < ifCount; c++)
3231 if((config && config.options && config.options.compilerOptions && config.options.compilerOptions.count) ||
3232 (options && options.compilerOptions && options.compilerOptions.count))
3234 f.Puts("CFLAGS +=");
3237 if(config && config.options && config.options.compilerOptions && config.options.compilerOptions.count)
3239 for(s : config.options.compilerOptions)
3242 if(options && options.compilerOptions && options.compilerOptions.count)
3244 for(s : options.compilerOptions)
3251 if((config && config.options && config.options.linkerOptions && config.options.linkerOptions.count) ||
3252 (options && options.linkerOptions && options.linkerOptions.count))
3254 f.Puts("OFLAGS +=");
3257 if(config && config.options && config.options.linkerOptions && config.options.linkerOptions.count)
3259 bool needWl = false;
3260 for(s : config.options.linkerOptions)
3262 if(!IsLinkerOption(s))
3270 for(s : config.options.linkerOptions)
3271 if(IsLinkerOption(s))
3275 if(options && options.linkerOptions && options.linkerOptions.count)
3277 bool needWl = false;
3278 for(s : options.linkerOptions)
3280 if(!IsLinkerOption(s))
3288 for(s : options.linkerOptions)
3289 if(IsLinkerOption(s))
3297 f.Puts("CECFLAGS += -cpp $(_CPP)");
3301 if(GetProfile(config))
3302 f.Puts("OFLAGS += -pg\n\n");
3304 if((config && config.options && config.options.libraryDirs) || (options && options.libraryDirs))
3306 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3307 f.Puts("OFLAGS +=");
3308 if(config && config.options && config.options.libraryDirs)
3309 OutputFlags(f, _L, config.options.libraryDirs, lineEach);
3310 if(options && options.libraryDirs)
3311 OutputFlags(f, _L, options.libraryDirs, lineEach);
3317 f.Puts("# TARGETS\n");
3320 f.Printf("all: objdir%s $(TARGET)\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3323 f.Puts("objdir:\n");
3325 f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdir,$(OBJ)))\n");
3328 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");
3329 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");
3331 //f.Puts("# PRE-BUILD COMMANDS\n");
3332 if(options && options.prebuildCommands)
3334 for(s : options.prebuildCommands)
3335 if(s && s[0]) f.Printf("\t%s\n", s);
3337 if(config && config.options && config.options.prebuildCommands)
3339 for(s : config.options.prebuildCommands)
3340 if(s && s[0]) f.Printf("\t%s\n", s);
3342 if(platforms || (config && config.platforms))
3345 //f.Puts("# TARGET_PLATFORM-SPECIFIC PRE-BUILD COMMANDS\n");
3346 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3348 PlatformOptions projectPOs, configPOs;
3349 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3351 if((projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count) ||
3352 (configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count))
3357 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3359 if(projectPOs && projectPOs.options.prebuildCommands && projectPOs.options.prebuildCommands.count)
3361 for(s : projectPOs.options.prebuildCommands)
3362 if(s && s[0]) f.Printf("\t%s\n", s);
3364 if(configPOs && configPOs.options.prebuildCommands && configPOs.options.prebuildCommands.count)
3366 for(s : configPOs.options.prebuildCommands)
3367 if(s && s[0]) f.Printf("\t%s\n", s);
3374 for(c = 0; c < ifCount; c++)
3380 if(!sameOrRelObjTargetDirs)
3382 f.Puts("targetdir:\n");
3383 f.Printf("\t$(if $(wildcard %s),,$(call mkdir,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
3389 // Main Module (Linking) for ECERE C modules
3390 f.Puts("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
3391 f.Printf("\t@$(call rm,$(OBJ)symbols.lst)\n");
3392 f.Printf("\t@$(call touch,$(OBJ)symbols.lst)\n");
3393 OutputFileListActions(f, "SYMBOLS", eCsourcesParts, "$(OBJ)symbols.lst");
3394 OutputFileListActions(f, "IMPORTS", eCsourcesParts, "$(OBJ)symbols.lst");
3395 // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
3396 f.Printf("\t$(ECS)%s $(ARCH_FLAGS) $(ECSLIBOPT) @$(OBJ)symbols.lst -symbols %s -o $(call quote_path,$@)\n",
3397 GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
3399 // Main Module (Linking) for ECERE C modules
3400 f.Puts("$(OBJ)$(MODULE).main.c: $(OBJ)$(MODULE).main.ec\n");
3401 f.Puts("\t$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS)"
3402 " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
3403 f.Puts("\t$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY)"
3404 " -c $(OBJ)$(MODULE).main.ec -o $(call quote_path,$@) -symbols $(OBJ)\n");
3408 if(resNode.files && resNode.files.count && !noResources)
3410 f.Puts("ifdef USE_RESOURCES_EAR\n");
3411 f.Puts("$(RESOURCES_EAR): $(RESOURCES) | objdir\n");
3412 resNode.GenMakefileAddResources(f, resNode.path, config, "RESOURCES_EAR");
3419 // This would not rebuild the target on updated objects
3420 // f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) | objdir $(SYMBOLS) $(OBJECTS)%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3422 // This should fix it for good!
3423 f.Puts("$(SYMBOLS): | objdir\n");
3424 f.Puts("$(OBJECTS): | objdir\n");
3426 // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
3427 f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES_EAR) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
3428 rcSourcesParts ? " $(RCSOURCES)" : "", sameOrRelObjTargetDirs ? "" : " targetdir");
3430 f.Printf("\t@$(call rm,$(OBJ)objects.lst)\n");
3431 f.Printf("\t@$(call touch,$(OBJ)objects.lst)\n");
3432 OutputFileListActions(f, "_OBJECTS", objectsParts, "$(OBJ)objects.lst");
3435 f.Puts("ifdef WINDOWS_TARGET\n");
3436 OutputFileListActions(f, "RCOBJECTS", rcSourcesParts, "$(OBJ)objects.lst");
3441 f.Printf("\t$(call addtolistfile,$(OBJ)$(MODULE).main$(O),$(OBJ)objects.lst)\n");
3442 OutputFileListActions(f, "ECOBJECTS", eCsourcesParts, "$(OBJ)objects.lst");
3445 f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
3447 f.Puts("\t$(LD) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
3448 if(!GetDebug(config))
3450 f.Puts("ifndef NOSTRIP\n");
3451 f.Puts("\t$(STRIP) $(STRIPOPT) $(TARGET)\n");
3454 if(GetCompress(config))
3456 f.Printf("ifndef %s\n", PlatformToMakefileTargetVariable(win32));
3457 f.Puts("ifdef EXECUTABLE_TARGET\n");
3458 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3461 //f.Puts("ifneq ($(TARGET_ARCH),x86_64)\n");
3462 f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
3463 //f.Puts("endif\n");
3467 if(resNode.files && resNode.files.count && !noResources)
3469 f.Puts("ifndef USE_RESOURCES_EAR\n");
3470 resNode.GenMakefileAddResources(f, resNode.path, config, "TARGET");
3474 f.Puts("ifdef WINDOWS_HOST\n");
3475 f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)objects.lst $(LIBS)\n");
3477 f.Puts("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
3480 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3481 f.Puts("ifdef LINUX_TARGET\n");
3482 f.Puts("ifdef LINUX_HOST\n");
3483 // TODO?: support symlinks for longer version numbers
3484 f.Puts("\t$(if $(basename $(VER)),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)),)\n");
3485 f.Puts("\t$(if $(VER),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO),)\n");
3490 //f.Puts("# POST-BUILD COMMANDS\n");
3491 if(options && options.postbuildCommands)
3493 for(s : options.postbuildCommands)
3494 if(s && s[0]) f.Printf("\t%s\n", s);
3496 if(config && config.options && config.options.postbuildCommands)
3498 for(s : config.options.postbuildCommands)
3499 if(s && s[0]) f.Printf("\t%s\n", s);
3501 if(platforms || (config && config.platforms))
3504 //f.Puts("# TARGET_PLATFORM-SPECIFIC POST-BUILD COMMANDS\n");
3505 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3507 PlatformOptions projectPOs, configPOs;
3508 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3510 if((projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count) ||
3511 (configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count))
3516 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3518 if(projectPOs && projectPOs.options.postbuildCommands && projectPOs.options.postbuildCommands.count)
3520 for(s : projectPOs.options.postbuildCommands)
3521 if(s && s[0]) f.Printf("\t%s\n", s);
3523 if(configPOs && configPOs.options.postbuildCommands && configPOs.options.postbuildCommands.count)
3525 for(s : configPOs.options.postbuildCommands)
3526 if(s && s[0]) f.Printf("\t%s\n", s);
3533 for(c = 0; c < ifCount; c++)
3540 if(platforms || (config && config.platforms))
3542 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3544 PlatformOptions projectPOs, configPOs;
3545 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3547 if((projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count) ||
3548 (configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count))
3555 if(test || (options && options.installCommands) ||
3556 (config && config.options && config.options.installCommands))
3558 f.Puts("install:\n");
3559 if(options && options.installCommands)
3561 for(s : options.installCommands)
3562 if(s && s[0]) f.Printf("\t%s\n", s);
3564 if(config && config.options && config.options.installCommands)
3566 for(s : config.options.installCommands)
3567 if(s && s[0]) f.Printf("\t%s\n", s);
3569 if(platforms || (config && config.platforms))
3572 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
3574 PlatformOptions projectPOs, configPOs;
3575 MatchProjectAndConfigPlatformOptions(config, platform, &projectPOs, &configPOs);
3577 if((projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count) ||
3578 (configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count))
3583 f.Printf("ifdef %s\n", PlatformToMakefileTargetVariable(platform));
3585 if(projectPOs && projectPOs.options.installCommands && projectPOs.options.installCommands.count)
3587 for(s : projectPOs.options.installCommands)
3588 if(s && s[0]) f.Printf("\t%s\n", s);
3590 if(configPOs && configPOs.options.installCommands && configPOs.options.installCommands.count)
3592 for(s : configPOs.options.installCommands)
3593 if(s && s[0]) f.Printf("\t%s\n", s);
3600 for(c = 0; c < ifCount; c++)
3607 f.Puts("# SYMBOL RULES\n");
3610 topNode.GenMakefilePrintSymbolRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3612 f.Puts("# C OBJECT RULES\n");
3615 topNode.GenMakefilePrintCObjectRules(f, this, config, nodeCFlagsMapping, nodeECFlagsMapping);
3617 f.Puts("# OBJECT RULES\n");
3619 // todo call this still but only generate rules whith specific options
3620 // see we-have-file-specific-options in ProjectNode.ec
3621 topNode.GenMakefilePrintObjectRules(f, this, namesInfo, config, nodeCFlagsMapping, nodeECFlagsMapping);
3624 GenMakefilePrintMainObjectRule(f, config);
3626 f.Printf("cleantarget: objdir%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
3629 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)");
3630 f.Printf("\t$(call rm,$(OBJ)symbols.lst)\n");
3632 f.Printf("\t$(call rm,$(OBJ)objects.lst)\n");
3633 f.Puts("\t$(call rm,$(TARGET))\n");
3634 f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
3635 f.Puts("ifdef LINUX_TARGET\n");
3636 f.Puts("ifdef LINUX_HOST\n");
3637 // TODO?: support symlinks for longer version numbers
3638 f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
3639 f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO))\n");
3645 f.Puts("clean: cleantarget\n");
3646 OutputCleanActions(f, "OBJECTS", objectsParts);
3649 f.Puts("ifdef WINDOWS_TARGET\n");
3650 OutputCleanActions(f, "RCOBJECTS", rcSourcesParts);
3655 OutputCleanActions(f, "ECOBJECTS", eCsourcesParts);
3656 OutputCleanActions(f, "COBJECTS", eCsourcesParts);
3657 OutputCleanActions(f, "BOWLS", eCsourcesParts);
3658 OutputCleanActions(f, "IMPORTS", eCsourcesParts);
3659 OutputCleanActions(f, "SYMBOLS", eCsourcesParts);
3661 if(resNode.files && resNode.files.count && !noResources)
3663 f.Puts("ifdef USE_RESOURCES_EAR\n");
3664 f.Printf("\t$(call rm,$(RESOURCES_EAR))\n");
3669 f.Puts("realclean: cleantarget\n");
3670 f.Puts("\t$(call rmr,$(OBJ))\n");
3671 if(!sameOrRelObjTargetDirs)
3672 f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
3675 f.Puts("distclean: cleantarget\n");
3676 if(!sameOrRelObjTargetDirs)
3677 f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
3679 f.Puts("\t$(call rmr,obj/)\n");
3680 f.Puts("\t$(call rmr,.configs/)\n");
3681 f.Puts("\t$(call rm,*.ews)\n");
3682 f.Puts("\t$(call rm,*.Makefile)\n");
3688 varStringLenDiffs.Free();
3689 delete varStringLenDiffs;
3693 delete cflagsVariations;
3694 delete nodeCFlagsMapping;
3695 delete ecflagsVariations;
3696 delete nodeECFlagsMapping;
3701 // ChangeWorkingDir(oldDirectory);
3702 // delete pathBackup;
3705 config.makingModified = false;
3709 void GenMakefilePrintMainObjectRule(File f, ProjectConfig config)
3711 char extension[MAX_EXTENSION] = "c";
3712 //char modulePath[MAX_LOCATION];
3713 char fixedModuleName[MAX_FILENAME];
3715 //char command[2048];
3716 char objDirNoSpaces[MAX_LOCATION];
3717 const String objDirExp = GetObjDirExpression(config);
3719 ReplaceSpaces(objDirNoSpaces, objDirExp);
3720 ReplaceSpaces(fixedModuleName, moduleName);
3722 //sprintf(fixedModuleName, "%s.main", fixedPrjName);
3723 //strcat(fixedModuleName, ".main");
3725 #if 0 // TODO: Fix nospaces stuff
3726 // *** Dependency command ***
3727 sprintf(command, "gcc -MT $(OBJ)%s$(O) -MM $(OBJ)%s.c", fixedModuleName, fixedModuleName);
3729 // System Includes (from global settings)
3730 for(item : compiler.dirs[Includes])
3732 strcat(command, " -isystem ");
3733 if(strchr(item.name, ' '))
3735 strcat(command, "\"");
3736 strcat(command, item);
3737 strcat(command, "\"");
3740 strcat(command, item);
3743 for(item = includeDirs.first; item; item = item.next)
3745 strcat(command, " -I");
3746 if(strchr(item.name, ' '))
3748 strcat(command, "\"");
3749 strcat(command, item.name);
3750 strcat(command, "\"");
3753 strcat(command, item.name);
3755 for(item = preprocessorDefs.first; item; item = item.next)
3757 strcat(command, " -D");
3758 strcat(command, item.name);
3762 if((dep = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
3766 bool firstLine = true;
3768 // To do some time: auto save external dependencies?
3771 if(dep.GetLine(line, sizeof(line)-1))
3775 char * colon = strstr(line, ":");
3776 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
3790 // If we failed to generate dependencies...
3794 f.Puts("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
3795 f.Printf("\t$(CC) $(CFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(call quote_path,$@)\n", extension);
3803 void GenMakePrintCustomFlags(File f, const String variableName, bool printNonCustom, Map<String, int> cflagsVariations)
3806 for(c = printNonCustom ? 0 : 1; c <= cflagsVariations.count; c++)
3808 for(v : cflagsVariations)
3813 f.Printf("%s +=", variableName);
3815 f.Printf("CUSTOM%d_%s =", v-1, variableName);
3816 f.Puts(&v ? &v : "");
3824 void MatchProjectAndConfigPlatformOptions(ProjectConfig config, Platform platform,
3825 PlatformOptions * projectPlatformOptions, PlatformOptions * configPlatformOptions)
3827 *projectPlatformOptions = null;
3828 *configPlatformOptions = null;
3833 if(!strcmpi(p.name, platform))
3835 *projectPlatformOptions = p;
3840 if(config && config.platforms)
3842 for(p : config.platforms)
3844 if(!strcmpi(p.name, platform))
3846 *configPlatformOptions = p;
3854 static inline void ProjectLoadLastBuildNamesInfo(Project prj, ProjectConfig cfg)
3856 const char * cfgName = cfg ? cfg.name : "";
3857 Map<String, NameCollisionInfo> cfgNameCollisions = prj.configsNameCollisions[cfgName];
3858 if(cfgNameCollisions)
3860 cfgNameCollisions.Free();
3861 delete cfgNameCollisions;
3863 prj.configsNameCollisions[cfgName] = cfgNameCollisions = { };
3864 prj.topNode.GenMakefileGetNameCollisionInfo(cfgNameCollisions, cfg);
3867 Project LegacyBinaryLoadProject(File f, const char * filePath)
3869 Project project = null;
3870 char signature[sizeof(epjSignature)];
3872 f.Read(signature, sizeof(signature), 1);
3873 if(!strncmp(signature, (char *)epjSignature, sizeof(epjSignature)))
3875 char topNodePath[MAX_LOCATION];
3876 /*ProjectConfig newConfig
3878 name = CopyString("Default");
3879 makingModified = true;
3880 compilingModified = true;
3881 linkingModified = true;
3885 project = Project { options = { } };
3886 LegacyBinaryLoadNode(project.topNode, f);
3887 delete project.topNode.path;
3888 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
3889 MakeSlashPath(topNodePath);
3891 PathCatSlash(topNodePath, filePath);
3892 project.filePath = topNodePath;
3894 /* THIS IS ALREADY DONE BY filePath property
3895 StripLastDirectory(topNodePath, topNodePath);
3896 project.topNode.path = CopyString(topNodePath);
3898 // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
3900 // newConfig.options.defaultNameSpace = "";
3901 /*newConfig.objDir.dir = "obj";
3902 newConfig.targetDir.dir = "";*/
3904 //project.configurations = { [ newConfig ] };
3905 //project.config = newConfig;
3912 String targetFileName, targetDirectory, objectsDirectory;
3914 // { executable = 0, sharedLibrary = 1, staticLibrary = 2 };
3915 f.Read(&temp, sizeof(int),1);
3918 case 0: project.options.targetType = executable; break;
3919 case 1: project.options.targetType = sharedLibrary; break;
3920 case 2: project.options.targetType = staticLibrary; break;
3923 f.Read(&len, sizeof(int),1);
3924 targetFileName = new char[len+1];
3925 f.Read(targetFileName, sizeof(char), len+1);
3926 project.options.targetFileName = targetFileName;
3927 delete targetFileName;
3929 f.Read(&len, sizeof(int),1);
3930 targetDirectory = new char[len+1];
3931 f.Read(targetDirectory, sizeof(char), len+1);
3932 project.options.targetDirectory = targetDirectory;
3933 delete targetDirectory;
3935 f.Read(&len, sizeof(int),1);
3936 objectsDirectory = new byte[len+1];
3937 f.Read(objectsDirectory, sizeof(char), len+1);
3938 project.options.objectsDirectory = objectsDirectory;
3939 delete objectsDirectory;
3941 f.Read(&temp, sizeof(int),1);
3942 project./*config.*/options.debug = temp ? true : false;
3943 f.Read(&temp, sizeof(int),1);
3944 project./*config.*/options.optimization = temp ? speed : none;
3945 f.Read(&temp, sizeof(int),1);
3946 project./*config.*/options.profile = temp ? true : false;
3947 f.Read(&temp, sizeof(int),1);
3948 project.options.warnings = temp ? all : unset;
3950 f.Read(&count, sizeof(int),1);
3953 project.options.includeDirs = { };
3954 for(c = 0; c < count; c++)
3957 f.Read(&len, sizeof(int),1);
3958 name = new char[len+1];
3959 f.Read(name, sizeof(char), len+1);
3960 project.options.includeDirs.Add(name);
3964 f.Read(&count, sizeof(int),1);
3967 project.options.libraryDirs = { };
3968 for(c = 0; c < count; c++)
3971 f.Read(&len, sizeof(int),1);
3972 name = new char[len+1];
3973 f.Read(name, sizeof(char), len+1);
3974 project.options.libraryDirs.Add(name);
3978 f.Read(&count, sizeof(int),1);
3981 project.options.libraries = { };
3982 for(c = 0; c < count; c++)
3985 f.Read(&len, sizeof(int),1);
3986 name = new char[len+1];
3987 f.Read(name, sizeof(char), len+1);
3988 project.options.libraries.Add(name);
3992 f.Read(&count, sizeof(int),1);
3995 project.options.preprocessorDefinitions = { };
3996 for(c = 0; c < count; c++)
3999 f.Read(&len, sizeof(int),1);
4000 name = new char[len+1];
4001 f.Read(name, sizeof(char), len+1);
4002 project.options.preprocessorDefinitions.Add(name);
4006 f.Read(&temp, sizeof(int),1);
4007 project.options.console = temp ? true : false;
4010 for(node : project.topNode.files)
4012 if(node.type == resources)
4014 project.resNode = node;
4024 void ProjectConfig::LegacyProjectConfigLoad(File f)
4032 char subSection[128];
4037 f.GetLine(buffer, 65536 - 1);
4038 TrimLSpaces(buffer, buffer);
4039 TrimRSpaces(buffer, buffer);
4042 if(buffer[0] == '-')
4046 TrimLSpaces(equal, equal);
4047 if(!strcmpi(subSection, "LibraryDirs"))
4049 if(!options.libraryDirs)
4050 options.libraryDirs = { [ CopyString(equal) ] };
4052 options.libraryDirs.Add(CopyString(equal));
4054 else if(!strcmpi(subSection, "IncludeDirs"))
4056 if(!options.includeDirs)
4057 options.includeDirs = { [ CopyString(equal) ] };
4059 options.includeDirs.Add(CopyString(equal));
4062 else if(buffer[0] == '+')
4073 TrimLSpaces(equal, equal);
4074 delete name; name = CopyString(equal); // property::name = equal;
4077 else if(!strcmpi(buffer, "Compiler Options"))
4078 strcpy(section, buffer);
4079 else if(!strcmpi(buffer, "IncludeDirs"))
4080 strcpy(subSection, buffer);
4081 else if(!strcmpi(buffer, "Linker Options"))
4082 strcpy(section, buffer);
4083 else if(!strcmpi(buffer, "LibraryDirs"))
4084 strcpy(subSection, buffer);
4085 else if(!strcmpi(buffer, "Files") || !strcmpi(buffer, "Resources"))
4092 equal = strstr(buffer, "=");
4096 TrimRSpaces(buffer, buffer);
4098 TrimLSpaces(equal, equal);
4099 if(!strcmpi(buffer, "Target Name"))
4100 options.targetFileName = /*CopyString(*/equal/*)*/;
4101 else if(!strcmpi(buffer, "Target Type"))
4103 if(!strcmpi(equal, "Executable"))
4104 options.targetType = executable;
4105 else if(!strcmpi(equal, "Shared"))
4106 options.targetType = sharedLibrary;
4107 else if(!strcmpi(equal, "Static"))
4108 options.targetType = staticLibrary;
4110 options.targetType = executable;
4112 else if(!strcmpi(buffer, "Target Directory"))
4113 options.targetDirectory = /*CopyString(*/equal/*)*/;
4114 else if(!strcmpi(buffer, "Console"))
4115 options.console = ParseTrueFalseValue(equal);
4116 else if(!strcmpi(buffer, "Libraries"))
4118 if(!options.libraries) options.libraries = { };
4119 ParseArrayValue(options.libraries, equal);
4121 else if(!strcmpi(buffer, "Intermediate Directory"))
4122 options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
4123 else if(!strcmpi(buffer, "Debug"))
4124 options.debug = ParseTrueFalseValue(equal);
4125 else if(!strcmpi(buffer, "Optimize"))
4127 if(!strcmpi(equal, "None"))
4128 options.optimization = none;
4129 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
4130 options.optimization = speed;
4131 else if(!strcmpi(equal, "Size"))
4132 options.optimization = size;
4134 options.optimization = none;
4136 else if(!strcmpi(buffer, "Compress"))
4137 options.compress = ParseTrueFalseValue(equal);
4138 else if(!strcmpi(buffer, "Profile"))
4139 options.profile = ParseTrueFalseValue(equal);
4140 else if(!strcmpi(buffer, "AllWarnings"))
4141 options.warnings = ParseTrueFalseValue(equal) ? all : unset;
4142 else if(!strcmpi(buffer, "MemoryGuard"))
4143 options.memoryGuard = ParseTrueFalseValue(equal);
4144 else if(!strcmpi(buffer, "Default Name Space"))
4145 options.defaultNameSpace = CopyString(equal);
4146 else if(!strcmpi(buffer, "Strict Name Spaces"))
4147 options.strictNameSpaces = ParseTrueFalseValue(equal);
4148 else if(!strcmpi(buffer, "Preprocessor Definitions"))
4150 if(!options.preprocessorDefinitions) options.preprocessorDefinitions = { };
4151 ParseArrayValue(options.preprocessorDefinitions, equal);
4157 if(!options.targetDirectory && options.objectsDirectory)
4158 options.targetDirectory = /*CopyString(*/options.objectsDirectory/*)*/;
4159 //if(!objDir.dir) objDir.dir = "obj";
4160 //if(!targetDir.dir) targetDir.dir = "";
4161 // if(!targetName) property::targetName = ""; // How can a targetFileName be nothing???
4162 // if(!defaultNameSpace) property::defaultNameSpace = "";
4163 makingModified = true;
4166 Project LegacyAsciiLoadProject(File f, const char * filePath)
4168 Project project = null;
4170 char parentPath[MAX_LOCATION];
4171 char section[128] = "";
4172 char subSection[128] = "";
4173 ProjectNode parent = null;
4174 bool configurationsPresent = false;
4184 f.GetLine(buffer, 65536 - 1);
4185 TrimLSpaces(buffer, buffer);
4186 TrimRSpaces(buffer, buffer);
4189 if(buffer[0] == '-' || buffer[0] == '=')
4191 bool simple = buffer[0] == '-';
4194 TrimLSpaces(equal, equal);
4195 if(!strcmpi(section, "Target") && !strcmpi(subSection, "LibraryDirs"))
4197 if(!project.config.options.libraryDirs)
4198 project.config.options.libraryDirs = { [ CopyString(equal) ] };
4200 project.config.options.libraryDirs.Add(CopyString(equal));
4202 else if(!strcmpi(section, "Target") && !strcmpi(subSection, "IncludeDirs"))
4204 if(!project.config.options.includeDirs)
4205 project.config.options.includeDirs = { [ CopyString(equal) ] };
4207 project.config.options.includeDirs.Add(CopyString(equal));
4209 else if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
4211 len = strlen(equal);
4214 char temp[MAX_LOCATION];
4215 ProjectNode child { };
4216 // We don't need to do this anymore, fileName is just a property that sets name & path
4217 // child.fileName = CopyString(equal);
4220 child.name = CopyString(equal);
4221 child.path = CopyString(parentPath);
4225 GetLastDirectory(equal, temp);
4226 child.name = CopyString(temp);
4227 StripLastDirectory(equal, temp);
4228 child.path = CopyString(temp);
4230 child.nodeType = file;
4231 child.parent = parent;
4232 child.indent = parent.indent + 1;
4234 child.icon = NodeIcons::SelectFileIcon(child.name);
4235 parent.files.Add(child);
4241 StripLastDirectory(parentPath, parentPath);
4242 parent = parent.parent;
4246 else if(buffer[0] == '+')
4250 TrimLSpaces(equal, equal);
4251 if(!strcmpi(section, "Target") && (!strcmpi(subSection, "Files") || !strcmpi(subSection, "Resources")))
4253 char temp[MAX_LOCATION];
4254 ProjectNode child { };
4255 // NEW: Folders now have a path set like files
4256 child.name = CopyString(equal);
4257 strcpy(temp, parentPath);
4258 PathCatSlash(temp, child.name);
4259 child.path = CopyString(temp);
4261 child.parent = parent;
4262 child.indent = parent.indent + 1;
4263 child.type = folder;
4264 child.nodeType = folder;
4266 child.icon = folder;
4267 PathCatSlash(parentPath, child.name);
4268 parent.files.Add(child);
4273 else if(!strcmpi(section, "Configurations"))
4275 ProjectConfig newConfig
4277 makingModified = true;
4281 LegacyProjectConfigLoad(newConfig, f);
4282 project.configurations.Add(newConfig);
4285 else if(!strcmpi(buffer, "ECERE Project File"));
4286 else if(!strcmpi(buffer, "Version 0a"))
4287 ; //strcpy(version, "0a");
4288 else if(!strcmpi(buffer, "Version 0.1a"))
4289 ; //strcpy(version, "0.1a");
4290 else if(!strcmpi(buffer, "Configurations"))
4292 project.configurations.Free();
4293 project.config = null;
4294 strcpy(section, buffer);
4295 configurationsPresent = true;
4297 else if(!strcmpi(buffer, "Target") || !strnicmp(buffer, "Target \"", strlen("Target \"")))
4299 ProjectConfig newConfig { name = CopyString("Default"), options = { } };
4300 char topNodePath[MAX_LOCATION];
4301 // newConfig.defaultNameSpace = "";
4302 //newConfig.objDir.dir = "obj";
4303 //newConfig.targetDir.dir = "";
4304 project = Project { /*options = { }*/ };
4305 project.configurations = { [ newConfig ] };
4306 project.config = newConfig;
4307 // if(project.topNode.path) delete project.topNode.path;
4308 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
4309 MakeSlashPath(topNodePath);
4310 PathCatSlash(topNodePath, filePath);
4311 project.filePath = topNodePath;
4312 parentPath[0] = '\0';
4313 parent = project.topNode;
4315 strcpy(section, "Target");
4320 if(equal[0] == '\"')
4322 StripQuotes(equal, equal);
4323 delete project.moduleName; project.moduleName = CopyString(equal);
4327 else if(!strcmpi(buffer, "Compiler Options"));
4328 else if(!strcmpi(buffer, "IncludeDirs"))
4329 strcpy(subSection, buffer);
4330 else if(!strcmpi(buffer, "Linker Options"));
4331 else if(!strcmpi(buffer, "LibraryDirs"))
4332 strcpy(subSection, buffer);
4333 else if(!strcmpi(buffer, "Files"))
4335 strcpy(section, "Target");
4336 strcpy(subSection, buffer);
4338 else if(!strcmpi(buffer, "Resources"))
4340 ProjectNode child { };
4341 parent.files.Add(child);
4342 child.parent = parent;
4343 child.indent = parent.indent + 1;
4344 child.name = CopyString(buffer);
4345 child.path = CopyString("");
4346 child.type = resources;
4348 child.icon = archiveFile;
4349 project.resNode = child;
4352 strcpy(subSection, buffer);
4356 equal = strstr(buffer, "=");
4360 TrimRSpaces(buffer, buffer);
4362 TrimLSpaces(equal, equal);
4364 if(!strcmpi(section, "Target"))
4366 if(!strcmpi(buffer, "Build Exclusions"))
4368 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
4370 /*if(node && node.type != NodeTypes::project)
4371 ParseListValue(node.buildExclusions, equal);*/
4374 else if(!strcmpi(buffer, "Path") && !strcmpi(subSection, "Resources"))
4376 delete project.resNode.path;
4377 project.resNode.path = CopyString(equal);
4378 PathCatSlash(parentPath, equal);
4382 else if(!strcmpi(buffer, "Intermediate Directory"))
4383 project.config.options.objectsDirectory = /*CopyString(*/equal/*)*/; //objDir.expression = equal;
4384 else if(!strcmpi(buffer, "Debug"))
4385 project.config.options.debug = ParseTrueFalseValue(equal);
4386 else if(!strcmpi(buffer, "Optimize"))
4388 if(!strcmpi(equal, "None"))
4389 project.config.options.optimization = none;
4390 else if(!strcmpi(equal, "Speed") || !strcmpi(equal, "True"))
4391 project.config.options.optimization = speed;
4392 else if(!strcmpi(equal, "Size"))
4393 project.config.options.optimization = size;
4395 project.config.options.optimization = none;
4397 else if(!strcmpi(buffer, "Profile"))
4398 project.config.options.profile = ParseTrueFalseValue(equal);
4399 else if(!strcmpi(buffer, "MemoryGuard"))
4400 project.config.options.memoryGuard = ParseTrueFalseValue(equal);
4403 if(!project.options) project.options = { };
4405 // Project Wide Settings (All configs)
4406 if(!strcmpi(buffer, "Target Name"))
4407 project.options.targetFileName = /*CopyString(*/equal/*)*/;
4408 else if(!strcmpi(buffer, "Target Type"))
4410 if(!strcmpi(equal, "Executable"))
4411 project.options.targetType = executable;
4412 else if(!strcmpi(equal, "Shared"))
4413 project.options.targetType = sharedLibrary;
4414 else if(!strcmpi(equal, "Static"))
4415 project.options.targetType = staticLibrary;
4417 project.options.targetType = executable;
4419 else if(!strcmpi(buffer, "Target Directory"))
4420 project.options.targetDirectory = /*CopyString(*/equal/*)*/;
4421 else if(!strcmpi(buffer, "Console"))
4422 project.options.console = ParseTrueFalseValue(equal);
4423 else if(!strcmpi(buffer, "Libraries"))
4425 if(!project.options.libraries) project.options.libraries = { };
4426 ParseArrayValue(project.options.libraries, equal);
4428 else if(!strcmpi(buffer, "AllWarnings"))
4429 project.options.warnings = ParseTrueFalseValue(equal) ? all : unset;
4430 else if(!strcmpi(buffer, "Preprocessor Definitions"))
4432 if(!strcmpi(section, "Target") && !strcmpi(subSection, "Files"))
4434 /*if(node && (node.type == NodeTypes::project || (node.type == file && !node.isInResources) || node.type == folder))
4435 ParseListValue(node.preprocessorDefs, equal);*/
4439 if(!project.options.preprocessorDefinitions) project.options.preprocessorDefinitions = { };
4440 ParseArrayValue(project.options.preprocessorDefinitions, equal);
4451 SplitPlatformLibraries(project);
4453 if(configurationsPresent)
4454 CombineIdenticalConfigOptions(project);
4458 void SplitPlatformLibraries(Project project)
4460 if(project && project.configurations)
4462 for(cfg : project.configurations)
4464 if(cfg.options.libraries && cfg.options.libraries.count)
4466 Iterator<String> it { cfg.options.libraries };
4470 char * platformName = strstr(l, ":");
4473 PlatformOptions platform = null;
4475 if(!cfg.platforms) cfg.platforms = { };
4476 for(p : cfg.platforms)
4478 if(!strcmpi(platformName, p.name))
4486 platform = { name = CopyString(platformName), options = { libraries = { } } };
4487 cfg.platforms.Add(platform);
4489 *(platformName-1) = 0;
4490 platform.options.libraries.Add(CopyString(l));
4492 cfg.options.libraries.Delete(it.pointer);
4501 void CombineIdenticalConfigOptions(Project project)
4503 if(project && project.configurations && project.configurations.count)
4506 ProjectOptions nullOptions { };
4507 ProjectConfig firstConfig = null;
4508 for(cfg : project.configurations)
4510 if(cfg.options.targetType != staticLibrary)
4517 firstConfig = project.configurations.firstIterator.data;
4519 for(member = class(ProjectOptions).membersAndProperties.first; member; member = member.next)
4521 if(!member.isProperty)
4523 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
4528 for(cfg : project.configurations)
4530 if(cfg != firstConfig)
4532 if(cfg.options.targetType != staticLibrary)
4536 if(type.type == noHeadClass || type.type == normalClass)
4538 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4539 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4540 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4544 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4545 (byte *)firstConfig.options + member.offset + member._class.offset,
4546 (byte *)cfg.options + member.offset + member._class.offset);
4558 if(type.type == noHeadClass || type.type == normalClass)
4560 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4561 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4562 *(void **)((byte *)nullOptions + member.offset + member._class.offset)))
4567 if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4568 (byte *)firstConfig.options + member.offset + member._class.offset,
4569 (byte *)nullOptions + member.offset + member._class.offset))
4573 if(!project.options) project.options = { };
4575 /*if(type.type == noHeadClass || type.type == normalClass)
4577 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4578 (byte *)project.options + member.offset + member._class.offset,
4579 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
4583 void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
4584 // TOFIX: ListBox::SetData / OnCopy mess
4585 ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
4586 (byte *)project.options + member.offset + member._class.offset,
4587 (type.typeSize > 4) ? address :
4588 ((type.typeSize == 4) ? (void *)*(uint32 *)address :
4589 ((type.typeSize == 2) ? (void *)*(uint16*)address :
4590 (void *)*(byte *)address )));
4593 (byte *)project.options + member.offset + member._class.offset,
4594 (byte *)firstConfig.options + member.offset + member._class.offset, type.typeSize);
4596 for(cfg : project.configurations)
4598 if(cfg.options.targetType == staticLibrary)
4602 if(type.type == noHeadClass || type.type == normalClass)
4604 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4605 *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
4606 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4610 result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
4611 (byte *)firstConfig.options + member.offset + member._class.offset,
4612 (byte *)cfg.options + member.offset + member._class.offset);
4617 if(cfg != firstConfig)
4619 if(type.type == noHeadClass || type.type == normalClass)
4621 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4622 *(void **)((byte *)cfg.options + member.offset + member._class.offset));
4626 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
4627 (byte *)cfg.options + member.offset + member._class.offset);
4629 memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
4632 memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
4639 // Compare Platform Specific Settings
4642 for(cfg : project.configurations)
4644 if(cfg != firstConfig && cfg.options.targetType != staticLibrary && (firstConfig.platforms || cfg.platforms) &&
4645 ((!firstConfig.platforms && cfg.platforms) || firstConfig.platforms.OnCompare(cfg.platforms)))
4651 if(same && firstConfig.platforms)
4653 for(cfg : project.configurations)
4655 if(cfg.options.targetType == staticLibrary && firstConfig.platforms.OnCompare(cfg.platforms))
4657 if(cfg != firstConfig)
4659 cfg.platforms = null;
4662 project.platforms = firstConfig.platforms;
4663 *&firstConfig.platforms = null;
4667 // Static libraries can't contain libraries
4668 for(cfg : project.configurations)
4670 if(cfg.options.targetType == staticLibrary)
4672 if(!cfg.options.libraries) cfg.options.libraries = { };
4673 cfg.options.libraries.Free();
4679 Project LoadProject(const char * filePath, const char * activeConfigName)
4681 Project project = null;
4682 File f = FileOpen(filePath, read);
4685 project = LegacyBinaryLoadProject(f, filePath);
4688 ECONParser parser { f = f };
4689 /*JSONResult result = */parser.GetObject(class(Project), &project);
4692 char insidePath[MAX_LOCATION];
4694 delete project.topNode.files;
4695 if(!project.files) project.files = { };
4696 project.topNode.files = project.files;
4699 char topNodePath[MAX_LOCATION];
4700 GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
4701 MakeSlashPath(topNodePath);
4702 PathCatSlash(topNodePath, filePath);
4703 project.filePath = topNodePath;//filePath;
4706 project.topNode.FixupNode(insidePath);
4708 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4709 delete project.resNode.path;
4710 project.resNode.path = project.resourcesPath;
4711 project.resourcesPath = null;
4712 project.resNode.nodeType = (ProjectNodeType)-1;
4713 delete project.resNode.files;
4714 project.resNode.files = project.resources;
4715 project.files = null;
4716 project.resources = null;
4717 if(!project.configurations) project.configurations = { };
4719 project.resNode.FixupNode(insidePath);
4724 project = LegacyAsciiLoadProject(f, filePath);
4730 if(!project.options) project.options = { };
4731 if(activeConfigName && activeConfigName[0] && project.configurations)
4732 project.config = project.GetConfig(activeConfigName);
4733 if(!project.config && project.configurations)
4734 project.config = project.configurations.firstIterator.data;
4736 if(!project.resNode)
4738 project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
4741 if(!project.moduleName)
4742 project.moduleName = CopyString(project.name);
4743 if(project.config &&
4744 (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
4745 (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
4747 //delete project.config.options.targetFileName;
4749 project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
4750 project.config.options.optimization = none;
4751 project.config.options.debug = true;
4752 //project.config.options.warnings = unset;
4753 project.config.options.memoryGuard = false;
4754 project.config.compilingModified = true;
4755 project.config.linkingModified = true;
4757 else if(!project.topNode.name && project.config)
4759 project.topNode.name = CopyString(project.config.options.targetFileName);
4762 /* // THIS IS NOW AUTOMATED WITH A project CHECK IN ProjectNode
4763 project.topNode.configurations = project.configurations;
4764 project.topNode.platforms = project.platforms;
4765 project.topNode.options = project.options;*/
4771 #if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
4772 static GccVersionInfo GetGccVersionInfo(CompilerConfig compiler, const String compilerCommand)
4774 GccVersionInfo result = unknown;
4775 if(compiler.ccCommand)
4777 char command[MAX_F_STRING*4];
4779 sprintf(command, "%s%s --version", compiler.gccPrefix ? compiler.gccPrefix : "", compilerCommand);
4780 if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
4782 bool firstLine = true;
4787 if(f.GetLine(line,sizeof(line)))
4791 uint count = Tokenize(line, sizeof(tokens)/sizeof(tokens[0]), tokens,false);
4792 char * token = null;
4795 for(i = 0; i < count; i++)
4797 if(tokens[i][0] == '(')
4799 if(tokens[i][strlen(tokens[i])-1] != ')')
4802 else if(tokens[i][0] && tokens[i][strlen(tokens[i])-1] == ')')
4804 else if(!inPar && isdigit(tokens[i][0]) && strchr(tokens[i], '.'))
4808 result = GccVersionInfo::GetVersionInfo(token);
4819 static enum GccVersionInfo
4821 unknown, pre4_8, post4_8;
4823 GccVersionInfo ::GetVersionInfo(char * version)
4825 GccVersionInfo result = unknown;
4827 char * s = CopyString(version);
4829 uint count = TokenizeWith(s, sizeof(tokens)/sizeof(tokens[0]), tokens, ".", false);
4830 ver = count > 1 ? atoi(tokens[1]) : 0;
4831 ver += count ? atoi(tokens[0]) * 1000 : 0;