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: 6 days 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 7 years ago)
- Default Branch: main
- Last Pushed: 2024-12-30T19:40:43.000Z (about 2 months ago)
- Last Synced: 2025-02-08T17:07:00.412Z (13 days ago)
- Topics: codingame, rust
- Language: Rust
- Homepage: https://crates.io/crates/rustsourcebundler
- Size: 88.9 KB
- Stars: 61
- Watchers: 4
- Forks: 12
- Open Issues: 7
-
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.rsuse std::path::Path;
extern crate rustsourcebundler;
use rustsourcebundler::Bundler;fn main() -> Result<(), Box> {
let mut bundler: Bundler = Bundler::new(Path::new("src/bin/mybin.rs"),
Path::new("src/bin/singlefile.rs"));
bundler.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](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