Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch dependencies based on build profile

I want to use a feature from a dependency when I build in release profile and I don't want to use any feature while testing/development.

For example, the dependency is normally defined as:

[depenencies.my_dep]
version = "*"

But when I build in release profile, I want it to be

[depenencies.my_dep]
version = "*"
features = [my_feature]

From the cargo documentation I can make out that this can be achieved only for platform targets. Is there a way to do it for profile based configuration?

like image 943
Krishna Avatar asked Jul 14 '15 09:07

Krishna


1 Answers

cargo does not support what you want directly. I see two options.

A. Use dev-dependencies which allow for tests to have different depends than debug/release. dev-dependencies described

B. Have a Cargo-mock.toml and a Cargo-release.toml. Switch between them using cargo build --manifest-path ./Cargo-<type>.toml.

like image 52
Sean Perry Avatar answered Nov 17 '22 07:11

Sean Perry