https://github.com/lpenz/rust-sourcebundler
Bundle the source code of a binary in a crate into a single .rs file to be used in single-file programming competition sites
https://github.com/lpenz/rust-sourcebundler
codingame rust
Last synced: 10 months ago
JSON representation
Bundle the source code of a binary in a crate into a single .rs file to be used in single-file programming competition sites
- Host: GitHub
- URL: https://github.com/lpenz/rust-sourcebundler
- Owner: lpenz
- License: mit
- Created: 2017-06-13T20:41:39.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-03-17T19:24:12.000Z (11 months ago)
- Last Synced: 2025-03-28T17:09:47.220Z (11 months ago)
- Topics: codingame, rust
- Language: Rust
- Homepage: https://crates.io/crates/rustsourcebundler
- Size: 90.8 KB
- Stars: 62
- Watchers: 3
- Forks: 12
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/lpenz/rust-sourcebundler/actions/workflows/ci.yml)
[](https://coveralls.io/github/lpenz/rust-sourcebundler?branch=main)
[](https://crates.io/crates/rustsourcebundler)
# rust-sourcebundler
Bundle the source code of a rust cargo crate in a single source file.
Very useful for sending the source code to a competitive programming site that
accept only a single file ([codingame](https://codingame.com), I'm looking at
you) and still keeping the cargo structure locally.
## Usage
Add the following snippet to your *Cargo.toml*:
```toml
[package]
(...)
build = "build.rs"
[build-dependencies]
rustsourcebundler = { git = "https://github.com/lpenz/rust-sourcebundler" }
```
And create the file *build.rs* with the following:
```rust
//! Bundle mybin.rs and the crate libraries into singlefile.rs
use std::path::Path;
extern crate rustsourcebundler;
use rustsourcebundler::Bundler;
fn main() {
let mut bundler: Bundler = Bundler::new(Path::new("src/bin/mybin.rs"),
Path::new("src/bin/singlefile.rs"));
bundler.crate_name("");
bundler.run();
}
```
You can use the code inside the *example* directory of this repository
as a starting point.
## Similar Projects
* [slava-sh/rust-bundler](https://github.com/slava-sh/rust-bundler)
* [Endle/rust-bundler-cp](https://github.com/Endle/rust-bundler-cp)
* [MarcosCosmos/cg-rust-bundler](https://github.com/MarcosCosmos/cg-rust-bundler)
written in python