We have a UBT plugin that provides code generation for our custom ECS framework (registration traits describing entity data type capabilities, auto registration of code for working with those types, etc). We were walking the UHT output and property metadata and creating custom generated .mggenerated.h and .mggenerated.cpp files for each relevant header and module.
We were using the CompileOutput to automatically make UBT pick up these generated files, which replaced a custom patch we had in UBT in previous engine versions to pick up generated files with those extensions.
Now when doing the unreal 5.8 merge we notice this functionality has been removed/deprecated. We were wondering if there was a particular reason this gets removed, or if there is another way to enable custom code generation as part of UBT/UHT framework?
We’ve tried to go back to our earlier patch of the UBT, which is as follows, but this appears to be flawed in unreal 5.8.
That patch now lives in UEBuildModuleCPP.cs, inside the GeneratedCppDirectories loop:
```
if (Directory.Exists(GeneratedDir))
{
string[] MgFiles = Directory.GetFiles(GeneratedDir, “*.mggen.cpp”);
foreach (string MgFile in MgFiles)
{
string FileName \= Path.GetFileName(MgFile);
string Key \= Prefix \+ FileName.Substring(0, FileName.Length \- ".mggen.cpp".Length) \+ ".mggen";
FileItem Item \= FileItem.GetItemByPath(MgFile);
GeneratedFiles.TryAdd(Key, Item);
}
}
```
The problem is that UBT enumerates a module’s generated .cpp inputs before UHT executes. The built in .gen.cpp are unaffected because their filenames already derived up front before UHT runs. A UHT exporter emitting .cpp files conditionally has no supported way to register those files as compile inputs, and the scan no longer works, because the only integration point is before UHT execution. Any help here would be greatly appreciated. Of course, we’d prefer not having to maintain patches of UBT.
(If we could hook into existing UHT codegen instead of having our own .mggenerated.h we need to include that would of course even be more amazing :))
[Attachment Removed]