Why does bmcweb use so many headers? My build times are slow!
TL;DR, History
bmcweb at one point was a crow-based project. Evidence of this can still be seen in the http/.hpp files that still contain references to the crow namespaces. Crow makes heavy use of headers and template meta programming, and doesn't ship any cpp or implementation files, choosing to put everything in include once headers. As bmcweb evolved, it needed more capabilities, so the core was ported to Boost Beast, and what remains has very little similarity to crow anymore. Boost::beast at the time we ported took the same opinion, relying on header files and almost no implementation compile units. A large amount of the compile time is taken up in boost::beast template instantiations, specifically for boost::beast::http::message (ie Request and Response).
The initial solution that gets proposed is to just move everything as it exists to separate compile units, making no other changes. This has been proposed and implemented 3-4 times in the project, the latest of which is below. The intent of this document is largely to save effort for the next person, so they can at least start from the existing prior attempts.
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/49039
Moving to cpp files without handling any architecture has the net result of making total compilation slower, not faster, as the slowest-to-compile parts end up getting compiled multiple times, then the duplicates deleted at link time. This isn't great for the end result.
To actually effect the result that we'd like to see from multiple compile units, there have been proposed a few ideas might provide some relief;