UBT GenerateClangDatabase is NOT incremental and recreates whole compile_commands.json each time

TLDR: -NoExecCodeGenActions

I think I found a workaround/fix to this issue.
There is a hidden flag in UnrealEngine/Engine/Source/Programs/UnrealBuildTool/Modes/GenerateClangDatabase.cs


		/// <summary>
		/// Execute any actions which result in code generation (eg. ISPC compilation)
		/// </summary>
		[CommandLine("-ExecCodeGenActions")]
		[CommandLine("-NoExecCodeGenActions", Value = "false")]
		public bool bExecCodeGenActions = true;

which controls generation of *.generated.h files.

So adding -NoExecCodeGenActions fixes this issue for my use case.
Execution time is decreased from 45sec to roughly 3sec.
(but have in mind that whole Project and Engine must be compiled already)

I’m not sure if this is optimal though since 3 sec is still pretty long for something that should be run for each compilation attempt. For comparison, changing one .cpp file in my Project requires around 2-5sec for its recompilation. So additional 3sec would make noticeable difference.