Description
The issue of needing to be able to disable things like pkg-config checks in build scripts for FFI -sys
crates has been raised previously (for example this or this). We now have cfg(doc)
as of Rust 1.41, however it seems that this is not used when running build scripts. Why? Please could this be changed/fixed?
I have just successfully converted some of my crates to use cfg(doc)
outside of the build script, from previously using the dox
feature technique. Wanting to rid my crates now of the dox
feature I tried fixing the last remaining use of it - the build script. Unfortunately I have found that cfg(doc)
does not work there, nor does CARGO_CFG_DOC
. Looking at the output from cargo doc -vv
it is clear that cargo is not signalling doc mode to rustc
when executing the build script.
I am aware of the rustc-args
key of docs.rs
metadata, and I believe that setting it to ["--cfg", "doc"]
may work around this problem for docs.rs, allowing me to ditch my dox
feature.
However, (1) why am I having to implement such a workaround, why is cargo not passing it along itself? (2) although this helps in the docs.rs case, it does not enable users generating local documentation to get to do so without the presence of the system library, and it would be nice to allow them to do so, because why have such a restriction.
I could leave the dox
feature in place to address point 2, but it only helps for direct generation of crate docs, not so much when it's a dependency of something else. Additionally, it complicates things compared to cargo just passing --cfg doc
along, and I don't really want the messy cruft of keeping dox
around.
I'm using the Debian Sid cargo package, which is currently version 1.42.1 (0.43.1). I did check through the cargo changelog and saw no signs that this has already been addressed.