public override void FinalizeOutput(ReadOnlyTargetRules Target, TargetMakefile Makefile) { FileReference OutputFile; if (Target.ProjectFile == null) { OutputFile = FileReference.Combine(UnrealBuildTool.EngineDirectory, "Saved", "PVS-Studio", String.Format("{0}.pvslog", Target.Name)); } else { OutputFile = FileReference.Combine(Target.ProjectFile.Directory, "Saved", "PVS-Studio", String.Format("{0}.pvslog", Target.Name)); } List <FileReference> InputFiles = Makefile.OutputItems.Select(x => x.Location).Where(x => x.HasExtension(".pvslog")).ToList(); // Collect the prerequisite items off of the Compile action added in CompileCPPFiles so that in SingleFileCompile mode the PVSGather step is also not filtered out List <FileItem> AnalyzeActionPrerequisiteItems = Makefile.Actions.Where(x => x.ActionType == ActionType.Compile).SelectMany(x => x.PrerequisiteItems).ToList(); FileItem InputFileListItem = Makefile.CreateIntermediateTextFile(OutputFile.ChangeExtension(".input"), InputFiles.Select(x => x.FullName)); Action AnalyzeAction = Makefile.CreateAction(ActionType.Compile); AnalyzeAction.CommandPath = UnrealBuildTool.GetUBTPath(); AnalyzeAction.CommandArguments = String.Format("-Mode=PVSGather -Input=\"{0}\" -Output=\"{1}\"", InputFileListItem.Location, OutputFile); AnalyzeAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory; AnalyzeAction.PrerequisiteItems.Add(InputFileListItem); AnalyzeAction.PrerequisiteItems.AddRange(Makefile.OutputItems); AnalyzeAction.PrerequisiteItems.AddRange(AnalyzeActionPrerequisiteItems); AnalyzeAction.ProducedItems.Add(FileItem.GetItemByFileReference(OutputFile)); AnalyzeAction.DeleteItems.AddRange(AnalyzeAction.ProducedItems); Makefile.OutputItems.AddRange(AnalyzeAction.ProducedItems); }
/// <summary> /// Adds aall input/output properties of a CSProject to a hash collection /// </summary> /// <param name="Hasher"></param> /// <param name="Project"></param> /// <returns></returns> public static bool AddCsProjectInfo(this HashCollection Hasher, CsProjectInfo Project, HashCollection.HashType HashType) { // Get the output assembly and pdb file FileReference OutputFile; if (!Project.TryGetOutputFile(out OutputFile)) { throw new Exception(String.Format("Unable to get output file for {0}", Project.ProjectPath)); } FileReference DebugFile = OutputFile.ChangeExtension("pdb"); // build a list of all input and output files from this module List <FileReference> DependentFiles = new List <FileReference> { Project.ProjectPath, OutputFile, DebugFile }; DependentFiles.AddRange(Project.CompileReferences); if (!Hasher.AddFiles(DependentFiles, HashType)) { return(false); } return(true); }