示例#1
0
 private static void SetWriteFilePipDetails(WriteFile pip, PipDetails result, PathTable pathTable)
 {
     result.Destination = new FileDetails()
     {
         Id = pip.Destination.Path.Value.Value, Path = pip.Destination.Path.ToString(pathTable)
     };
 }
示例#2
0
        private static void SetProcessPipDetails(Process pip, PipDetails result, PathTable pathTable, PipEnvironment pipEnvironment)
        {
            var args = new List <string>();

            args.Add(pip.Executable.Path.ToString(pathTable));
            args.AddRange(ConvertArgumentsToStringArray(pip.Arguments, pathTable));

            result.Executable = new ToolReference()
            {
                Id = pip.Executable.Path.Value.Value, Path = pip.Executable.Path.ToString(pathTable)
            };
            result.CommandLineFragments = args;
            result.CommandLine          = GetPipCommandLine(pip, pathTable);
            result.WarningTimeout       = pip.WarningTimeout;
            result.Timeout = pip.Timeout;

            bool includeDefaultOutputs = result.State == PipState.Failed;

            result.StandardInput = pip.StandardInput.IsFile
                ? StandardInput.CreateFromFile(FileReference.FromAbsolutePath(pathTable, pip.StandardInput.File.Path))
                : pip.StandardInput.IsData
                    ? StandardInput.CreateFromData(
                pip.StandardInput.Data.ToString(pathTable).Split(new[] { Environment.NewLine }, StringSplitOptions.None))
                    : StandardInput.Invalid;

            result.StandardOutput            = GetStdFilePath(pip, SandboxedProcessFile.StandardOutput, pathTable, includeDefaultOutputs);
            result.StandardError             = GetStdFilePath(pip, SandboxedProcessFile.StandardError, pathTable, includeDefaultOutputs);
            result.StandardDirectory         = pip.StandardDirectory.IsValid ? pip.StandardDirectory.ToString(pathTable) : null;
            result.Dependencies              = pip.Dependencies.Select(d => FileArtifactToFileDetails(d, pathTable)).OrderBy(d => d).ToList();
            result.DirectoryDependencies     = pip.DirectoryDependencies.Select(d => d.Path.ToString(pathTable)).OrderBy(d => d).ToList();
            result.AdditionalTempDirectories = pip.AdditionalTempDirectories.Select(d => d.ToString(pathTable)).OrderBy(d => d).ToList();
            result.UntrackedPaths            = pip.UntrackedPaths.Select(f => f.ToString(pathTable)).OrderBy(f => f).ToList();
            result.UntrackedScopes           = pip.UntrackedScopes.Select(f => f.ToString(pathTable)).OrderBy(f => f).ToList();
            result.Outputs = pip.FileOutputs.Select(f => FileArtifactToFileDetails(f.ToFileArtifact(), pathTable)).OrderBy(f => f).ToList();

            result.WorkingDirectory = pip.WorkingDirectory.ToString(pathTable);
            if (!result.WorkingDirectory.EndsWith(@"\", StringComparison.Ordinal))
            {
                result.WorkingDirectory += @"\";
            }

            if (pip.ResponseFile.IsValid)
            {
                result.ResponseFile = FileArtifactToFileDetails(pip.ResponseFile, pathTable);
            }

            var vars = new List <Tuple <string, string> >();

            foreach (var env in pipEnvironment.GetEffectiveEnvironmentVariables(pathTable, pip).ToDictionary().OrderBy(kvp => kvp.Key, StringComparer.OrdinalIgnoreCase))
            {
                vars.Add(new Tuple <string, string>(env.Key, env.Value));
            }

            vars.Sort((first, second) => string.Compare(first.Item1, second.Item1, StringComparison.OrdinalIgnoreCase));
            result.EnvironmentVariables = vars;
        }
示例#3
0
        /// <summary>
        /// Creates a new PipDetails from a pip
        /// </summary>
        public static PipDetails DetailsFromPip(Pip pip, PathTable pathTable, PipEnvironment pipEnvironment)
        {
            Contract.Requires(pip != null);
            Contract.Requires(pathTable != null);

            var resultingPipDetails = new PipDetails();

            SetCommonPipDetails(pip, resultingPipDetails);

            // Details specific to pip type
            switch (pip.PipType)
            {
            case PipType.WriteFile:
                SetWriteFilePipDetails((WriteFile)pip, resultingPipDetails, pathTable);
                break;

            case PipType.CopyFile:
                SetCopyFilePipDetails((CopyFile)pip, resultingPipDetails, pathTable);
                break;

            case PipType.Process:
                SetProcessPipDetails((Process)pip, resultingPipDetails, pathTable, pipEnvironment);
                break;

            case PipType.HashSourceFile:
                // Not an interesting pip
                break;

            case PipType.SealDirectory:
                SetSealDirectoryPipDetails((SealDirectory)pip, resultingPipDetails, pathTable);
                break;

            case PipType.Value:
                SetValuePipDetails((ValuePip)pip, resultingPipDetails, pathTable);
                break;

            case PipType.SpecFile:
                SetSpecFilePipDetails((SpecFilePip)pip, resultingPipDetails, pathTable);
                break;

            case PipType.Module:
                SetModulePipDetails((ModulePip)pip, resultingPipDetails, pathTable);
                break;

            case PipType.Ipc:
                SetIpcPipDetails((IpcPip)pip, resultingPipDetails, pathTable);
                break;

            default:
                Contract.Assume(false);
                break;
            }

            return(resultingPipDetails);
        }
示例#4
0
 private static void SetCopyFilePipDetails(CopyFile pip, PipDetails result, PathTable pathTable)
 {
     result.Source = new FileDetails()
     {
         Id = pip.Source.Path.Value.Value, Path = pip.Source.Path.ToString(pathTable)
     };
     result.Destination = new FileDetails()
     {
         Id = pip.Destination.Path.Value.Value, Path = pip.Destination.Path.ToString(pathTable)
     };
 }
示例#5
0
 private static void SetIpcPipDetails(IpcPip pip, PipDetails result, PathTable pathTable)
 {
     result.Payload            = pip.MessageBody.ToString(pathTable);
     result.PayloadFragments   = ConvertArgumentsToStringArray(pip.MessageBody, pathTable);
     result.IsServiceFinalizer = pip.IsServiceFinalization;
     result.IpcConfig          = JsonConvert.SerializeObject(pip.IpcInfo.IpcClientConfig);
     result.IpcMoniker         = pip.IpcInfo.IpcMonikerId.ToString(pathTable.StringTable);
     result.Dependencies       = pip.FileDependencies.Select(d => FileArtifactToFileDetails(d, pathTable)).OrderBy(d => d).ToList();
     result.StandardOutput     = new FileReference {
         Id = -1, Path = pip.OutputFile.Path.ToString(pathTable)
     };
 }
示例#6
0
        private static void SetCommonPipDetails(Pip p, PipDetails result)
        {
            IVisualizationInformation visualizationInformation = EngineModel.VisualizationInformation;
            PipGraph pipGraph    = visualizationInformation.PipGraph.Value;
            var      scheduler   = visualizationInformation.Scheduler.Value;
            var      context     = visualizationInformation.Context.Value;
            var      pathTable   = context.PathTable;
            var      symbolTable = context.SymbolTable;

            result.Id   = p.PipId.Value;
            result.Hash = p.SemiStableHash.ToString("X16", CultureInfo.InvariantCulture);
            result.QualifierAsString = p.Provenance != null?context.QualifierTable.GetCanonicalDisplayString(p.Provenance.QualifierId) : "";

            result.Description = p.GetDescription(context);
            result.State       = scheduler.GetPipState(p.PipId);

            result.Tags = p.Tags.IsValid ? p.Tags.Select(tag => pathTable.StringTable.GetString(tag)).ToList() : new List <string>();

            IEnumerable <Pip> dependents = pipGraph.RetrievePipImmediateDependents(p);

            result.DependantOf = dependents
                                 .Where(d => d.PipType != PipType.HashSourceFile)
                                 .Select(f => FromPip(f))
                                 .ToList();

            IEnumerable <Pip> dependencies = pipGraph.RetrievePipImmediateDependencies(p);

            result.DependsOn = dependencies
                               .Where(d => d.PipType != PipType.HashSourceFile)
                               .Select(f => FromPip(f))
                               .ToList();

            IEnumerable <ValuePip> valuePips = dependents.Where(pipId => pipId.PipType == PipType.Value).Cast <ValuePip>();

            result.Values = valuePips.Select(valuePip => ValueReference.Create(symbolTable, pathTable, valuePip));
        }
示例#7
0
 private static void SetSealDirectoryPipDetails(SealDirectory pip, PipDetails result, PathTable pathTable)
 {
     result.Directory = pip.Directory.Path.ToString(pathTable);
     result.SealKind  = pip.Kind.ToString();
     result.Contents  = pip.Contents.Select(f => FileArtifactToFileDetails(f, pathTable)).OrderBy(f => f).ToList();
 }
示例#8
0
 private static void SetModulePipDetails(ModulePip pip, PipDetails result, PathTable pathTable)
 {
 }
示例#9
0
 private static void SetSpecFilePipDetails(SpecFilePip pip, PipDetails result, PathTable pathTable)
 {
 }
示例#10
0
 private static void SetValuePipDetails(ValuePip pip, PipDetails result, PathTable pathTable)
 {
 }