如何在 Cargo.toml 中启用每个平台的 crate 功能?
How to enable crate features per-platform in Cargo.toml?
如何在 Cargo.toml 配置中启用每个平台的 crate 功能?我试过两种方法,都不行。
方法一:
[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 平台上使用 'bundled' 功能,但无论我尝试以何种方式配置货物,它总是在构建时添加 'bundled' 功能Ubuntu 系统。
是否可以只在一个平台上启用功能?
Is it possible to enable features only on one platform?
不,这是不可能的,因为 Cargo issue #1197。
另请参阅:
如何在 Cargo.toml 配置中启用每个平台的 crate 功能?我试过两种方法,都不行。
方法一:
[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 平台上使用 'bundled' 功能,但无论我尝试以何种方式配置货物,它总是在构建时添加 'bundled' 功能Ubuntu 系统。
是否可以只在一个平台上启用功能?
Is it possible to enable features only on one platform?
不,这是不可能的,因为 Cargo issue #1197。
另请参阅: