#single-file #source #source-file #bundle #build #merge

bin+lib rustsourcebundler

Bundle the source code of a rust cargo crate in a single source file

20 releases (10 breaking)

new 0.13.0 Jun 17, 2024
0.11.7 Apr 19, 2024
0.11.6 Jan 30, 2024
0.11.4 Nov 15, 2023
0.1.1 Jun 27, 2017

#794 in Command line utilities

Download history 45/week @ 2024-02-27 182/week @ 2024-03-05 6/week @ 2024-03-12 1/week @ 2024-03-26 13/week @ 2024-04-02 149/week @ 2024-04-16 6/week @ 2024-04-23 19/week @ 2024-05-28 242/week @ 2024-06-11

261 downloads per month

MIT license

16KB
259 lines

CI coveralls crates.io

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

Dependencies

~4–5.5MB
~100K SLoC