如何在 Cargo.toml 中启用每个平台的 crate 功能? [英] How to enable crate features per-platform in Cargo.toml?

查看:33
本文介绍了如何在 Cargo.toml 中启用每个平台的 crate 功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Cargo.toml 配置中启用每个平台的 crate 功能?我试过两种方法,都不行.

How do I enable crate features per-platform in a Cargo.toml configuration? I've tried two methods, neither of which work.

方法一:

[target.'cfg(windows)'.dependencies.rusqlite]
version = "0.19.0"
features = ["bundled"]

[target.'cfg(unix)'.dependencies.rusqlite] # same behavior with cfg(not(windows))
version = "0.19.0"

方法二:

[target.'cfg(windows)'.dependencies]
rusqlite = { version = "0.19.0", features = ["bundled"] }

[target.'cfg(unix)'.dependencies]
rusqlite = { version = "0.19.0" }

我试图仅在 Windows 平台上使用捆绑"功能,但无论我尝试以哪种方式配置货物,在 Ubuntu 系统上构建时,它总是添加捆绑"功能.

I'm trying to use the 'bundled' feature only on Windows platforms, but regardless of which way I try to configure cargo it always adds the 'bundled' feature when building on an Ubuntu system.

是否可以只在一个平台上启用功能?

Is it possible to enable features only on one platform?

推荐答案

是否可以只在一个平台上启用功能?

Is it possible to enable features only on one platform?

不,这是不可能的,因为 货物问题 #1197.

No, it is not possible, due to Cargo issue #1197.

另见:

这篇关于如何在 Cargo.toml 中启用每个平台的 crate 功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆