Custom target-like config for crates

⚓ Rust    📅 2025-12-19    👤 surdeus    👁️ 4      

surdeus

I want to parameterize a crate of mine to be compiled for different hardware targets.
I don't want to use a feature for that, because the configuration targets should be mutually exclusive.
Within the code base the chosen target only affects a constant which is used throughout the code.

I want the user to choose the target device in their dependency config, analogous to features.
Does cargo support something like this?

I.e.

[dependencies]
my_crate = { version = "0.1.0", target_device = "this_specific_one" }

The target in this context is not a cargo target as available, but a set of different network co-processor (NCP) models from the same series of a hardware vendor.

3 posts - 2 participants

Read full topic

🏷️ Rust_feed