如何从构建脚本 (build.rs) 访问当前的货物配置文件(构建、测试、工作台、文档……) [英] How to access current cargo profile (build, test, bench, doc, ....) from the build script (build.rs)
问题描述
我想编写一个自定义的 build.rs
脚本,该脚本生成一些图表以伴随我正在处理的板条箱的文档.我希望此脚本仅在我运行 cargo doc
时运行,而不是其他配置文件(cargo build
、cargo test
、...).最好的方法是什么?
我希望 Cargo 将这个信息传递给 PROFILE
环境变量中的 build.rs
,但这似乎只包含调试"或发布".
从 Rust 1.47 开始这是不可能的.货物问题 #4001 跟踪以某种方式支持这一点的可能性.>
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".
This is not possible as of Rust 1.47. Cargo issue #4001 tracks the possibility of supporting this in some fashion.
这篇关于如何从构建脚本 (build.rs) 访问当前的货物配置文件(构建、测试、工作台、文档……)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!