This section describes the analysis of Unreal Engine projects on Windows operating system. The instructions for checking projects under Linux\macOS are available by this link.
A specialized build system called Unreal Build System is used for building Unreal Engine projects. This system is integrated over the build system used by the Visual Studio environment (MSBuild) by utilizing autogenerated makefile MSBuild projects. This is a special type of Visual C++ (vcxproj) projects in which the execution of the build is relegated to the execution of a command calling a third-party utility, for example (but not necessarily), Make. The use of makefile projects allows working with source code of Unreal Engine from Visual Studio environment, taking advantage of such features as code autocompletion, syntax highlighting, symbol navigation, etc.
Because makefile MSBuild projects themselves do not contain full information, necessary to perform the compilation, and therefore, preprocessing of C/C++ source files, PVS-Studio does not support the analysis of such projects from within Visual Studio, or by PVS-Studio_Cmd.exe command line tool. Therefore, to check such projects with PVS-Studio, you can go two ways - monitoring of compiler invocations (Compiler Monitoring) and direct integration of the PVS-Studio.exe C/C++ analyzer in the Unreal Build Tool utility. Let's consider these options in more detail.
Unreal Build System uses the Visual C++ compiler-cl.exe for building under Windows. This compiler is supported by the system of PVS-Studio compiler monitoring on Windows. It can be both used from the C and C++ Compiler Monitoring UI (Standalone.exe) or from CLMonitor.exe command line tool.
Compiler monitoring can be launched manually from within the Compiler Monitoring UI or it can be assigned to the event of starting\ending builds in Visual Studio. The result of the analysis by the monitoring system is a plog XML report file, which you can open from the Visual Studio PVS-Studio extension, or convert to one of the standard formats (txt, html, csv) using the PlogConverter special tool.
A more detailed description for the system of compiler monitoring is available in this section of the documentation. We recommend using this way to run the analysis when you want to check it for the first time and get acquainted with the analyzer, as this way is the easiest one to set up.
A general description of how to integrate PVS-Studio C/C++ analyzer into any build system directly is available here.
In case of Unreal Build System, the developers from Epic Games provide the opportunity to use PVS-Studio through the direct integration with the build utility called Unreal Build Tool, starting from version 4.17.
Unreal Build Tool allows running the analysis by PVS-Studio, by adding the following flag to the build command line:
For example, a full command line for running Unreal Build Tool might look as follows:
UnrealBuildTool.exe UE4Client Win32 Debug -WaitMutex -FromMsBuild -StaticAnalyzer=PVSStudio -DEPLOY
To enable the analysis when running from Visual Studio, open the project properties by going to Properties-> Configuration Properties-> NMake and add the -StaticAnalyzer=PVSStudio flag to the options for project's build and rebuild commands (Build Command Line/Rebuild All Command Line)
The path to the file with the results of the analysis will be displayed in the Output (Build) window of Visual Studio (or stdout if you've run the Unreal Build Tool manually from the command line). This analysis results file has a "unparsed" format - you can open it from the IDE by 'PVS-Studio|Open/Save|Open Analysis Report' command, selecting the 'unparsed output' file type, or you can convert this results file by using the PlogConverter utility, as described in the section above for the XML log.
Before starting the analysis, you should enter your license for the analyzer - open Visual Studio and in the 'PVS-Studio|Options...Registration' window enter your license information (please note, that before Unreal Engine version 4.20, UBT was unable to get the license information from the PVS-Studio common settings file; in case UBT does not recognize a license entered via UI, you should create a separate license file with the name of PVS-Studio.lic and place it to the '%USERPROFILE%\AppData\Roaming\PVS-Studio' directory).
Note 1: the usual Visual Studio trial mode for PVS-Studio does not work with the Unreal Build Tool projects. In order to try the analyzer, you can use the Compiler Monitoring from the Compiler Monitoring UI (the analysis results can be viewed in Visual Studio as well, by saving the analysis log after the check from Compiler Monitoring UI and opening them from VS). Email us at email@example.com, if you want a trial license to test out the integration with Unreal Build Tool.
Note 2: integration of PVS-Studio with Unreal Build Tool currently supports not all of analzyer's settings, available from Visual Studio (PVS-Studio|Options...). Currently, supported are the specification of exclude directories via ''PVS-Studio|Options...|Don't Check Files' and filtering of the loaded analysis results through 'Detectable Errors'.
In addition, in the UBT integration, the analyzer runs with only the General Analysis diagnostics group enabled. If you are interested in running the analyzer for other groups of diagnostics available in PVS-Studio, please write us through firstname.lastname@example.org.