rustsourcebundler

Crates.iorustsourcebundler
lib.rsrustsourcebundler
version0.13.0
sourcesrc
created_at2017-06-27 19:00:03.718775
updated_at2024-06-17 16:45:00.087154
descriptionBundle the source code of a rust cargo crate in a single source file
homepagehttps://github.com/lpenz/rust-sourcebundler
repositoryhttps://github.com/lpenz/rust-sourcebundler.git
max_upload_size
id21018
size36,869
Leandro Lisboa Penz (lpenz)

documentation

README

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

Commit count: 85

cargo fmt