this post was submitted on 18 Mar 2024
11 points (92.3% liked)
Rust
5953 readers
1 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
A couple options come to mind to me:
cfg
more. If your features are conditional based on OS, architecture, CPU features, etc then you probably are better off using conditions other thanfeature
. See the reference for more information.cargo-make
andjust
. From there, you can do platform-specific build logic or even read variables from a.env
like you mentioned you wanted.Going opt-in instead of opt-out does not change the fact that I would still have to toggle the features manually. To be more specific, my use case is that I have a program to control cameras in my lab. But not all computers have the libraries for all cameras. So, every supported library can be enable/disable using a feature But the program being still in active development, I am frequently using
cargo run
,cargo check
,cargo install
, on different computers with different libraries installed. What would be convenient would be to have a configuration file on each computer, specifying that we will build only for PCO camera on this computer, only for Photometrics camera on this one, only Ximea and PCO on this one, instead of having to remember to toggle the relevant features every time. A shell script is not very convenient because I use different commands, run, check, install etc.You should look at the tools I linked.
cargo-make
would just change your flow tocargo make run
,cargo make check
, etc. andjust
has similar benefits. You'd handle the computer-specific logic in there, using a .env per computer if you want.Ok, I'll look into that then. Thanks.