How to access current cargo profile (build, test, bench, doc, …) from the build script (build.rs)

流过昼夜 提交于 2019-12-01 17:08:34

问题


I want to write a custom build.rs script that generates some diagrams to accompany the documentation for a crate I'm working on. I want this script to run only when I run cargo doc, not the other profiles (cargo build, cargo test, ...). What would be the best way to do that?

I was hoping that cargo would pass this info to build.rs in the PROFILE env variable, but that seems to only contain "debug" or "release".


回答1:


This is not possible as of Rust 1.38. Cargo issue #4001 tracks the possibility of supporting this in some fashion.



来源:https://stackoverflow.com/questions/36446642/how-to-access-current-cargo-profile-build-test-bench-doc-from-the-bui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!