Iwyu

I’ve just submitted a change to master branch on GitHub to convert the engine to an “include what you use” model. This is a big change!

Rather than including big headers like Engine.h and UnrealEd.h everywhere, each header now includes just what it needs. There will doubtless be a few teething problems switching over to this, but we’ve been seeing a 20-50% improvement on build times in its staging branch, so hopefully it’ll be worthwhile.

Here’s the commit description (4ba423868f9b6349d8f80a6e36a7e040cd003d50) with some more specifics:

The tool I’ve used to convert the codebase over is pretty custom, but we’re going to be looking at fixing it up to run over our internal games in the next few weeks. Feel free to check it out if you like, but don’t expect it to work without a lot of tweaking just yet.

In the meantime, the intent was to leave most of the big monolithic headers (Engine.h etc…) alone so as to not break backwards compatibility, but you may run into the odd thing missing.

This is awesome!

Oh nice! This will make it easier to maintain our own game code!

It’s good. Thanks a lot.
I have a question. Why does “iwyu” perform better than using precompiled monolithic headers on full rebuild??

Sounds awesome. How do I activate this feature? I just went through this article
https://docs.unrealengine.com/latest/INT/Programming/UnrealBuildSystem/IWYUReferenceGuide/index.html
and tried to use the
PCHUsageMode.UseSharedPCH
But I can’t include this in my game.build.cs file. Anything I am missing?

Hi Ben, is there some example how to use this tool convert pre IWYU codebase to required convention? I would like to know this as I spent past day just fighting compile errors and various stuff in many plugins that are required to use this. I would like to enable and convert my project with it to save on typing and pulled hairs… :slight_smile: Thank you.

EDIT:
I mean this one: Tool used to generate this transform is at Engine\Source\Programs\IncludeTool

I’m also interested in running include tool for our game project. We’re making quite the mess here with all those fine includes… half of them probably unnecessary… :smiley:

I think the main change is that this allows us to decouple the contents of precompiled headers from a successful compile. Previously, we manually included precompiled headers everywhere, so it wasn’t easy to remove less used things from them without having to add them to a bunch of places that included them. As part of the dependency analysis that IncludeTool does, we can generate statistically good coverage for the modules that consume it.

I’ve written up some brief documentation on how to use IncludeTool and committed it to the 4.17 branch. The program itself hasn’t changed in a while, so it should apply to older versions too. Use it at your own risk!

https://github.com/EpicGames/UnrealEngine/tree/4.17/Engine/Source/Programs/IncludeTool

Hi, the link to the github page 404’d. Is the include tool being deprecated or something?

You need to be logged in and a member of the github Epic Games organization thing.

I just tried to use this finally, but can’t seem to get it to work. I installed the cross compile toolchain for 4.18, copied my project to a subfolder of UnrealEngine for it to find it, but the command from the readme doesn’t work:


C:\UnrealEngine>Engine\Binaries\DotNET\IncludeTool.exe -Mode=Optimize -Target=BrickadiaEditor -Platform=Linux -Configuration=Development -WorkingDir=C:\IncludeToolWorking -OutputDir=C:\IncludeToolOutput -SourceFiles=-/Engine/... -OptimizeFiles=-/Engine/... -OutputFiles=-/Engine/...
Caching contents of C:\UnrealEngine...
No files found after running source file filter

[USER=“1345”]Ben Marsh[/USER] am I missing something here? Does it have to be run from a specific folder?

Just discovered this post been messing round with this trying to get it to work in 4.22, been getting a bunch of headaches, thinking it might be easier to downgrade my project to 4.17, without opening the editor and breaking assets, and getting it working that way, posted an answerhub question about my progress, which at least gets as far as trying to create the dependency model but then explodes trying to resolve the build hash defines, which I’m assuming were not there in 4.17? anyway heres the answerhub link, InputTool commandline args - Community & Industry Discussion - Unreal Engine Forums