Obtaining paths for includes and directives from the UBT

Hello, this isn’t a bug but rather a request for information. We are working on a project where we need to obtain all of the includes and directives for the title when compiling. Is it possible to obtain the includes paths and preprocessor directives for each source file by parsing UBT?

[Attachment Removed]

Steps to Reproduce[Attachment Removed]

Hi [mention removed]​,

Yes, it is possible to obtain the include paths and preprocessor definitions used during compilation by running the following UBT command:

"UE_PATH\UnrealBuildTool.exe" MyProjectEditor Win64 Development -Project="PROJECT_PATH\MyProject.uproject" -Game -Engine -Mode=GenerateClangDatabaseThis generates a compile_commands.json file with one entry per source file. The file is typically written to the Unreal Engine root directory used in the command.

Include Paths

Each entry references a compiler invocation, typically via response files (.rsp). These response files reference a shared .rsp (e.g. *.Shared.rsp). If you check the information of these .rsp, they contain the full list of include paths (marked with /I).

Preprocessor directives

Preprocessor definitions are also available, but split across different files:

  • .rsp files also include /D definitions
  • Force-included headers (via /FI) → files like Definitions.<Module>.h containing additional #define macros

Parsing UBT rule files directly is generally not sufficient to retrieve this information, as the final include paths and definitions are resolved during the build process, but could take a look if needed.

Best Regards,

Joan

[Attachment Removed]