Hello GN people-
Does anyone have any best-practices guidance on generating semi-global "configuration" header files? It's sometimes desirable to convert build args into macros so that the configuration can be accessible to the program being built.
Examples include things like version strings, debug/release information, configuration flags that might be clearer as #define directives instead of compile flags.
One obvious way is to do it early in the build itself via a custom action. This is straightforward; a custom action takes the various arguments and stamps out a file. This does need to be maintained as the arguments change over time, though, with new arguments plumbed through to the emission script.
Another way might be to use write_file, so that this happens at configuration-time, but then of course the challenge is getting the args into a C header format.
If you've solved this and feel like sharing any wisdom learned along the way, I'd love to hear it! I suspect the answer is simply "write the action, plumb the relevant args through it, emit a .h file, keep it up to date" but thought I'd ask in case there's a less manual trick.
Thanks,
Charles