13 releases (8 breaking)
0.11.2 | Feb 10, 2023 |
---|---|
0.11.0 | Oct 23, 2022 |
0.9.0 | Oct 18, 2021 |
0.6.0 | Aug 12, 2018 |
0.1.1 | Jun 27, 2017 |
#1065 in Command line utilities
15KB
241 lines
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, I'm looking at you) and still keeping the cargo structure locally.
Usage
Add the following snippet to your Cargo.toml:
[package]
(...)
build = "build.rs"
[build-dependencies]
rustsourcebundler = { git = "https://github.com/lpenz/rust-sourcebundler" }
And create the file build.rs with the following:
//! Bundle mybin.rs and the crate libraries into singlefile.rs
use std::path::Path;
extern crate rustsourcebundler;
use rustsourcebundler::Bundler;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut bundler: Bundler = Bundler::new(Path::new("src/bin/mybin.rs"),
Path::new("src/bin/singlefile.rs"));
bundler.crate_name("<crate name>");
bundler.run()?;
Ok(())
}
You can use the code inside the example directory of this repository as a starting point.
Similar Projects
- slava-sh/rust-bundler
- Endle/rust-bundler-cp
- MarcosCosmos/cg-rust-bundler written in python
Dependencies
~3–4MB
~94K SLoC