Hey guys, I’ve written myself a script that bundles C++ code in a project (i.e. across multiple files) into a single file to ship up to CG (with CodinGame Sync, for example), and I figured someone else might find it useful.
It does this by detecting include and pragma-once macros, as well as include guards, and source (.cpp) files to accompany any included headers.
There were a few motivations for creating this script:
- Making it easier to do local debugging with breakpoints etc in a proper IDE, since most IDEs can be configured to automatically run the script in the background when you compile/run tests.
- Helping to optimise code a little to ease the burden of CG’s limitations, for example, minification, or something like what Magus indicates he does for comps (see here). - I figure rather than resigning to the immediate limitations in front of us, we should use our skills and tools to work around them!
- Making it a little easier to develop our CG software more ergonomically and idiomatically, especially for newcomers
- Hopefully encouraging a small collaborative project
You can download it from this repo, which also contains more complete documentation on what it does and how to use it:
This is a tentative to-do list of additional features I’ve considered, but have not yet implemented.
It is not intended to be a complete list. More concrete plans will be reflected in the issues section of the repo.
- Code minification (with varying levels of intensity)
- CLI flags for including
#pragmaoptimisation macros at the top of the bundled code
- Optionally performing some preprocessing optimisation within the script to squeeze out more performance (such as techniques described here)
I’ll implement these on an as-needed basis for my own use, or if there are community requests for them.
Feel free to request additional features or report problems (via the issues section of the repo). (or even implement changes yourself - pull-requests are welcome!)
I also plan to create, or encourage, similar bundlers for other languages.