我如何仅获取和编译Dev依赖性?
RUST cargo.toml
规范文件允许开发依赖关系节,例如[dev-depentencies]
cargo.toml :
[dev-dependencies]
tempdir = "0.3"
获取和编译这些开发依赖性的命令是什么?
需要明确的是,我想获取并仅编译[DEV依赖性]
。 链接问题不同之处在于,它指的是获取和编译 all 依赖关系,然后构建应用程序。
The Rust Cargo.toml
specification file allows for development dependencies section, e.g. [dev-dependencies]
Cargo.toml:
[dev-dependencies]
tempdir = "0.3"
What is the command to fetch and compile those development dependencies?
To be clear, I want to fetch and compile only the [dev-dependencies]
. The Linked question differs in that it regards fetching and compiling all dependencies and then building the application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有足够的声誉,所以我只是回答。
如您的链接所声明和 nofollow noreferrer“> >,不可能从Dev依赖性中“构建”二进制文件。
是偷偷摸摸的,可能是您可以在#[CFG(test)]下放置一些功能并运行
货物测试
,以便可以实现您的目标。一种更合适的方法,使用
货物
使用功能标志在cargo.toml和cargo命令中进行选择性构建。您可以查看货物命令以切换功能在这里 and “ nofollow noreferrer”>可选依赖性 。I do not have enough reputation so I just answer.
As declare by your link and rust-by-example, it is impossible to "build" a binary from dev-dependencies.
To be sneaky, may be you can put some function under #[cfg(test)] and run
cargo test
so that your goal can be achieved.A more appropriate way to selectively build by
cargo
using the feature flag, in cargo.toml and cargo command. You can take a look at the cargo command to toggle feature here and optional dependencies which help control categorizing of features.