rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
687 stars 149 forks source link

Allow to use only as library #618

Closed Shatur closed 2 years ago

Shatur commented 2 years ago

When working with FPGA I use this crate as a build dependency library to generate code (because my FPGA configuration changes). But this also means that I have to pull some extra deps, such as clap. I would like to request to separate executable and generation library.

Emilgardis commented 2 years ago

This could be done by making bin deps default opt-in, and then you'll depend on svd2rust with svd2rust = {version = "*", default-features = false}

e.g

New feature bin that pulls in clap and everything else we're using in the svd2rust binary. This feature is enabled by default

this just has to be implemented, feel free to make a pr!

Shatur commented 2 years ago

New feature bin that pulls in clap and everything else we're using in the svd2rust binary. This feature is enabled by default

But what main.rs will represent without bin dependencies? The command cargo build --no-default-features will produce a binary since main.rs is present. More idiomatic would use workspace and two crates - library and executable.

Emilgardis commented 2 years ago

I don't see the issue, binary packages can specify required-features

Shatur commented 2 years ago

Oh, got it, will send a PR then.