To specify a dependency that only exists on a certain platform, you can write this in your Cargo.toml
file:
[target.'cfg(windows)'.dependencies]
winreg = "0.3"
Let's say I have a binary that uses winreg
:
[[bin]]
name="windows_only_bin"
path="src/thing.rs"
How do I tell Cargo to not even attempt to build windows_only_bin
on non-windows platforms?
Anyone ever manage to figure this out? I have exactly this problem now with a bin I don't want to build on android. I tried:
[[target.'cfg(not(target_os = "android"))'.bin]]
name = "cmd_client"
path = "bin/cmd_client.rs"
But that just gave me the warning:
warning: unused manifest key: target.cfg(not(target_os = "android")).bin
Is it possible for me to conditionally build a bin?