CloneSymbolicLink( CollatedObject collatedSymlink, System.Collections.Generic.Dictionary <CollatedObject, Bam.Core.Module> referenceMap) { var clonedSymLink = Bam.Core.Module.Create <CollatedSymbolicLink>(preInitCallback: module => { if (!referenceMap.ContainsKey(collatedSymlink.Reference)) { throw new Bam.Core.Exception("Unable to find CollatedSymbolicLink reference to {0} in the reference map", collatedSymlink.Reference.SourceModule.ToString()); } var newRef = referenceMap[collatedSymlink.Reference]; var referenceFilePath = newRef.GeneratedPaths[this.ReferenceKey]; module.Macros["CopyDir"] = Collation.GenerateSymbolicLinkCopyDestination( this, referenceFilePath, collatedSymlink.SubDirectory); }); this.DependsOn(clonedSymLink); clonedSymLink.SourceModule = collatedSymlink; clonedSymLink.SourcePath = collatedSymlink.GeneratedPaths[CollatedObject.Key]; clonedSymLink.SubDirectory = collatedSymlink.SubDirectory; clonedSymLink.AssignLinkTarget(collatedSymlink.Macros["LinkTarget"]); }
Include <DependentModule>( Bam.Core.PathKey key, string subDirectory, CollatedObject reference) where DependentModule : Bam.Core.Module, new() { var dependent = Bam.Core.Graph.Instance.FindReferencedModule <DependentModule>(); this.Requires(dependent); this.Requires(dependent.Tool); var strippedInitialRef = this.RefMap[reference]; var subDir = Bam.Core.TokenizedString.CreateVerbatim(subDirectory); var copyFileModule = Bam.Core.Module.Create <CollatedFile>(preInitCallback: module => { Bam.Core.TokenizedString referenceFilePath = strippedInitialRef.GeneratedPaths[this.ReferenceKey]; this.RegisterGeneratedFile(Key, module.CreateTokenizedString("@dir($(0))", dependent.GeneratedPaths[key])); module.Macros["CopyDir"] = Collation.GenerateFileCopyDestination( module, referenceFilePath, subDir, this.GeneratedPaths[Key]); }); this.Requires(copyFileModule); copyFileModule.SourceModule = dependent; copyFileModule.SourcePath = dependent.GeneratedPaths[key]; copyFileModule.Reference = strippedInitialRef as CollatedFile; copyFileModule.SubDirectory = subDir; return(copyFileModule); }
convertPaths( CollatedObject module, Bam.Core.TokenizedString inSourcePath, Bam.Core.TokenizedString inPublishingPath, out string resolvedSourcePath, out string resolvedDestinationDir) { if (module is CollatedDirectory) { // Posix cp only requires the destination to be added when there is a rename if (module.Macros.Contains("RenameLeaf")) { resolvedSourcePath = System.String.Format("{0}{1}*", inSourcePath.ToString(), System.IO.Path.DirectorySeparatorChar); resolvedDestinationDir = System.String.Format("{0}{1}{2}{1}", inPublishingPath.ToString(), System.IO.Path.DirectorySeparatorChar, module.Macros["RenameLeaf"].ToString()); } else { resolvedSourcePath = inSourcePath.ToString(); resolvedDestinationDir = inPublishingPath.ToString(); } } else { resolvedSourcePath = inSourcePath.ToString(); resolvedDestinationDir = inPublishingPath.ToString(); } }
CloneDirectory( CollatedObject collatedDir, System.Collections.Generic.Dictionary <CollatedObject, Bam.Core.Module> referenceMap) { var clonedDir = Bam.Core.Module.Create <CollatedDirectory>(preInitCallback: module => { if (!referenceMap.ContainsKey(collatedDir.Reference)) { throw new Bam.Core.Exception("Unable to find CollatedDirectory reference to {0} in the reference map", collatedDir.Reference.SourceModule.ToString()); } var newRef = referenceMap[collatedDir.Reference]; var referenceFilePath = newRef.GeneratedPaths[this.ReferenceKey]; module.Macros["CopyDir"] = Collation.GenerateDirectoryCopyDestination( module, referenceFilePath, collatedDir.SubDirectory, collatedDir.SourcePath); }); this.DependsOn(clonedDir); clonedDir.SourceModule = collatedDir; clonedDir.SourcePath = collatedDir.GeneratedPaths[CollatedObject.Key]; clonedDir.SubDirectory = collatedDir.SubDirectory; if (collatedDir.Macros["CopiedFilename"].IsAliased) { clonedDir.Macros["CopiedFilename"].Aliased(collatedDir.Macros["CopiedFilename"]); } }
convertPaths( CollatedObject module, Bam.Core.TokenizedString inSourcePath, Bam.Core.TokenizedString inPublishingPath, out string resolvedSourcePath, out string resolvedDestinationDir) { resolvedSourcePath = inSourcePath.ToString(); if (module is CollatedDirectory) { // Windows XCOPY requires the directory name to be added to the destination regardless if (module.Macros.Contains("RenameLeaf")) { resolvedDestinationDir = System.String.Format("{0}{1}{2}{1}", inPublishingPath.ToString(), System.IO.Path.DirectorySeparatorChar, module.Macros["RenameLeaf"].ToString()); } else { resolvedDestinationDir = System.String.Format("{0}{1}{2}{1}", inPublishingPath.ToString(), System.IO.Path.DirectorySeparatorChar, System.IO.Path.GetFileName(inSourcePath.ToString())); } } else { resolvedDestinationDir = inPublishingPath.ToString(); } }
Include <DependentModule>( Bam.Core.PathKey key, Collation collator, CollatedObject anchor) where DependentModule : Bam.Core.Module, new() { var dependent = Bam.Core.Graph.Instance.FindReferencedModule <DependentModule>(); if (null == dependent) { return(null); } var modulePublishDir = collator.Mapping.FindPublishDirectory(dependent, key); var collatedFile = Bam.Core.Module.Create <CollatedFile>(preInitCallback: module => { module.SourceModule = dependent; module.SourcePathKey = key; module.Anchor = anchor; module.SetPublishingDirectory("$(0)", new[] { modulePublishDir }); }); var strippedAnchor = this.findAnchor(anchor); collatedFile.Macros.Add("publishdir", strippedAnchor.Macros["publishdir"]); // dependents might reference the anchor's OutputName macro, e.g. dylibs copied into an application bundle collatedFile.Macros.Add("AnchorOutputName", (anchor as CollatedObject).Macros["AnchorOutputName"]); this.Requires(collatedFile); return(collatedFile); }
convertPaths( CollatedObject module, Bam.Core.TokenizedString inSourcePath, Bam.Core.TokenizedString inPublishingPath, out string resolvedSourcePath, out string resolvedDestinationDir) { resolvedSourcePath = inSourcePath.ToString(); resolvedDestinationDir = inPublishingPath.ToString(); }
findAnchor( CollatedObject anchor) { foreach (var obj in this.collatedObjects) { if (obj.Key == anchor) { return(obj.Value as Bam.Core.Module); } } throw new Bam.Core.Exception("Unable to find stripped collation object for '{0}'", (anchor as ICollatedObject).SourceModule.ToString()); }
IncludeFile( Bam.Core.TokenizedString parameterizedFilePath, string subdir) { var copyFileModule = this.CreateCollatedFile( this, parameterizedFilePath, null, Bam.Core.TokenizedString.CreateVerbatim(subdir)); this.InitialReference = copyFileModule; return(copyFileModule); }
Include <DependentModule>( Bam.Core.PathKey key, EPublishingType type, string subdir = null) where DependentModule : Bam.Core.Module, new() { var dependent = Bam.Core.Graph.Instance.FindReferencedModule <DependentModule>(); if (null == dependent) { return(null); } var path = this.PublishingPath(dependent, type); string destSubDir; if (null == path) { destSubDir = subdir; } else { if (null != subdir) { destSubDir = System.IO.Path.Combine(path, subdir); } else { destSubDir = path; } } var copyFileModule = this.CreateCollatedFile( dependent, dependent.GeneratedPaths[key], null, Bam.Core.TokenizedString.CreateVerbatim(destSubDir)); if (EPublishingType.WindowedApplication == type) { if (C.ConsoleApplication.Key == key) { this.AddOSXChangeIDNameForBinary(copyFileModule); } } this.InitialReference = copyFileModule; return(copyFileModule); }
CreatedSYMBundle( CollatedObject collatedFile, System.Collections.Generic.Dictionary <CollatedObject, Bam.Core.Module> referenceMap) { var createDebugSymbols = Bam.Core.Module.Create <DSymUtilModule>(preInitCallback: module => { module.ReferenceMap = referenceMap; }); this.DependsOn(createDebugSymbols); createDebugSymbols.SourceModule = collatedFile; if (collatedFile.Reference == null) { referenceMap.Add(collatedFile, createDebugSymbols); } }
CopyDebugSymbols( CollatedObject collatedFile, System.Collections.Generic.Dictionary <CollatedObject, Bam.Core.Module> referenceMap) { var createDebugSymbols = Bam.Core.Module.Create <ObjCopyModule>(preInitCallback: module => { module.ReferenceMap = referenceMap; }); this.DependsOn(createDebugSymbols); createDebugSymbols.SourceModule = collatedFile; createDebugSymbols.PrivatePatch(settings => { var objCopySettings = settings as IObjCopyToolSettings; objCopySettings.Mode = EObjCopyToolMode.OnlyKeepDebug; }); if (collatedFile.Reference == null) { referenceMap.Add(collatedFile, createDebugSymbols); } }
CopyPDB( CollatedObject collatedFile, System.Collections.Generic.Dictionary <CollatedObject, Bam.Core.Module> referenceMap) { var copyPDBModule = Bam.Core.Module.Create <CollatedFile>(preInitCallback: module => { Bam.Core.TokenizedString referenceFilePath = null; if (collatedFile.Reference != null) { if (!referenceMap.ContainsKey(collatedFile.Reference)) { throw new Bam.Core.Exception("Unable to find CollatedFile reference to {0} in the reference map", collatedFile.Reference.SourceModule.ToString()); } var newRef = referenceMap[collatedFile.Reference]; referenceFilePath = newRef.GeneratedPaths[CollatedObject.Key]; } module.Macros["CopyDir"] = Collation.GenerateFileCopyDestination( this, referenceFilePath, collatedFile.SubDirectory, this.GeneratedPaths[Key]); }); this.DependsOn(copyPDBModule); copyPDBModule.SourceModule = collatedFile.SourceModule; // TODO: there has not been a check whether this is a valid path or not (i.e. were debug symbols enabled for link?) copyPDBModule.SourcePath = collatedFile.SourceModule.GeneratedPaths[C.ConsoleApplication.PDBKey]; copyPDBModule.SubDirectory = collatedFile.SubDirectory; // since PDBs aren't guaranteed to exist as it depends on build settings, allow missing files to go through copyPDBModule.FailWhenSourceDoesNotExist = false; if (collatedFile.Reference == null) { referenceMap.Add(collatedFile, copyPDBModule); } }
CloneFile( CollatedObject collatedFile, System.Collections.Generic.Dictionary <CollatedObject, Bam.Core.Module> referenceMap) { var clonedFile = Bam.Core.Module.Create <CollatedFile>(preInitCallback: module => { Bam.Core.TokenizedString referenceFilePath = null; if (collatedFile.Reference != null) { if (!referenceMap.ContainsKey(collatedFile.Reference)) { throw new Bam.Core.Exception("Unable to find CollatedFile reference to {0} in the reference map", collatedFile.Reference.SourceModule.ToString()); } var newRef = referenceMap[collatedFile.Reference]; // the PathKey depends on whether the reference came straight as a clone, or after being stripped referenceFilePath = newRef.GeneratedPaths[this.ReferenceKey]; } module.Macros["CopyDir"] = Collation.GenerateFileCopyDestination( this, referenceFilePath, collatedFile.SubDirectory, this.GeneratedPaths[Key]); }); this.DependsOn(clonedFile); clonedFile.SourceModule = collatedFile; clonedFile.SourcePath = collatedFile.GeneratedPaths[CollatedObject.Key]; clonedFile.SubDirectory = collatedFile.SubDirectory; if (collatedFile.Reference == null) { referenceMap.Add(collatedFile, clonedFile); this.ReferenceKey = CollatedObject.Key; } }
StripBinary( CollatedObject collatedFile, System.Collections.Generic.Dictionary <CollatedObject, Bam.Core.Module> referenceMap, ObjCopyModule debugSymbols = null) { var stripBinary = Bam.Core.Module.Create <StripModule>(preInitCallback: module => { module.ReferenceMap = referenceMap; }); this.DependsOn(stripBinary); stripBinary.SourceModule = collatedFile; if (null != debugSymbols) { stripBinary.DebugSymbolsModule = debugSymbols; stripBinary.Requires(debugSymbols); } if (collatedFile.Reference == null) { referenceMap.Add(collatedFile, stripBinary); this.ReferenceKey = StripModule.Key; } return(stripBinary); }