Description
With docs.rs out, we’ve noticed a problem with cargo running build.rs
scripts when documenting each crate, while it shouldn’t be necessary in majority of the cases.
Namely, most of the crates use build.rs scripts for one of these three large categories:
- Native library discovery (pkgconfig/etc);
- Building of dependencies written in other languages (gcc-rs/etc);
- Generating rust code (syntex/lalrpop/etc).
First and second use case will not influence the resulting documentation in meaningful ways, while the third use-case almost always will. First and second use-cases are target-dependent and may require cross-compilation toolchains, whereas the third use-case as well as documentation generation are obviously target-agnostic and can be done without any extra tooling or knowledge about the target platform.
It is counter-productive to not make any distinction between these cases. A project like docs.rs ideally shouldn’t need to install any native dependencies (see https://github.com/onur/docs.rs/issues/23) in order to generate documentation (because they are irrelevant for documentation generation purposes!)
There’s multiple ways one could proceed here:
- Introduce
generate.rs
, do not runbuild.rs
scripts oncargo doc
; - Introduce extra keys to
Cargo.toml
(e.g.run_build_script_for_docs = false
) defaulting to not running build.rs before generating documentation and making people using third use case specify that variable to true; - The least breaking change would be to add a way in cargo API to not run build.rs scripts when building docs, so docs.rs could implement some sort of scheme itself (e.g. via
[metadata]
Cargo.toml section instructing docs.rs to runbuild.rs
); - etc.
cc @onur