I have git package library, where branch = "dev" for development and branch = "master" for production.
In my main app, using features I want to configure what branch to use.
Something like this:
[target.'cfg(feature = "dev")'.dependencies]
utils = { git = "https://url/utils.git", branch = "master", optional = true }
[target.'cfg(feature = "prod")'.dependencies]
utils = { git = "https://url/utils.git", branch = "dev", optional = true }
Code above does't work, cause of:
Dependency 'utils' has different source paths depending on the build target. Each dependency must have a single canonical source path irrespective of build target.
I found the way like this:
[features]
dev = ["utils-dev"]
prod = ["utils-prod"]
utils-prod = { git = "https://url/utils.git", branch = "master", optional = true, package = "utils" }
utils-dev = { git = "https://url/utils.git", branch = "dev", optional = true, package = "utils" }
But every time when I use this library, I need to add this code:
#[cfg(feature = "dev")]
use utils_dev as regex;
#[cfg(feature = "prod")]
use utils_prod as regex;
Maybe exists better and easier way to do this?