如何在Cargo.toml中针对不同平台启用特定功能?

10
如何在Cargo.toml配置中针对不同平台启用Crate功能?我尝试了两种方法,但均不起作用。
方法1:
[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”功能,但无论我如何配置cargo,在Ubuntu系统上构建时它总是添加了“bundled”功能。是否可能仅在一个平台上启用功能?

很不幸,Cargo的功能系统现在非常有限,这使得跨平台应用程序的开发非常痛苦。 - Denys Séguret
1个回答

8

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接