Exemple #1
0
        private ObjectInfo DirectoryArtifactInfo(DirectoryArtifact d)
        {
            if (!d.IsValid)
            {
                return(new ObjectInfo("Invalid"));
            }

            var name    = d.Path.GetName(PathTable).ToString(StringTable);
            var kind    = d.IsSharedOpaque ? "shared opaque" : d.IsOutputDirectory() ? "exclusive opaque" : "source";
            var members = d.IsOutputDirectory()
                ? Analyzer.GetDirMembers(d, PipGraph.GetProducer(d))
                : d.PartialSealId > 0
                    ? PipGraph.ListSealedDirectoryContents(d).Select(f => f.Path)
                    : CollectionUtilities.EmptyArray <AbsolutePath>();

            return(new ObjectInfo(
                       preview: $"{name} [{kind}]",
                       properties: new[]
            {
                new Property("Path", d.Path.ToString(PathTable)),
                new Property("PartialSealId", d.PartialSealId),
                new Property("Kind", kind),
                d.IsOutputDirectory() ? new Property("Producer", () => Analyzer.GetPip(PipGraph.GetProducer(d))) : null,
                new Property("Consumers", PipGraph.GetConsumingPips(d)),
                new Property("Members", members)
            }
                       .Where(p => p != null)));
        }
Exemple #2
0
        private void GetPathProducers(AbsolutePath path)
        {
            Dictionary <AbsolutePath, DirectoryArtifact> directories = new Dictionary <AbsolutePath, DirectoryArtifact>();

            foreach (var directory in PipGraph.AllSealDirectories)
            {
                directories[directory.Path] = directory;
            }

            var latest = PipGraph.TryGetLatestFileArtifactForPath(path);

            if (!latest.IsValid)
            {
                m_writer.WriteLine("No declared file producers");
            }
            else
            {
                for (int i = 0; i <= latest.RewriteCount; i++)
                {
                    var producerId = PipGraph.TryGetProducer(new FileArtifact(path, i));
                    if (producerId.IsValid)
                    {
                        m_writer.WriteLine("File Producer: ({0})", i);
                        m_producers.Add(producerId);
                        m_writer.WriteLine(GetDescription(GetPip(producerId)));
                        m_writer.WriteLine();
                    }
                }
            }

            while (path.IsValid)
            {
                DirectoryArtifact containingDirectory;
                if (directories.TryGetValue(path, out containingDirectory))
                {
                    var directoryNode = PipGraph.GetSealedDirectoryNode(containingDirectory);
                    var sealDirectory = (SealDirectory)GetPip(directoryNode);
                    if (sealDirectory.Kind == SealDirectoryKind.Opaque)
                    {
                        m_writer.WriteLine("Directory Producer:");
                        m_producers.Add(PipGraph.GetProducer(containingDirectory));
                        m_writer.WriteLine(GetDescription(GetPip(PipGraph.GetProducer(containingDirectory))));
                        m_writer.WriteLine("Directory: " + GetDescription(sealDirectory));
                        m_writer.WriteLine();
                    }
                }

                path = path.GetParent(PathTable);
            }
        }
Exemple #3
0
        private ObjectInfo FileArtifactInfo(FileArtifact f)
        {
            if (!f.IsValid)
            {
                return(new ObjectInfo("Invalid"));
            }

            return(new ObjectInfoBuilder()
                   .Preview(FileArtifactPreview(f))
                   .Prop("Path", f.Path.ToString(PathTable))
                   .Prop("Kind", f.IsSourceFile ? "source" : "output")
                   .Prop("RewriteCount", f.RewriteCount)
                   .Prop("FileContentInfo", () => Analyzer.TryGetFileContentInfo(f))
                   .Prop("Producer", () => f.IsOutputFile ? Analyzer.GetPip(PipGraph.GetProducer(f)) : null)
                   .Prop("Consumers", () => PipGraph.GetConsumingPips(f.Path))
                   .Build());
        }
Exemple #4
0
        private ObjectInfo FileArtifactInfo(FileArtifact f)
        {
            if (!f.IsValid)
            {
                return(new ObjectInfo("Invalid"));
            }

            return(new ObjectInfo(
                       preview: FileArtifactPreview(f),
                       properties: new[]
            {
                new Property("Path", f.Path.ToString(PathTable)),
                new Property("Kind", f.IsSourceFile ? "source" : "output"),
                new Property("RewriteCount", f.RewriteCount),
                new Property("FileContentInfo", () => Analyzer.TryGetFileContentInfo(f)),
                f.IsOutputFile ? new Property("Producer", () => Analyzer.GetPip(PipGraph.GetProducer(f))) : null,
                new Property("Consumers", () => PipGraph.GetConsumingPips(f.Path))
            }
                       .Where(p => p != null)));
        }
Exemple #5
0
        private ObjectInfo DirectoryArtifactInfo(DirectoryArtifact d)
        {
            if (!d.IsValid)
            {
                return(new ObjectInfo("Invalid"));
            }

            var name = d.Path.GetName(PathTable).ToString(StringTable);
            var kind = d.IsSharedOpaque ? "shared opaque" : d.IsOutputDirectory() ? "exclusive opaque" : "source";

            return(new ObjectInfo(
                       preview: $"{name} [{kind}]",
                       properties: new[]
            {
                new Property("Path", d.Path.ToString(PathTable)),
                new Property("PartialSealId", d.PartialSealId),
                new Property("Kind", kind),
                d.IsOutputDirectory() ? new Property("Producer", () => PipGraph.GetProducer(d)) : null,
                new Property("Consumers", PipGraph.GetConsumingPips(d.Path).ToArray()),
                d.PartialSealId > 0 ? new Property("Members", () => PipGraph.ListSealedDirectoryContents(d)) : null
            }
                       .Where(p => p != null)));
        }
Exemple #6
0
        private bool ProcessFilter(string filterText, FileStream stream, StreamWriter writer)
        {
            var parser = new FilterParser(CachedGraph.Context, CachedGraph.MountPathExpander.TryGetRootByMountName, filterText, canonicalize: true);

            if (!parser.TryParse(out var rootFilter, out var error))
            {
                Console.WriteLine(string.Format(CultureInfo.InvariantCulture,
                                                "Error at position {1} of command line pip filter {0}. {3} {2}",
                                                filterText,
                                                error.Position,
                                                error.FormatFilterPointingToPosition(filterText),
                                                error.Message));
                return(false);
            }

            var outputs = PipGraph.FilterOutputs(rootFilter);
            var pips    = new List <PipId>();

            if (PipGraph.FilterNodesToBuild(Events.StaticContext, rootFilter, out var nodes))
            {
                foreach (var node in nodes)
                {
                    pips.Add(node.ToPipId());
                }
            }

            writer.WriteLine(I($"Filter: {filterText}"));
            writer.WriteLine(I($"Pips: {pips.Count}"));
            Console.WriteLine(I($"Pips: {pips.Count}"));
            foreach (var pip in pips)
            {
                writer.WriteLine(GetDescription(GetPip(pip)));
            }

            writer.WriteLine();
            Console.WriteLine(I($"Outputs: {outputs.Count}"));
            writer.WriteLine(I($"Outputs: {outputs.Count}"));
            foreach (var output in outputs)
            {
                var kind = output.IsDirectory ? "D" : "F";
                writer.WriteLine(I($"{kind}: {output.Path.ToString(PathTable)} ({GetDescription(GetPip(PipGraph.GetProducer(output)))})"));
            }

            writer.WriteLine();
            writer.WriteLine();
            writer.Flush();
            stream.Flush();

            return(true);
        }