Why UBT is often recompiling all my files?

UBT recompiles all my files very often, even when I change only one file. Why?

Notes:

  • it only recompiles my own files, not UE4 files,

  • I am working on an editor plugin (with a custom FEdModule) so hot-reload is not accessible (except with "Window > Dev tool > Module > Find the module name in the loooong list > Recompile takes a long time ; but this does not always work, for example when I change anything related to Slate ).

  • I don’t know how to fill MyPluginPrivatePCH.h, I just have one line for now:

         #include "PBModule.h"
    

Long build times usually means too many dependencies. For example, the slate code is probably getting rebuilt everytime you build your module, because now it is a dependency. Hence moving slate headers to the MyPluginPrivatePCH.h would be a good way of reducing this build time. PCH is basically pre-compiled headers. In your case, it will just link your module to all the libraries you are using in PCH and wouldn’t need to do that again. Unless, you modify your PCH, your build times should be local to whatever is being built within the module.

You can find more about PCH here, Precompiled header - Wikipedia

I am quiet new as well, so someone can correct me if I am wrong.

Thanks. It only recompile my files, not UE4 files, so Slate is not recompiled every time. Should I put all my custom headers in the PCH?

When you change anything in header file UHT might want to regenerate reflection header files which will cause all cpp files in module to recompile

Thanks! Is it possible to prevent this? Or is there a workaround?

I don’t think so, whatever UBT it is usally needed, maybe moving some header files to PCH might help too as kishoreven said, what i’m saying it’s from my own observation. Deviding your plugin in to more modules will help you, you need to divide it to runtime and editor module anyway if you plan to make any editor code that affects the packaged game.

Could you add this in your answer please?

Sorry for the late reply. 's answer is about right. I think it has to do greatly with come up with an architecture for your plugin and sort of iterating over the plan to divide them into modules. Also you don’t have to add the header files from your module into the pch.