Пример #1
0
        private void DumpPip(Pip pip, AnalysisInput analysisInput, string dumpPath)
        {
            var dumpPipAnalyzer = new DumpPipAnalyzer(analysisInput, dumpPath, pip.SemiStableHash, true, false);
            var result          = dumpPipAnalyzer.Analyze();

            if (result != 0)
            {
                throw new Exception($"DumpPip failed for {pip.FormattedSemiStableHash}");
            }
        }
Пример #2
0
        public Analyzer InitializeDumpPipAnalyzer()
        {
            string            outputFilePath   = null;
            long              semiStableHash   = 0;
            bool              useOriginalPaths = false;
            DirectoryArtifact outputDirectory  = default;

            foreach (var opt in AnalyzerOptions)
            {
                if (opt.Name.Equals("outputFile", StringComparison.OrdinalIgnoreCase) ||
                    opt.Name.Equals("o", StringComparison.OrdinalIgnoreCase))
                {
                    outputFilePath = ParseSingletonPathOption(opt, outputFilePath);
                }
                else if (opt.Name.Equals("pip", StringComparison.OrdinalIgnoreCase) ||
                         opt.Name.Equals("p", StringComparison.OrdinalIgnoreCase))
                {
                    semiStableHash = ParseSemistableHash(opt);
                }
                else if (opt.Name.Equals("useOriginalPaths", StringComparison.OrdinalIgnoreCase) ||
                         opt.Name.Equals("u", StringComparison.OrdinalIgnoreCase))
                {
                    useOriginalPaths = ParseBooleanOption(opt);
                }
                else if (opt.Name.Equals("directory", StringComparison.OrdinalIgnoreCase) ||
                         opt.Name.Equals("d", StringComparison.OrdinalIgnoreCase))
                {
                    outputDirectory = parseDirectoryArtifact(opt);
                }
                else
                {
                    throw Error("Unknown option for dump pip analysis: {0}", opt.Name);
                }
            }

            if ((semiStableHash == 0) == (!outputDirectory.IsValid))
            {
                throw Error("Either /pip or /directory parameter must be specified");
            }

            return(new DumpPipAnalyzer(GetAnalysisInput(), outputFilePath, semiStableHash, outputDirectory, useOriginalPaths));

            DirectoryArtifact parseDirectoryArtifact(Option opt)
            {
                if (!DumpPipAnalyzer.TryDeserializeDirectoryArtifact(opt.Value, out DirectoryArtifact directory) || !directory.IsValid)
                {
                    throw Error("Invalid directory artifact: {0}.", opt.Value);
                }

                return(directory);
            }
        }