Make `clap` optional for build scripts
There is no need in clap when we use cbindgen in a build script.
I'd like to do this too. rust-bindgen has the same problem.
Unfortunately - https://github.com/rust-lang/cargo/issues/1982
You can use features for this.
Was able to find a potential workaround here for the cargo issue.
[[bin]]
name = "mybinary"
path = "src/main.rs"
required-features = ["binaries"]
[dependencies]
docopt = { version = "0.8.1", optional = true }
[features]
binaries = ["docopt"]
Unfortunately that would require all users to install the cbindgen binary with cargo install cbindgen --features=binary or else they'll get a 'descriptive' error. This could be okay.
Looks like this was already done, here: https://github.com/mozilla/cbindgen/commit/6748b78c0bc434d6b7c8d72c0a6a56053b2f7555
And you can disable building with clap by disabling the default features. E.g. this in your own Cargo.toml:
cbindgen = { version ="0.25", default-features = false }