Detecting `cargo doc` invocation from build scripts

⚓ Rust    📅 2025-09-18    👤 surdeus    👁️ 9      

surdeus

Warning

This post was published 44 days ago. The information described in this article may have changed.

My crate builds C++ with cmake inside of build scripts.
But for building documentation (with cargo doc) I would want to skip the C++ part: as required libraries are not available in the pipeline at that point.
I can do this with a feature flag and build docs like cargo doc --features build-docs, but this seems redundant.

Maybe cargo doc already sets some envars I can reliably check against?

9 posts - 3 participants

Read full topic

🏷️ Rust_feed