Crate deps_gen

Source
Expand description

§deps-gen

Allows to generate files from Cargo.lock and a provided template at build-time

§Example

The following will build a file named src/deps.rs.

In Cargo.toml, add the following line:

[build-dependencies]
deps-gen = "*"

then in your build.rs:

use deps_gen::gen_deps;
 
fn main() {
    gen_deps();
}

Add src/deps.template.rs:

#[allow(dead_code)]

pub struct License {
    pub name: &'static str,
    pub version: &'static str,
}

impl License {
    pub fn all() -> Vec<Self> {
        vec![
            //{}{{#each dependencies}}
            Self {
                name: "{{name}}",
                version: "{{version}}",
            },
            //{}{{/each}}
        ]
    }
}

See readme for more details

Structs§

Configuration
Configuration struct

Enums§

TemplateSource

Functions§

gen_deps
For lazy people (like me 😉) the default configuration will take src/deps.template.rs to generate src/deps.rs
gen_deps_with_conf
Detailed generator, allowing to customize configuration