1 #ifndef MAKEFILE_GENERATOR
12 static define app = ((GuiApplication)__thisModule);
15 bool eString_PathInsideOfMore(char * path, char * of, char * pathRest)
17 if(!path[0] || !of[0])
18 return false; // What to do here? Ever used?
21 char ofPart[MAX_FILENAME], ofRest[MAX_LOCATION];
22 char pathPart[MAX_FILENAME]; //, pathRest[MAX_LOCATION];
24 strcpy(pathRest, path);
25 for(; ofRest[0] && pathRest[0];)
27 SplitDirectory(ofRest, ofPart, ofRest);
28 SplitDirectory(pathRest, pathPart, pathRest);
29 if(fstrcmp(pathPart, ofPart))
32 if(!ofRest[0] && !pathRest[0])
34 else if(!pathRest[0]) // not inside of, it's the other way around
40 enum NodeTypes { project, file, folder, resources, folderOpen };
43 genFile, ewsFile, epjFile, folder, openFolder, ecFile, ehFile,
44 cFile, hFile, cppFile, hppFile, textFile, webFile, pictureFile, soundFile,
45 archiveFile, packageFile, opticalMediaImageFile, mFile;
47 NodeIcons ::SelectFileIcon(char * filePath)
50 if(filePath && filePath[0])
52 char extension[MAX_EXTENSION];
53 GetExtension(filePath, extension);
56 if(!strcmpi(extension, WorkspaceExtension))
58 else if(!strcmpi(extension, ProjectExtension))
60 else if(!strcmpi(extension, "ec"))
62 else if(!strcmpi(extension, "eh"))
64 else if(!strcmpi(extension, "cpp") || !strcmpi(extension, "cc") ||
65 !strcmpi(extension, "cxx"))
67 else if(!strcmpi(extension, "hpp") || !strcmpi(extension, "hh") ||
68 !strcmpi(extension, "hxx"))
70 else if(!strcmpi(extension, "c"))
72 else if(!strcmpi(extension, "h"))
74 else if(!strcmpi(extension, "m"))
76 else if(!strcmpi(extension, "txt") || !strcmpi(extension, "text") ||
77 !strcmpi(extension, "nfo") || !strcmpi(extension, "info"))
79 else if(!strcmpi(extension, "htm") || !strcmpi(extension, "html") ||
80 !strcmpi(extension, "css") || !strcmpi(extension, "php") ||
81 !strcmpi(extension, "js"))
83 else if(!strcmpi(extension, "bmp") || !strcmpi(extension, "pcx") ||
84 !strcmpi(extension, "jpg") || !strcmpi(extension, "jpeg") ||
85 !strcmpi(extension, "gif") || !strcmpi(extension, "png") ||
86 !strcmpi(extension, "ico"))
88 else if(!strcmpi(extension, "wav") || !strcmpi(extension, "mp3") ||
89 !strcmpi(extension, "ogg") || !strcmpi(extension, "snd"))
91 else if(!strcmpi(extension, "ear") || !strcmpi(extension, "7z") ||
92 !strcmpi(extension, "rar") || !strcmpi(extension, "zip") ||
93 !strcmpi(extension, "gz") || !strcmpi(extension, "bz2") ||
94 !strcmpi(extension, "tar") || !strcmpi(extension, "arj") ||
95 !strcmpi(extension, "lza") || !strcmpi(extension, "lzh") ||
96 !strcmpi(extension, "cpio") || !strcmpi(extension, "z"))
98 else if(!strcmpi(extension, "cab") || !strcmpi(extension, "deb") ||
99 !strcmpi(extension, "rpm"))
101 else if(!strcmpi(extension, "iso") || !strcmpi(extension, "mds") ||
102 !strcmpi(extension, "cue") || !strcmpi(extension, "bin") ||
103 !strcmpi(extension, "ccd") || !strcmpi(extension, "bwt") ||
104 !strcmpi(extension, "cdi") || !strcmpi(extension, "nrg"))
105 icon = opticalMediaImageFile;
113 icon = genFile; // tocheck: error icon?
117 NodeIcons ::SelectNodeIcon(NodeTypes type)
136 #define SELECTION_COLOR Color { 10, 36, 106 }
142 // this is so not working, why!
144 // return result was not even executed (did not step on while debugging)
145 class TwoStrings : struct
165 class ProjectNode : ListItem
170 set { return { fileName = value }; }
171 // TOCHECK: Is this isset necessary at all?
172 isset { return nodeType == file && !options && !configurations && !platforms && !files; }
174 property String folder
179 if(strchr(value, '/'))
181 char p[MAX_LOCATION];
182 char n[MAX_FILENAME];
183 GetLastDirectory(value, n);
184 StripLastDirectory(value, p);
185 name = CopyString(n);
186 path = CopyString(p);
189 name = CopyString(value);
193 // TOCHECK: Non Reentrant
194 static char insidePath[MAX_LOCATION];
196 strcpy(insidePath, (parent.type == project) ? "" : parent.path);
197 PathCatSlash(insidePath, name);
199 if(!fstrcmp(path, insidePath))
203 strcpy(insidePath, path);
204 if(!insidePath[0]) strcpy(insidePath, ".");
205 PathCatSlash(insidePath, name);
209 isset { return nodeType == folder; }
211 property String fileName
216 if(strchr(value, '/'))
218 char p[MAX_LOCATION];
219 char n[MAX_FILENAME];
220 GetLastDirectory(value, n);
221 StripLastDirectory(value, p);
222 name = CopyValidateMakefilePath(n);
223 path = CopyValidateMakefilePath(p);
226 name = CopyValidateMakefilePath(value);
230 // TOCHECK: Non Reentrant
231 static char insidePath[MAX_LOCATION];
233 strcpy(insidePath, (parent.type == project) ? "" : parent.path);
234 if(!fstrcmp(path, insidePath))
238 strcpy(insidePath, path);
239 if(!insidePath[0]) strcpy(insidePath, ".");
240 PathCatSlash(insidePath, name);
244 isset { return nodeType == file && (options || configurations || platforms); }
247 LinkList<ProjectNode> files;
248 property ProjectOptions options
250 get { return project ? project.options : options; }
251 set { if(project) { delete project.options; project.options = value; } else { delete options; options = value; } }
252 isset { ProjectOptions options = project ? project.options : this.options; return options && !options.isEmpty; }
254 property Array<PlatformOptions> platforms
256 get { return project ? project.platforms : platforms; }
259 if(project) { project.platforms = value; }
262 if(platforms) { platforms.Free(); delete platforms; }
265 List<PlatformOptions> empty { };
266 Iterator<PlatformOptions> it { value };
268 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
269 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
276 Array<PlatformOptions> platforms = project ? project.platforms : this.platforms;
281 if(p.options && !p.options.isEmpty)
288 property List<ProjectConfig> configurations
290 get { return project ? project.configurations : configurations; }
295 if(project.configurations)
297 project.configurations.Free();
298 delete project.configurations;
300 project.configurations = value;
304 if(configurations) { configurations.Free(); delete configurations; }
307 List<ProjectConfig> empty { };
308 Iterator<ProjectConfig> it { value };
309 configurations = value;
310 for(c : configurations)
312 bool somethingSet = c.options && !c.options.isEmpty;
313 // TODO: Implement isset keyword
314 if(!somethingSet && c.platforms && c.platforms.count)
318 if(p.options && !p.options.isEmpty)
328 for(c : empty; it.Find(c)) configurations.Delete(it.pointer);
335 if(!parent) return true;
338 for(c : configurations)
340 bool somethingSet = c.options && !c.options.isEmpty;
341 if(!somethingSet && c.platforms && c.platforms.count)
345 if(p.options && !p.options.isEmpty)
360 ProjectOptions options;
361 Array<PlatformOptions> platforms;
362 List<ProjectConfig> configurations;
363 ProjectNodeType nodeType;
368 // This holds the absolute path of the .epj for the project topnode (without the filename)
369 // It holds a relative path to the topNode (project) for other nodes (folders and files)
370 // For folders, it includes the folder it refers to. If there is a name difference between the
371 // file system folder and the grouping folder of the project view, it maps to that folder.
381 // This is only set for Top Nodes
384 ProjectConfig GetMatchingNodeConfig(ProjectConfig prjConfig)
386 ProjectConfig nodeConfig = null;
387 if(property::configurations && prjConfig)
389 const char * configName = prjConfig.name;
390 for(cfg : property::configurations)
392 if(!strcmpi(cfg.name, configName))
402 // For makefile generation:
403 bool GetECFLAGS(ProjectConfig prjConfig)
405 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
406 ProjectOptions options = property::options;
407 SetBool memoryGuard = localMemoryGuard;
408 String defaultNameSpace = localDefaultNameSpace;
409 SetBool strictNameSpaces = localStrictNameSpaces;
410 SetBool noLineNumbers = localNoLineNumbers;
412 if(memoryGuard || defaultNameSpace || strictNameSpaces || noLineNumbers)
414 else if(parent.parent)
415 return parent.GetECFLAGS(prjConfig);
420 bool GetMemoryGuard(ProjectConfig prjConfig)
422 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
423 ProjectOptions options = property::options;
424 SetBool memoryGuard = localMemoryGuard;
428 return parent.GetMemoryGuard(prjConfig);
430 return memoryGuard == true;
433 String GetDefaultNameSpace(ProjectConfig prjConfig)
435 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
436 ProjectOptions options = property::options;
437 String defaultNameSpace = localDefaultNameSpace;
438 if(!defaultNameSpace)
441 return parent.GetDefaultNameSpace(prjConfig);
443 return defaultNameSpace;
446 bool GetStrictNameSpaces(ProjectConfig prjConfig)
448 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
449 ProjectOptions options = property::options;
450 SetBool strictNameSpaces = localStrictNameSpaces;
451 if(!strictNameSpaces)
454 return parent.GetStrictNameSpaces(prjConfig);
456 return strictNameSpaces == true;
459 bool GetNoLineNumbers(ProjectConfig prjConfig)
461 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
462 ProjectOptions options = property::options;
463 SetBool noLineNumbers = localNoLineNumbers;
467 return parent.GetNoLineNumbers(prjConfig);
469 return noLineNumbers == true;
472 property ProjectNode root { get { ProjectNode n; for(n = this; n.parent; n = n.parent); return n; } }
474 property bool containsFile
483 if(child.type == file ||
484 ((child.type == folder || child.type == folderOpen) && child.containsFile))
497 char * GetFullFilePath(char * buffer)
501 strcpy(buffer, root.path);
502 PathCatSlash(buffer, path);
503 PathCatSlash(buffer, name);
508 char * GetFileSysMatchingPath(char * buffer)
512 ProjectNode n, root = this.root;
513 for(n = this; n && (n.type == folder || n.type == project); n = n.parent)
515 strcpy(buffer, root.path);
517 PathCatSlash(buffer, n.path);
518 if(FileExists(buffer).isDirectory)
521 if(!(n && (n.type == folder || n.type == project)))
527 void CollectPerFileAndDirOptions(ProjectConfig prjConfig, Array<String> perFilePreprocessorDefs, Array<DirPath> perFileIncludeDirs)
529 ProjectNode node = null;
530 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
531 List<ProjectNode> nodeStack { };
533 for(node = this; node && node.parent; node = node.parent)
536 // Should we reverse this stack to give priority to the per-file includes? Does the following technique already reverse?
538 // TODO: Check how to fix duplication of following options when configuration is made per-config-per-file
539 while((node = nodeStack.lastIterator.data))
541 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
542 ProjectOptions nodeOptions = node.property::options;
543 if(nodeOptions && nodeOptions.preprocessorDefinitions)
545 for(def : nodeOptions.preprocessorDefinitions)
546 perFilePreprocessorDefs.Add(CopyString(def));
548 if(config && config.options && config.options.preprocessorDefinitions)
550 for(def : config.options.preprocessorDefinitions)
551 perFilePreprocessorDefs.Add(CopyString(def));
553 if(nodeOptions && nodeOptions.includeDirs)
555 for(dir : nodeOptions.includeDirs)
556 perFileIncludeDirs.Add(CopySystemPath(dir));
558 if(config && config.options && config.options.includeDirs)
560 for(dir : config.options.includeDirs)
561 perFileIncludeDirs.Add(CopySystemPath(dir));
563 nodeStack.lastIterator.Remove();
569 property Project project
573 ProjectNode n = this;
574 while(n && n.type != project) n = n.parent;
575 return n ? (*&n.project) : null;
579 void RenameConfig(char * oldName, char * newName)
583 for(f : files; (f.configurations || f.files)) { f.RenameConfig(oldName, newName); }
585 if(property::configurations)
587 for(c : property::configurations; !strcmp(c.name, oldName))
590 c.name = CopyString(newName);
595 void DeleteConfig(ProjectConfig configToDelete)
599 for(f : files; (f.configurations || f.files)) { f.DeleteConfig(configToDelete); }
601 if(property::configurations)
603 Iterator<ProjectConfig> c { property::configurations };
606 ProjectConfig config = c.data;
607 if(!strcmp(configToDelete.name, config.name))
614 if(!property::configurations.count)
615 property::configurations = null;
621 ProjectNode backupNode { };
625 backupNode.files = { };
626 for(f : files) backupNode.files.Add(f.Backup());
628 if(property::options)
629 backupNode.options = property::options.Copy();
631 if(property::platforms)
633 backupNode.platforms = { };
634 for(p : property::platforms)
635 backupNode.platforms.Add(p.Copy());
638 if(property::configurations)
640 backupNode.configurations = { };
641 for(c : property::configurations)
642 backupNode.configurations.Add(c.Copy());
647 void Revert(ProjectNode backupNode)
651 Iterator<ProjectNode> it { backupNode.files };
659 property::options = backupNode.options ? backupNode.options.Copy() : null;
660 if(backupNode.platforms)
662 Array<PlatformOptions> platforms { };
663 property::platforms = platforms;
665 for(p : backupNode.platforms)
666 platforms.Add(p.Copy());
668 if(backupNode.configurations)
670 List<ProjectConfig> configurations { };
671 property::configurations = configurations;
672 for(c : backupNode.configurations)
673 configurations.Add(c.Copy());
677 void FixupNode(char * parentPath)
683 else if(nodeType == file)
688 path = CopyString((parent.type == folder || parent.type == resources) ? parentPath : "");
691 else if(nodeType == folder)
697 char temp[MAX_LOCATION];
698 strcpy(temp, (parent.type == folder || parent.type == resources) ? parentPath : "");
699 PathCatSlash(temp, name);
700 path = CopyString(temp);
704 indent = parent ? parent.indent + 1 : 0;
707 icon = NodeIcons::SelectFileIcon(name);
709 icon = NodeIcons::SelectNodeIcon(type);
718 parentPath[0] = '\0';
719 else if(type == resources || type == folder)
720 strcpy(parentPath, path);
722 f.FixupNode(parentPath);
727 char * OnGetString(char * tempString, void * fieldData, bool * needClass)
731 // TOCHECK: Called from JSON writer
732 if(nodeType == file && !property::options && !property::configurations && !property::platforms && name)
734 strcpy(tempString, "\"");
735 strcat(tempString, property::fileName);
736 strcat(tempString, "\"");
743 // TOCHECK: Called from ProjectView rendering
744 return name ? name : "";
757 if(!project && platforms)
762 if(!project && configurations)
764 configurations.Free();
765 delete configurations;
768 /////////////////////////////
774 property bool isInResources
779 for(node = this; node; node = node.parent)
781 if(node.type == resources)
788 TwoStrings GetPlatformSpecificFu(ProjectConfig prjConfig)
790 TwoStrings result { a = CopyString(""), b = CopyString("") };
791 // note: unknown platform is for common
792 Map<Platform, SetBool> exclusionInfo { };
793 MapNode<Platform, SetBool> mn;
798 CollectExclusionInfo(exclusionInfo, prjConfig);
799 common = exclusionInfo[unknown];
801 Map<Platform, SetBool> cleaned { };
802 SetBool opposite = common == true ? false : true;
803 for(mn = exclusionInfo.root.minimum; mn; mn = mn.next)
805 if(mn.key == unknown || mn.value == opposite)
806 cleaned[mn.key] = mn.value;
808 delete exclusionInfo;
809 exclusionInfo = cleaned;
812 if(exclusionInfo.count > 1)
814 if(exclusionInfo.count > 2)
817 len = strlen(exp) + strlen("$(if $(or ");
818 exp = renew exp char[len+1];
819 strcat(exp, "$(if $(or ");
822 for(mn = exclusionInfo.root.minimum; mn; mn = mn.next)
824 if(mn.key != unknown)
826 char * comma = mn.next ? "," : "";
828 var = PlatformToMakefileVariable(mn.key);
831 len = strlen(exp) + strlen("$(") + strlen(var) + strlen(")") + strlen(comma);
832 exp = renew exp char[len+1];
842 len = strlen(exp) + strlen("),");
843 exp = renew exp char[len+1];
847 if(exclusionInfo.root.minimum.key != unknown)
848 var = PlatformToMakefileVariable(exclusionInfo.root.minimum.key);
850 var = PlatformToMakefileVariable(exclusionInfo.root.minimum.next.key);
853 len = strlen(exp) + strlen("$(if $(") + strlen(var) + strlen("),");
854 exp = renew exp char[len+1];
855 strcat(exp, "$(if $(");
862 exp = common == true ? result.b : result.a;
863 len = strlen(exp) + strlen(",");
864 exp = renew exp char[len+1];
866 if(common == true) result.b = exp; else result.a = exp;
869 len = strlen(exp) + strlen(")");
870 exp = renew exp char[len+1];
874 delete exclusionInfo;
879 bool GetIsExcluded(ProjectConfig prjConfig)
882 // note: unknown platform is for common
883 Map<Platform, SetBool> exclusionInfo { };
884 CollectExclusionInfo(exclusionInfo, prjConfig);
885 if(exclusionInfo.count == 0)
887 else if(exclusionInfo.count == 1)
888 result = exclusionInfo.root.minimum.value == true;
891 SetBool check = exclusionInfo.root.minimum.value;
892 MapNode<Platform, SetBool> mn;
893 for(mn = exclusionInfo.root.minimum; mn; mn = mn.next)
895 if(check != mn.value)
898 if(!mn) // all are same
899 result = check == true;
903 delete exclusionInfo;
907 void CollectExclusionInfo(Map<Platform, SetBool> output, ProjectConfig prjConfig)
909 // note: unknown platform is for common
911 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
912 ProjectOptions options = property::options;
913 Array<PlatformOptions> platforms = property::platforms;
914 List<ProjectConfig> configurations = property::configurations;
917 parent.CollectExclusionInfo(output, prjConfig);
919 output[unknown] = unset;
921 if(options && options.excludeFromBuild)
922 output[unknown] = options.excludeFromBuild;
924 if(config && config.options && config.options.excludeFromBuild)
925 output[unknown] = config.options.excludeFromBuild;
931 if(p.options.excludeFromBuild && (platform = p.name))
932 output[platform] = p.options.excludeFromBuild;
935 if(config && config.platforms)
937 for(p : config.platforms)
939 if(p.options.excludeFromBuild && (platform = p.name))
940 output[platform] = p.options.excludeFromBuild;
948 parent.EnsureVisible();
949 row.collapsed = false;
955 parent.files.Delete(this);
958 ProjectNode Find(char * name, bool includeResources)
960 ProjectNode result = null;
965 if(includeResources || child.type != resources)
967 if(child.type != folder && child.name && !strcmpi(child.name, name))
972 result = child.Find(name, includeResources);
981 ProjectNode FindWithPath(char * name, bool includeResources)
983 ProjectNode result = null;
988 if(includeResources || child.type != resources)
990 char path[MAX_LOCATION];
991 strcpy(path, child.path);
992 if(child.type != folder && child.name)
994 PathCatSlash(path, child.name);
995 if(!strcmpi(path, name))
1001 result = child.FindWithPath(name, includeResources);
1010 ProjectNode FindByFullPath(char * path, bool includeResources)
1012 ProjectNode result = null;
1017 if(includeResources || child.type != resources)
1019 if(child.type != folder && child.name)
1021 char p[MAX_LOCATION];
1022 child.GetFullFilePath(p);
1023 if(!strcmpi(p, path))
1029 result = child.FindByFullPath(path, includeResources);
1038 ProjectNode FindSpecial(char * name, bool recursive, bool includeResources, bool includeFolders)
1040 ProjectNode result = null;
1045 if(includeResources || child.type != resources)
1047 if((includeFolders || child.type != folder) && child.name && !strcmpi(child.name, name))
1053 result = child.FindSpecial(name, recursive, includeResources, includeFolders);
1062 ProjectNode FindSameNameConflict(char * name, bool includeResources,
1063 Map<Platform, SetBool> exclusionInfo, ProjectConfig prjConfig)
1065 ProjectNode result = null;
1066 Map<Platform, SetBool> compareExclusion { };
1067 SetBool common, commonComp;
1068 SetBool actual, actualComp;
1073 if(includeResources || child.type != resources)
1075 if(child.type != folder && child.name && !strcmpi(child.name, name))
1077 child.CollectExclusionInfo(compareExclusion, prjConfig);
1078 common = exclusionInfo[unknown];
1079 commonComp = compareExclusion[unknown];
1080 if(exclusionInfo.count == 1 && compareExclusion.count == 1)
1082 if(!(common == true || commonComp == true))
1091 for(platform = (Platform)1; platform < Platform::enumSize; platform++)
1094 actualComp = commonComp;
1095 if(exclusionInfo[platform] != unset)
1096 actual = exclusionInfo[platform];
1097 if(compareExclusion[platform] != unset)
1098 actualComp = compareExclusion[platform];
1099 if(!(actual == true || actualComp == true))
1107 compareExclusion.Free();
1110 result = child.FindSameNameConflict(name, includeResources, exclusionInfo, prjConfig);
1114 compareExclusion.Free();
1116 delete compareExclusion;
1120 ProjectNode Add(Project project, char * filePath, ProjectNode after, NodeTypes type, NodeIcons icon, bool checkIfExists)
1122 ProjectNode node = null;
1123 char temp[MAX_LOCATION];
1124 Map<Platform, SetBool> exclusionInfo { };
1126 GetLastDirectory(filePath, temp);
1127 //if(!checkIfExists || !project.topNode.Find(temp, false))
1129 // TOCHECK: Shouldn't this apply either for all configs or none?
1130 CollectExclusionInfo(exclusionInfo, project.config);
1131 if(!checkIfExists || !project.topNode.FindSameNameConflict(temp, false, exclusionInfo, project.config))
1133 // Do the check for folder in the same parent or resource files only here
1134 if(type == folder || !checkIfExists)
1138 if(node.name && !strcmpi(node.name, temp))
1143 node = ProjectNode { parent = this, indent = indent + 1, type = type, icon = icon, name = CopyString(temp) };
1147 node.nodeType = folder;
1153 StripLastDirectory(filePath, temp);
1154 MakePathRelative(temp, project.topNode.path, temp);
1155 node.path = CopyUnixPath(temp);
1157 node.nodeType = file;
1161 strcpy(temp, (type == NodeTypes::project) ? "" : path);
1162 PathCatSlash(temp, node.name);
1163 node.path = CopyString(temp);
1165 files.Insert(after, node);
1167 delete exclusionInfo;
1171 #ifndef MAKEFILE_GENERATOR
1172 void OnDisplay(Surface surface, int x, int y, int width, ProjectView projectView, Alignment alignment, DataDisplayFlags displayFlags)
1174 char label[MAX_FILENAME];
1180 bool showConfig = true;
1185 projectView = ide.projectView;
1188 bmp = projectView.icons[icon].bitmap;
1189 xStart = /*indent * indent + */x + (bmp ? (bmp.width + 5) : 0);
1191 GetLastDirectory(name, label);
1192 if(!showConfig || projectView.drawingInProjectSettingsDialogHeader)
1194 if(projectView.drawingInProjectSettingsDialogHeader || (type == project && info))
1196 if(projectView.projectSettingsDialog && projectView.projectSettingsDialog.buildTab)
1199 addendum = projectView.projectSettingsDialog.buildTab.selectedConfigName;
1200 if(strlen(addendum))
1202 strcat(label, " (");
1203 strcat(label, addendum);
1206 addendum = projectView.projectSettingsDialog.buildTab.selectedPlatformName;
1207 if(strlen(addendum))
1209 strcat(label, " (");
1210 strcat(label, addendum);
1216 else if(!projectView.drawingInProjectSettingsDialog)
1219 strcat(label, " *");
1220 if(type == project && info)
1222 int len = strlen(info) + 4;
1223 char * more = new char[len];
1224 sprintf(more, " (%s)", info);
1225 strcat(label, more);
1229 len = strlen(label);
1233 if(type == folder || type == folderOpen)
1234 surface.SetForeground(yellow);
1238 surface.TextOpacity(false);
1239 surface.TextExtent(label, len, &w, &h);
1242 // Draw the current row stipple
1243 if(displayFlags.selected)
1244 //surface.Area(xStart - 1, y, xStart - 1, y + h - 1);
1245 //surface.Area(xStart + w - 1, y, xStart + w + 1, y + h - 1);
1246 surface.Area(xStart - 3, y, xStart + w + 1, y + h - 1);
1248 surface.WriteTextDots(alignment, xStart, y + 2, width, label, len);
1252 if(displayFlags.current)
1254 if(displayFlags.active)
1256 surface.LineStipple(0x5555);
1257 if(displayFlags.selected)
1258 surface.SetForeground(projectView.fileList.stippleColor);
1260 surface.SetForeground(projectView.fileList.foreground);
1264 surface.SetForeground(SELECTION_COLOR);
1266 surface.Rectangle(xStart - 3, y, xStart + w + 1, y + h - 1);
1267 surface.LineStipple(0);
1272 surface.SetForeground(white);
1273 surface.Blit(bmp, x /*+ indent * indent*/,y,0,0, bmp.width, bmp.height);
1279 int OnCompare(ProjectNode b)
1282 if(type == b.type /*|| type >= TYPE_DRIVE*/)
1283 result = strcmpi(name, b.name);
1286 if(type == folder && b.type == file) result = -1;
1287 else if(type == file && b.type == folder) result = 1;
1292 bool ContainsFilesWithExtension(char * extension)
1296 char ext[MAX_EXTENSION];
1297 GetExtension(name, ext);
1298 if(!fstrcmp(ext, extension))
1303 bool needed = false;
1305 if(child.ContainsFilesWithExtension(extension))
1311 void GenFileFlags(File f, Project project, ProjectConfig prjConfig)
1313 ProjectNode node = null;
1314 List<ProjectNode> nodeStack { };
1316 for(node = this; node && node.parent; node = node.parent)
1317 nodeStack.Add(node);
1319 // Should we reverse this stack to give priority to the per-file includes?
1321 while((node = nodeStack.lastIterator.data))
1323 ProjectOptions nodeOptions = node.property::options;
1324 ProjectConfig config = node.GetMatchingNodeConfig(prjConfig);
1325 if(nodeOptions && nodeOptions.preprocessorDefinitions)
1326 OutputListOption(f, "D", nodeOptions.preprocessorDefinitions, inPlace, false);
1327 if(config && config.options && config.options.preprocessorDefinitions)
1328 OutputListOption(f, "D", config.options.preprocessorDefinitions, inPlace, false);
1329 if(nodeOptions && nodeOptions.includeDirs)
1330 OutputListOption(f, "I", nodeOptions.includeDirs, inPlace, true);
1331 if(config && config.options && config.options.includeDirs)
1332 OutputListOption(f, "I", config.options.includeDirs, inPlace, true);
1334 nodeStack.lastIterator.Remove();
1339 void GenMakefileGetNameCollisionInfo(Map<String, NameCollisionInfo> namesInfo, ProjectConfig prjConfig)
1343 char extension[MAX_EXTENSION];
1344 GetExtension(name, extension);
1345 if(!strcmpi(extension, "ec") || !strcmpi(extension, "c") ||
1346 !strcmpi(extension, "cpp") || !strcmpi(extension, "cc") ||
1347 !strcmpi(extension, "cxx") || !strcmpi(extension, "m"))
1349 char moduleName[MAX_FILENAME];
1350 NameCollisionInfo info;
1351 ReplaceSpaces(moduleName, name);
1352 StripExtension(moduleName);
1353 info = namesInfo[moduleName];
1355 info = NameCollisionInfo { };
1356 info.count++; // += 1; unless this is for a bug?
1357 if(!strcmpi(extension, "ec"))
1359 else if(!strcmpi(extension, "c"))
1361 else if(!strcmpi(extension, "cpp"))
1363 else if(!strcmpi(extension, "cc"))
1365 else if(!strcmpi(extension, "cxx"))
1367 else if(!strcmpi(extension, "m"))
1369 namesInfo[moduleName] = info;
1376 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1377 child.GenMakefileGetNameCollisionInfo(namesInfo, prjConfig);
1382 int GenMakefilePrintNode(File f, Project project, GenMakefilePrintTypes printType,
1383 Map<String, NameCollisionInfo> namesInfo, Array<String> items,
1384 ProjectConfig prjConfig)
1390 TwoStrings ts = GetPlatformSpecificFu(prjConfig);
1391 char moduleName[MAX_FILENAME];
1392 char extension[MAX_EXTENSION];
1393 GetExtension(name, extension);
1394 if(printType == resources)
1397 char tempPath[MAX_LOCATION];
1398 char modulePath[MAX_LOCATION];
1401 if(eString_PathInsideOfMore(path, project.resNode.path, tempPath))
1404 PathCatSlash(tempPath, name);
1409 strcpy(tempPath, path);
1410 PathCatSlash(tempPath, name);
1412 ReplaceSpaces(modulePath, tempPath);
1413 sprintf(s, "%s%s%s%s", ts.a, useRes ? "$(RES)" : "", modulePath, ts.b);
1414 items.Add(CopyString(s));
1416 else if(printType == sources)
1418 if(!strcmpi(extension, "c") || !strcmpi(extension, "cpp") ||
1419 !strcmpi(extension, "cc") || !strcmpi(extension, "cxx") ||
1420 !strcmpi(extension, "ec") || !strcmpi(extension, "m"))
1422 char modulePath[MAX_LOCATION];
1424 ReplaceSpaces(modulePath, path);
1425 ReplaceSpaces(moduleName, name);
1426 sprintf(s, "%s%s%s%s%s", ts.a, modulePath, path[0] ? SEPS : "", moduleName, ts.b);
1427 items.Add(CopyString(s));
1430 else if(!strcmpi(extension, "c") || !strcmpi(extension, "cpp") ||
1431 !strcmpi(extension, "cc") || !strcmpi(extension, "cxx") ||
1432 !strcmpi(extension, "m"))
1434 if(printType == objects)
1437 NameCollisionInfo info;
1438 ReplaceSpaces(moduleName, name);
1439 StripExtension(moduleName);
1440 info = namesInfo[moduleName];
1441 collision = info ? info.IsExtensionColliding(extension) : false;
1442 sprintf(s, "%s$(OBJ)%s%s%s.o%s", ts.a, moduleName, collision ? "." : "", collision ? extension : "", ts.b);
1443 items.Add(CopyString(s));
1446 else if(!strcmpi(extension, "ec"))
1448 ReplaceSpaces(moduleName, name);
1449 StripExtension(moduleName);
1450 if(printType == objects)
1453 if(printType == objects)
1454 sprintf(s, "%s$(OBJ)%s.o%s", ts.a, moduleName, ts.b);
1455 else if(printType == cObjects)
1456 sprintf(s, "%s$(OBJ)%s.c%s", ts.a, moduleName, ts.b);
1457 else if(printType == symbols)
1458 sprintf(s, "%s$(OBJ)%s.sym%s", ts.a, moduleName, ts.b);
1459 else if(printType == imports)
1460 sprintf(s, "%s$(OBJ)%s.imp%s", ts.a, moduleName, ts.b);
1462 items.Add(CopyString(s));
1470 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1471 count += child.GenMakefilePrintNode(f, project, printType, namesInfo, items, prjConfig);
1477 void GenMakefilePrintSymbolRules(File f, Project project, CompilerConfig compiler,
1478 ProjectConfig prjConfig, Map<Platform, bool> parentExcludedPlatforms)
1481 Array<Platform> platforms = GetPlatformsArrayFromExcluisionInfo(prjConfig);
1482 //ProjectNode child;
1483 //char objDir[MAX_LOCATION];
1484 //ReplaceSpaces(objDir, config.objDir.dir);
1486 //eSystem_Log("Printing Symbol Rules\n");
1489 char extension[MAX_EXTENSION];
1490 char modulePath[MAX_LOCATION];
1491 char moduleName[MAX_FILENAME];
1493 GetExtension(name, extension);
1494 if(!strcmpi(extension, "ec"))
1499 ReplaceSpaces(moduleName, name);
1500 StripExtension(moduleName);
1502 ReplaceSpaces(modulePath, path);
1503 if(modulePath[0]) strcat(modulePath, SEPS);
1506 // *** Dependency command ***
1507 sprintf(command, "gcc -MT $(OBJ)%s.o -MM %s%s.%s", moduleName,
1508 modulePath, moduleName, extension);
1510 // System Includes (from global settings)
1511 for(item : compiler.dirs[Includes])
1513 strcat(command, " -isystem ");
1514 if(strchr(item, ' '))
1516 strcat(command, "\"");
1517 strcat(command, item);
1518 strcat(command, "\"");
1521 strcat(command, item);
1524 for(item : project.includeDirs)
1526 strcat(command, " -I");
1527 if(strchr(item, ' '))
1529 strcat(command, "\"");
1530 strcat(command, item);
1531 strcat(command, "\"");
1534 strcat(command, item);
1536 for(item : project.preprocessorDefs)
1538 strcat(command, " -D");
1539 strcat(command, item);
1543 if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
1546 bool firstLine = true;
1549 // To do some time: auto save external dependencies?
1552 if(dep.GetLine(line, sizeof(line)-1))
1556 char * colon = strstr(line, ":");
1557 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
1571 // If we failed to generate dependencies...
1575 OpenRulesPlatformExclusionIfs(f, &ifCount, platforms[0], parentExcludedPlatforms, null);
1576 f.Printf("$(OBJ)%s.sym: %s%s.%s\n",
1577 moduleName, modulePath, moduleName, extension);
1583 f.Printf("\t$(ECP) %s%s.%s %s.sym\n\n",
1584 modulePath, moduleName, extension, moduleName);
1587 f.Printf("\t$(ECP)");
1588 // Give priority to file flags
1589 GenFileFlags(f, project, prjConfig);
1591 f.Printf(" $(CECFLAGS)");
1592 if(GetECFLAGS(prjConfig))
1594 if(GetMemoryGuard(prjConfig))
1595 f.Printf(" -memguard");
1596 if(GetStrictNameSpaces(prjConfig))
1597 f.Printf(" -strictns");
1599 char * s = GetDefaultNameSpace(prjConfig);
1601 f.Printf(" -defaultns %s", s);
1605 f.Printf(" $(ECFLAGS)");
1606 f.Printf(" $(CFLAGS)");
1608 f.Printf(" -c %s%s.%s -o $(OBJ)%s.sym\n\n",
1609 modulePath, moduleName, extension, moduleName);
1610 CloseRulesPlatformExclusionIfs(f, ifCount);
1615 bool needed = false;
1616 if(ContainsFilesWithExtension("ec"))
1620 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1629 Map<Platform, bool> excludedPlatforms { };
1630 for(mn : parentExcludedPlatforms) if(mn) excludedPlatforms[&mn] = true;
1631 for(platform : platforms)
1633 OpenRulesPlatformExclusionIfs(f, &ifCount, platform, parentExcludedPlatforms, excludedPlatforms);
1636 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1637 child.GenMakefilePrintSymbolRules(f, project, compiler, prjConfig, excludedPlatforms);
1640 CloseRulesPlatformExclusionIfs(f, ifCount);
1641 delete excludedPlatforms;
1647 void GenMakefilePrintPrepecsRules(File f, Project project, CompilerConfig compiler,
1648 ProjectConfig prjConfig, Map<Platform, bool> parentExcludedPlatforms)
1651 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
1652 Array<Platform> platforms = GetPlatformsArrayFromExcluisionInfo(prjConfig);
1653 //ProjectNode child;
1654 //char objDir[MAX_LOCATION];
1655 //ReplaceSpaces(objDir, config.objDir.dir);
1657 //eSystem_Log("Printing Symbol Rules\n");
1660 char extension[MAX_EXTENSION];
1661 char modulePath[MAX_LOCATION];
1662 char moduleName[MAX_FILENAME];
1664 GetExtension(name, extension);
1665 if(!strcmpi(extension, "ec"))
1670 ReplaceSpaces(moduleName, name);
1671 StripExtension(moduleName);
1673 ReplaceSpaces(modulePath, path);
1674 if(modulePath[0]) strcat(modulePath, SEPS);
1676 OpenRulesPlatformExclusionIfs(f, &ifCount, platforms[0], parentExcludedPlatforms, null);
1677 f.Printf("$(OBJ)%s$(EC): %s%s.%s\n",
1678 moduleName, modulePath, moduleName, extension);
1679 //$(CPP) -x c -E ../extras/gui/controls/DirectoriesBox.ec -o $(OBJ)DirectoriesBox$(EC)
1680 /*f.Printf("\t$(CPP) %s%s.%s %s$(S)\n\n",
1681 modulePath, moduleName, extension, moduleName);*/
1683 f.Printf("\t$(CPP)");
1684 // Give priority to file flags
1685 GenFileFlags(f, project, prjConfig);
1687 /*f.Printf(" $(CECFLAGS)");
1688 if(GetECFLAGS(prjConfig))
1690 if(GetMemoryGuard(prjConfig))
1691 f.Printf(" -memguard");
1692 if(GetStrictNameSpaces(prjConfig))
1693 f.Printf(" -strictns");
1695 char * s = GetDefaultNameSpace(prjConfig);
1697 f.Printf(" -defaultns %s", s);
1701 f.Printf(" $(ECFLAGS)");*/
1702 f.Printf(" $(CFLAGS)");
1704 f.Printf(" -x c -E %s%s.%s -o $(OBJ)%s$(EC)\n\n",
1705 modulePath, moduleName, extension, moduleName);
1706 CloseRulesPlatformExclusionIfs(f, ifCount);
1711 bool needed = false;
1712 if(ContainsFilesWithExtension("ec"))
1716 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1725 Map<Platform, bool> excludedPlatforms { };
1726 for(mn : parentExcludedPlatforms) if(mn) excludedPlatforms[&mn] = true;
1727 for(platform : platforms)
1729 OpenRulesPlatformExclusionIfs(f, &ifCount, platform, parentExcludedPlatforms, excludedPlatforms);
1732 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1733 child.GenMakefilePrintPrepecsRules(f, project, compiler, prjConfig, excludedPlatforms);
1736 CloseRulesPlatformExclusionIfs(f, ifCount);
1737 delete excludedPlatforms;
1743 void GenMakefilePrintCObjectRules(File f, Project project, CompilerConfig compiler,
1744 ProjectConfig prjConfig, Map<Platform, bool> parentExcludedPlatforms)
1747 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
1748 Array<Platform> platforms = GetPlatformsArrayFromExcluisionInfo(prjConfig);
1749 //ProjectNode child;
1750 //char objDir[MAX_LOCATION];
1751 //ReplaceSpaces(objDir, config.objDir.dir);
1752 //eSystem_Log("Printing C Object Rules\n");
1755 char extension[MAX_EXTENSION];
1756 char modulePath[MAX_LOCATION];
1757 char moduleName[MAX_FILENAME];
1759 GetExtension(name, extension);
1760 if(!strcmpi(extension, "ec"))
1765 ReplaceSpaces(moduleName, name);
1766 StripExtension(moduleName);
1768 ReplaceSpaces(modulePath, path);
1769 if(modulePath[0]) strcat(modulePath, SEPS);
1772 // *** Dependency command ***
1773 sprintf(command, "gcc -MT $(OBJ)%s.o -MM %s%s.%s",
1774 moduleName, modulePath, moduleName, extension);
1776 // System Includes (from global settings)
1777 for(item : compiler.dirs[Includes])
1779 strcat(command, " -isystem ");
1780 if(strchr(item, ' '))
1782 strcat(command, "\"");
1783 strcat(command, item);
1784 strcat(command, "\"");
1787 strcat(command, item);
1790 for(item : config.includeDirs)
1792 strcat(command, " -I");
1793 if(strchr(item, ' '))
1795 strcat(command, "\"");
1796 strcat(command, item);
1797 strcat(command, "\"");
1800 strcat(command, item);
1802 for(item : config.preprocessorDefs)
1804 strcat(command, " -D");
1805 strcat(command, item);
1809 if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
1813 bool firstLine = true;
1815 // To do some time: auto save external dependencies?
1818 if(dep.GetLine(line, sizeof(line)-1))
1822 char * colon = strstr(line, ":");
1823 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
1837 // If we failed to generate dependencies...
1840 /* COMMENTED OUT FOR NOW
1841 f.Printf("$(OBJ)%s.c: %s%s.%s $(Symbols)\n",
1842 moduleName, modulePath, moduleName, extension);
1845 OpenRulesPlatformExclusionIfs(f, &ifCount, platforms[0], parentExcludedPlatforms, null);
1846 f.Printf("$(OBJ)%s.c: %s%s.%s $(OBJ)%s.sym | $(SYMBOLS)\n",
1847 moduleName, modulePath, moduleName, extension, moduleName);
1853 f.Printf("\t$(ECC) %s%s.%s $(OBJ)%s.c\n\n",
1854 modulePath, moduleName, extension, moduleName);
1857 f.Printf("\t$(ECC)");
1858 // Give priority to file flags
1859 GenFileFlags(f, project, prjConfig);
1860 if(GetECFLAGS(prjConfig))
1862 f.Printf("%s $(CECFLAGS)", GetNoLineNumbers(prjConfig) ? " -nolinenumbers" : "");
1863 if(GetMemoryGuard(prjConfig))
1864 f.Printf(" -memguard");
1865 if(GetStrictNameSpaces(prjConfig))
1866 f.Printf(" -strictns");
1868 char * s = GetDefaultNameSpace(prjConfig);
1870 f.Printf(" -defaultns %s", s);
1874 f.Printf(" $(CECFLAGS) $(ECFLAGS)");
1875 f.Printf(" $(CFLAGS) $(FVISIBILITY)");
1877 f.Printf(" -c %s%s.%s -o $(OBJ)%s.c -symbols $(OBJ)\n\n",
1878 modulePath, moduleName, extension, moduleName);
1879 CloseRulesPlatformExclusionIfs(f, ifCount);
1884 bool needed = false;
1885 if(ContainsFilesWithExtension("ec"))
1889 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1898 Map<Platform, bool> excludedPlatforms { };
1899 for(mn : parentExcludedPlatforms) if(mn) excludedPlatforms[&mn] = true;
1900 for(platform : platforms)
1902 OpenRulesPlatformExclusionIfs(f, &ifCount, platform, parentExcludedPlatforms, excludedPlatforms);
1905 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
1906 child.GenMakefilePrintCObjectRules(f, project, compiler, prjConfig, excludedPlatforms);
1909 CloseRulesPlatformExclusionIfs(f, ifCount);
1910 delete excludedPlatforms;
1916 void GenMakefilePrintObjectRules(File f, Project project,
1917 Map<String, NameCollisionInfo> namesInfo,
1918 CompilerConfig compiler, ProjectConfig prjConfig,
1919 Map<Platform, bool> parentExcludedPlatforms)
1922 ProjectConfig config = GetMatchingNodeConfig(prjConfig);
1923 Array<Platform> platforms = GetPlatformsArrayFromExcluisionInfo(prjConfig);
1924 //ProjectNode child;
1925 //char objDir[MAX_LOCATION];
1926 //ReplaceSpaces(objDir, config.objDir.dir);
1927 //eSystem_Log("Printing Object Rules\n");
1931 char extension[MAX_EXTENSION];
1932 char modulePath[MAX_LOCATION];
1933 char moduleName[MAX_FILENAME];
1935 GetExtension(name, extension);
1936 /*if(!strcmpi(extension, "c") || !strcmpi(extension, "cpp") ||
1937 !strcmpi(extension, "ec") || !strcmpi(extension, "cc") ||
1938 !strcmpi(extension, "cxx"))*/
1939 if(!strcmpi(extension, "c") || !strcmpi(extension, "cpp") ||
1940 !strcmpi(extension, "cc") || !strcmpi(extension, "cxx") ||
1941 !strcmpi(extension, "m") || !strcmpi(extension, "ec"))
1945 NameCollisionInfo info;
1947 ReplaceSpaces(moduleName, name);
1948 StripExtension(moduleName);
1950 info = namesInfo[moduleName];
1951 collision = info ? info.IsExtensionColliding(extension) : false;
1953 ReplaceSpaces(modulePath, path);
1954 if(modulePath[0]) strcat(modulePath, SEPS);
1956 // *** Dependency command ***
1957 if(!strcmpi(extension, "ec"))
1958 sprintf(command, "%s -MT $(OBJ)%s.o -MM $(OBJ)%s.c", compiler.ccCommand, moduleName, moduleName);
1960 sprintf(command, "%s -MT $(OBJ)%s.o -MM %s%s.%s", compiler.ccCommand, moduleName, modulePath, moduleName, extension);
1962 if(!strcmpi(extension, "ec"))
1963 f.Printf("$(OBJ)%s.o: $(OBJ)%s.c\n", moduleName, moduleName);
1967 // System Includes (from global settings)
1968 for(item : compiler.dirs[includes])
1970 strcat(command, " -isystem ");
1971 if(strchr(item, ' '))
1973 strcat(command, "\"");
1974 strcat(command, item);
1975 strcat(command, "\"");
1978 strcat(command, item);
1981 for(item : config.includeDirs)
1983 strcat(command, " -I");
1984 if(strchr(item, ' '))
1986 strcat(command, "\"");
1987 strcat(command, item);
1988 strcat(command, "\"");
1991 strcat(command, item);
1993 for(item : config.preprocessorDefs)
1995 strcat(command, " -D");
1996 strcat(command, item);
2000 if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
2003 bool firstLine = true;
2006 // To do some time: auto save external dependencies?
2010 if(dep.GetLine(line, sizeof(line)-1))
2014 char * colon = strstr(line, ":");
2015 if(strstr(line, "No such file") || strstr(line, ",") || (colon && strstr(colon+1, ":")))
2029 // If we failed to generate dependencies...
2033 OpenRulesPlatformExclusionIfs(f, &ifCount, platforms[0], parentExcludedPlatforms, null);
2035 /*if(!strcmpi(extension, "ec"))
2036 f.Printf("$(OBJ)%s.o: $(OBJ)%s.c\n", moduleName, moduleName);
2038 f.Printf("$(OBJ)%s%s%s.o: %s%s.%s\n", moduleName,
2039 collision ? "." : "", collision ? extension : "", modulePath, moduleName, extension);
2045 f.Printf("\t$(CC)");
2046 // Give priority to file flags
2047 GenFileFlags(f, project, prjConfig);
2049 f.Printf(" $(CFLAGS)");
2051 if(!strcmpi(extension, "ec"))
2052 f.Printf(" $(FVISIBILITY) -c $(OBJ)%s.c -o $(OBJ)%s.o\n\n", moduleName, moduleName);
2054 f.Printf(" -c %s%s.%s -o $(OBJ)%s%s%s.o\n\n",
2055 modulePath, moduleName, !strcmpi(extension, "ec") ? "c" : extension, moduleName,
2056 collision ? "." : "", collision ? extension : "");
2057 CloseRulesPlatformExclusionIfs(f, ifCount);
2062 bool needed = false;
2065 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
2073 Map<Platform, bool> excludedPlatforms { };
2074 for(mn : parentExcludedPlatforms) if(mn) excludedPlatforms[&mn] = true;
2075 for(platform : platforms)
2077 OpenRulesPlatformExclusionIfs(f, &ifCount, platform, parentExcludedPlatforms, excludedPlatforms);
2080 if(child.type != resources && (child.type == folder || !child.GetIsExcluded(prjConfig)))
2081 child.GenMakefilePrintObjectRules(f, project, namesInfo, compiler, prjConfig, excludedPlatforms);
2084 CloseRulesPlatformExclusionIfs(f, ifCount);
2085 delete excludedPlatforms;
2091 void GenMakefileAddResources(File f, String resourcesPath, ProjectConfig prjConfig)
2098 //Iterator<ProjectNode> i { files };
2099 //Iterator<ProjectNode> prev { files };
2100 //for(child : files)
2102 for(c = 0; c < files.count; c++)
2104 ProjectNode child = files[c];
2105 TwoStrings ts = child.GetPlatformSpecificFu(prjConfig);
2108 if(child.type == file && !child.GetIsExcluded(prjConfig) && !(count > 0 && ts))
2111 char tempPath[MAX_LOCATION];
2112 char resPath[MAX_LOCATION];
2116 // $(EAR) aw%s --- /*quiet ? "q" : */""
2118 f.Printf("\t%s$(EAR) aw $(TARGET)", ts.a);
2121 if(eString_PathInsideOfMore(child.path, resourcesPath, tempPath))
2124 PathCatSlash(tempPath, child.name);
2129 strcpy(tempPath, child.path);
2130 PathCatSlash(tempPath, child.name);
2132 ReplaceSpaces(resPath, tempPath);
2133 if(strchr(tempPath, ' '))
2137 f.Printf(" %s%s%s%s", quotes, useRes ? "$(RES)" : "", tempPath, quotes);
2140 if(count == 10 || (count > 0 && (ts || !child.next)))
2142 char path[MAX_LOCATION] = "", temp[MAX_LOCATION];
2145 for(parent = this; parent.type == folder; parent = parent.parent)
2148 strcpy(path, parent.name);
2155 f.Printf(" \"%s\"%s\n", path, ts.b);
2167 if(child.type == folder)
2168 child.GenMakefileAddResources(f, resourcesPath, prjConfig);
2173 Array<Platform> GetPlatformsArrayFromExcluisionInfo(ProjectConfig prjConfig)
2175 Array<Platform> platforms { };
2176 Map<Platform, SetBool> exclusionInfo { };
2177 CollectExclusionInfo(exclusionInfo, prjConfig);
2178 if(exclusionInfo[unknown] == true && exclusionInfo.count > 1)
2179 for(mn : exclusionInfo; mn == false)
2182 platforms.Add(unknown);
2183 delete exclusionInfo;
2188 class NameCollisionInfo
2198 bool IsExtensionColliding(char * extension)
2201 if(count > 1 && ((!strcmpi(extension, "c") && ec) ||
2202 (!strcmpi(extension, "cpp") && (ec || c)) ||
2203 (!strcmpi(extension, "cc") && (ec || c || cpp)) ||
2204 (!strcmpi(extension, "cxx") && (ec || c || cpp || cc)) ||
2205 !strcmpi(extension, "m")))
2213 static inline void OpenRulesPlatformExclusionIfs(File f, int * ifCount, Platform platform,
2214 Map<Platform, bool> parentExcludedPlatforms, Map<Platform, bool> excludedPlatforms)
2216 if(platform != unknown && !parentExcludedPlatforms[platform])
2218 if(*ifCount) // we really need a if defined(a) || defined(b) here
2219 f.Printf("else\n"); // instead of repeating the rules for each platform
2221 f.Printf("ifdef %s\n\n", PlatformToMakefileVariable(platform)); //
2222 if(excludedPlatforms)
2223 excludedPlatforms[platform] = true;
2227 static inline void CloseRulesPlatformExclusionIfs(File f, int ifCount)
2232 for(c = 0; c < ifCount; c++)
2233 f.Printf("endif\n");