OrderLibrariesWithDecreasingDependencies( Bam.Core.Array <Bam.Core.Module> libs) { // work on a copy of the flattened list of libraries, as the modules may be rearranged var flatLibs = new Bam.Core.Array <Bam.Core.Module>(libs); // now ensure that the order of the libraries is such that those with the least number of dependents // are at the end // this is O(N^2) and some modules may be moved more than once for (var i = 0; i < flatLibs.Count;) { var ontoNext = true; for (var j = i + 1; j < flatLibs.Count; ++j) { if (!(flatLibs[j] is IForwardedLibraries)) { continue; } // if any other module has the first as a dependent, move the dependent to the end if ((flatLibs[j] as IForwardedLibraries).ForwardedLibraries.Contains(flatLibs[i])) { var temp = flatLibs[i]; flatLibs.Remove(temp); flatLibs.Add(temp); ontoNext = false; break; } } if (ontoNext) { ++i; } } return(flatLibs.ToReadOnlyCollection()); }
AddFiles( string path, Bam.Core.Module macroModuleOverride = null, System.Text.RegularExpressions.Regex filter = null) { var macroModule = (macroModuleOverride == null) ? this : macroModuleOverride; var wildcardPath = macroModule.CreateTokenizedString(path).Parse(); var dir = System.IO.Path.GetDirectoryName(wildcardPath); if (!System.IO.Directory.Exists(dir)) { throw new Bam.Core.Exception("The directory {0} does not exist", dir); } var leafname = System.IO.Path.GetFileName(wildcardPath); var files = System.IO.Directory.GetFiles(dir, leafname, System.IO.SearchOption.TopDirectoryOnly); if (filter != null) { files = files.Where(pathname => filter.IsMatch(pathname)).ToArray(); } if (0 == files.Length) { throw new Bam.Core.Exception("No files were found that matched the pattern '{0}'", wildcardPath); } var modulesCreated = new Bam.Core.Array <Bam.Core.Module>(); foreach (var filepath in files) { modulesCreated.Add(this.AddFile(filepath, verbatim: true)); } return(modulesCreated); }
addMeta( MakeFileMeta meta) { lock (allMeta) { allMeta.Add(meta); } }
FlattenHierarchicalFileList( Bam.Core.Array <Bam.Core.Module> files) { var list = new Bam.Core.Array <Bam.Core.Module>(); foreach (var input in files) { if (input is Bam.Core.IModuleGroup) { foreach (var child in input.Children) { list.Add(child); } } else { list.Add(input); } } return(list); }
CreateBuildActionEntry( System.Xml.XmlDocument doc, System.Xml.XmlElement buildActionEntriesEl, Target target, Bam.Core.Array <Target> buildActionsCreated) { #if true #else // add all required dependencies in first (order matters) foreach (var required in target.TargetDependencies) { this.CreateBuildActionEntry(doc, buildActionEntriesEl, required., buildActionsCreated); } #endif // the same target might appear again while iterating through the required targets of dependencies // only add it once (first one is important for ordering) if (buildActionsCreated.Contains(target)) { return; } var buildActionEntry = doc.CreateElement("BuildActionEntry"); buildActionEntriesEl.AppendChild(buildActionEntry); var buildableReference = doc.CreateElement("BuildableReference"); buildActionEntry.AppendChild(buildableReference); { buildableReference.SetAttribute("BuildableIdentifier", "primary"); buildableReference.SetAttribute("BlueprintIdentifier", target.GUID); if (null != target.FileReference) { buildableReference.SetAttribute("BuildableName", target.FileReference.Name); } buildableReference.SetAttribute("BlueprintName", target.Name); if (target.Project.ProjectDir == this.Project.ProjectDir) { buildableReference.SetAttribute("ReferencedContainer", "container:" + System.IO.Path.GetFileName(this.Project.ProjectDir.Parse())); } else { var relative = this.Project.GetRelativePathToProject(target.Project.ProjectDir); buildableReference.SetAttribute("ReferencedContainer", "container:" + relative); } } buildActionsCreated.Add(target); }
AddFiles( string path, Bam.Core.Module macroModuleOverride = null, System.Text.RegularExpressions.Regex filter = null) { if (System.String.IsNullOrEmpty(path)) { throw new Bam.Core.Exception("Cannot add files from an empty path"); } var macroModule = (macroModuleOverride == null) ? this : macroModuleOverride; var tokenizedPath = macroModule.CreateTokenizedString(path); tokenizedPath.Parse(); var wildcardPath = tokenizedPath.ToString(); var dir = System.IO.Path.GetDirectoryName(wildcardPath); if (!System.IO.Directory.Exists(dir)) { throw new Bam.Core.Exception("The directory {0} does not exist", dir); } var leafname = System.IO.Path.GetFileName(wildcardPath); var option = leafname.Contains("**") ? System.IO.SearchOption.AllDirectories : System.IO.SearchOption.TopDirectoryOnly; var files = System.IO.Directory.GetFiles(dir, leafname, option); if (0 == files.Length) { throw new Bam.Core.Exception("No files were found that matched the pattern '{0}'", wildcardPath); } if (filter != null) { var filteredFiles = files.Where(pathname => filter.IsMatch(pathname)).ToArray(); if (0 == filteredFiles.Length) { throw new Bam.Core.Exception("No files were found that matched the pattern '{0}', after applying the regex filter. {1} were found prior to applying the filter.", wildcardPath, files.Count()); } files = filteredFiles; } var modulesCreated = new Bam.Core.Array <Bam.Core.Module>(); foreach (var filepath in files) { modulesCreated.Add(this.AddFile(filepath, verbatim: true)); } return(modulesCreated); }