5 ms·
Some people might not know this but Epic actually did a lot of this automatically within Unreal Engine by writing their own equivalent of CMake. The whole codeb
by speps 3y ago
Some people might not know this but Epic actually did a lot of this automatically within Unreal Engine by writing their own equivalent of CMake. The whole codebase is going through UnrealBuildTool which auto generates headers as well. It calls compilers, linkers, etc. for each supported platform.
It allows them to enable the "unity build" stuff automatically for example, and on a per file basis as well. If you have a file checked out locally (in Perforce terms), it won't include it into the usual unity compilation unit for it and will compile it on its own as it's likely it's one you're going to edit a lot if it's one you've got checked out.
Anyway, I thought it was an interesting datapoint as I think it's quite unique. To the level of Boost using a modified fork of Jam at some point...
- maccard 3y agoUBT is a blessing and a curse. I've spent a lot of time with it, and contributee to it. It's definitely not the fastest of build tools, the change detection takes a few seconds even on powerful hardware. The way it handles UHT (the codegen step of unreal) isn't great either. It has a nasty habit of getting itself stuck, and it's got a horrific architectural decision of only allowing one instance of the process to run at a time (and see previous point, it gets stuck). Combine those two with modern IDEs that call the build tool in the background and you bet a messy situation. But the adaptive unity build is probably one of the coolest features I've ever seen in a build system
- 8n4vidtmkvmk 3y agoDo they offer the header generator as a standalone tool? I figured this was possible but haven't seen anything that does it. I hate writing function signatures twice with subtle differences like default args and overrides. Waste of my time.
- dataflow 3y agoIs header generation substantially faster than compilation? I guess it skips codegen and instead replaces it with header generation, but isn't most of the time spent in parsing/semantic analysis? Or is header generation done in some hacky way that's much faster than full parsing?
- netheril96 3y agoI think the point of header generation is not to save compilation time, but to save developer time. Saving them from writing the same thing twice, in header and in implementation.
- 8n4vidtmkvmk 3y agoExactly this. I already have to wait 3 to 10 minutes for compiles. Can't imagine header generation will add substantially more.
- maccard 3y agoIt's not that sort of header generation, it's a straight up code generator. You can write #include "MyClass.gen.h" UCLASS() class UMyClass : public UObject { GENERATED_BODY() public: UPROPERTY(BlueprintReadWrite, EditAnywhere ) float MyFloat = 1.f; UPROPERTY() APlayerController* MyPc; }; in a header, and you get garbage collection, serialisation, script binding, editor UI out of the generated code.
- maccard 3y agoThe header gen is much faster than compilation, and is just a code generator. My project takes about 20 minutes for a clean build, the header generation is about 10 seconds at the beginning.
- dataflow 3y agoHow is that even possible? Is header generation hacky? Or does it really generate the AST?
- maccard 3y agoIt generates a header and cpp file for each header that it parses. It generates some pretty rudimentary c++ with a bunch of macros, and it looks like very generated code. It's then compiled after, but the nature of the generated code is fairly simple c++ so the cost isn't enormous
- maccard 3y agoIt's not that sort of tool. It's called UnrealHeaderTool, but it's a straight up code generator.