Fixed a couple of bugs that were frequently preventing correct detection of mod decls; now correctly ignores commented out mod decls.
Hi (again), as I mentioned in my previous thread, I've created a script for bundling Rust projects (i.e. with multiple files) into a single file to ship to CG (with CodinGame Sync, for example), and I figured someone else might find it useful.
It does this by detecting empty mod declarations (e.g.
mod my_mod;, searching for the associated file according to rust's rules (looks for either .rs or /mod.rs, searched in that order).
My motivations for doing this were similar to the reasons I created the C++ bundler, but in particular:
- Encouraging/facilitating idiomatic development practices
- Hopefully easing the burdens of CG's limitations a little (particularly that compiles in debug mode, which makes rust much slower compared to other languages than it is in the real world, and almost infeasible for reaching top rankings in multiplayer/contests, compared to C++)
- 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. For a more concrete idea of future plans, see the issues section of the repo.
- Supply a build-script, and cargo-configuration detection support, so that bundling can be integrated into the build process for CG rust projects.
- Local crate detection, so that you can crate up and re-use common code snippets or DIY-libraries you use across multiple puzzles/games
- Conditional-compilation emulation (e.g.
- More options, such as enabling/disabling crate detection
- Code minification (with varying levels of intensity)
- Optionally performing some preprocessing to improve code performance for games that require complex AI (and hopefully in doing so, bring rust's performance on CG closer to C++, as it should be)
- (Maybe) multi-line parsing to detect empty mod declarations that are language-compliant but currently missed by the script.
- (Maybe) Converting the script from Python3 into Rust, to integrate better with Rust's existing build-script tooling.
Note: Some of these features may be conditional on CG giving the OK for them, particularly optimisations (I know that straight-up local compilation to achieve release-mode performance is forbidden, for example).
I'll implement these on an as-needed basis for my own use, or possibly 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.
- I've already shared my C++ bundler
- It looks like someone has also created/found a similar tool for Java projects, described in this topic.