cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

Make `clap` optional for build scripts

Open RazrFalcon opened this issue 8 years ago • 4 comments

There is no need in clap when we use cbindgen in a build script.

RazrFalcon avatar Jul 22 '17 13:07 RazrFalcon

I'd like to do this too. rust-bindgen has the same problem.

Unfortunately - https://github.com/rust-lang/cargo/issues/1982

eqrion avatar Jul 22 '17 15:07 eqrion

You can use features for this.

RazrFalcon avatar Jul 22 '17 15:07 RazrFalcon

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.

eqrion avatar Aug 18 '18 05:08 eqrion

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 }

val-ms avatar Sep 07 '23 23:09 val-ms