Ejemplo n.º 1
0
 AddFile(
     Bam.Core.Module module,
     Bam.Core.PathKey key)
 {
     this.DependsOn(module);
     this.Files.Add(module, key);
 }
Ejemplo n.º 2
0
 AddPath(
     Bam.Core.Module module,
     Bam.Core.PathKey key)
 {
     this.DependsOn(module);
     this.Paths.Add(module, key);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        Include <DependentModule>(
            Bam.Core.PathKey key,
            string subdir,
            CollatedFile reference) where DependentModule : Bam.Core.Module, new()
        {
            var dependent = Bam.Core.Graph.Instance.FindReferencedModule <DependentModule>();

            if (null == dependent)
            {
                return(null);
            }

            var copyFileModule = this.CreateCollatedFile(
                dependent,
                dependent.GeneratedPaths[key],
                reference,
                Bam.Core.TokenizedString.CreateVerbatim(subdir));

            if (this.IsReferenceAWindowedApp(reference))
            {
                if (C.ConsoleApplication.Key == key)
                {
                    this.AddOSXChangeIDNameForBinary(copyFileModule);
                }
            }
            else if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Linux))
            {
                if ((dependent is C.IDynamicLibrary) && dependent.Macros.Contains("SOName"))
                {
                    this.CopySONameSymlink(copyFileModule);
                }
            }

            return(copyFileModule);
        }
Ejemplo n.º 5
0
        SourceFolder <DependentModule>(
            Bam.Core.PathKey key) where DependentModule : Bam.Core.Module, new()
        {
            var dependent = Bam.Core.Graph.Instance.FindReferencedModule <DependentModule>();

            this.InputFiles.AddPath(dependent, key);
        }
        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);
        }
Ejemplo n.º 7
0
 RegisterGeneratedFile(
     PathKey key,
     TokenizedString path)
 {
     if (this.GeneratedPaths.ContainsKey(key))
     {
         Log.DebugMessage("Key '{0}' already exists", key);
         return;
     }
     this.GeneratedPaths.Add(key, path);
 }
Ejemplo n.º 8
0
        Include <DependentModule>(
            Bam.Core.PathKey key) where DependentModule : Bam.Core.Module, new()
        {
            var dependent = Bam.Core.Graph.Instance.FindReferencedModule <DependentModule>();

            if (null == dependent)
            {
                return;
            }
            this.InputFiles.AddFile(dependent, key);
        }
Ejemplo n.º 9
0
 Generate(
     string key)
 {
     var matches = GeneratedKeys.Where(item => (item.Id == key));
     var first = matches.FirstOrDefault();
     if (null != first)
     {
         return first;
     }
     var newKey = new PathKey(key);
     GeneratedKeys.Add(newKey);
     return newKey;
 }
Ejemplo n.º 10
0
        Generate(
            string key)
        {
            var foundPathKey = GeneratedKeys.FirstOrDefault(item => (item.Id == key));

            if (null != foundPathKey)
            {
                return(foundPathKey);
            }
            var newKey = new PathKey(key);

            GeneratedKeys.Add(newKey);
            return(newKey);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        Generate(
            string key)
        {
            var matches = GeneratedKeys.Where(item => (item.Id == key));
            var first   = matches.FirstOrDefault();

            if (null != first)
            {
                return(first);
            }
            var newKey = new PathKey(key);

            GeneratedKeys.Add(newKey);
            return(newKey);
        }
Ejemplo n.º 13
0
        Include <DependentModule>(
            Bam.Core.PathKey key,
            string subdir,
            CollatedFile reference) where DependentModule : Bam.Core.Module, new()
        {
            try
            {
                var dependent = Bam.Core.Graph.Instance.FindReferencedModule <DependentModule>();
                if (null == dependent)
                {
                    return(null);
                }

                var copyFileModule = this.CreateCollatedFile(
                    dependent,
                    dependent.GeneratedPaths[key],
                    reference,
                    Bam.Core.TokenizedString.CreateVerbatim(subdir));

                if (this.IsReferenceAWindowedApp(reference))
                {
                    if (C.ConsoleApplication.Key == key)
                    {
                        this.AddOSXChangeIDNameForBinary(copyFileModule);
                    }
                }
                else if (this.BuildEnvironment.Platform.Includes(Bam.Core.EPlatform.Linux))
                {
                    if ((dependent is C.IDynamicLibrary) && dependent.Macros.Contains("SOName"))
                    {
                        this.CopySONameSymlink(copyFileModule);
                    }
                }

                return(copyFileModule);
            }
            catch (Bam.Core.UnableToBuildModuleException exception)
            {
                Bam.Core.Log.Info("Not publishing {0} requested by {1} because {2}, but publishing will continue",
                                  typeof(DependentModule).ToString(),
                                  this.GetType().ToString(),
                                  exception.Message);
                return(null);
            }
        }
Ejemplo n.º 14
0
        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;
            }
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
 RegisterGeneratedFile(
     PathKey key)
 {
     this.RegisterGeneratedFile(key, null);
 }