Open chengchangwu opened 4 years ago
Hmm. It seems I don't have that feature at the moment, let's hope it won't take too long to implement it :-)
Could you please check version 0.3.3
and see whether it works for you?
I've added extraCargoEnv
option.
For target armv7-linux-android I need to set PKG_CONFIG_LIBDIR=/path/to/my/pkg-config/armv7, for target aarch64-linux-android I need to set PKG_CONFIG_LIBDIR=/path/to/my/pkg-config/arm64. I do not know how to do that with extraCargoEnv. Could I use productFlavors and puth extraCargoEnv there?
Hmm... I guess it would be possible to implement configuration per target. However, I'm not sure that such paths in your own system should be in that place. They look specific to your environment, and so others might have different ones. I guess we need to think about where would be the best place to specify them. Do you have any suggestions?
I can see a particular useful case for this. We we're building for multiple architectures and we need to set specific environment variables for, say pkg-config to find dependent libraries for each architecture we're building.
An example of how this could work is something like:
cargoNdk {
env = ["arm64": "PKG_CONFIG_LIBDIR=/path/to/arm64-libdirs", "arm": "PKG_CONFIG_LIBDIR=/path/to/arm-libdirs"...]
}
I'm not familiar with groovy's syntax, so there's probably a better way to write this. As for the implementation, this would just set the PATH temporarily. Might look like this for when building arm:
PKG_CONFIG_LIBDIR=/path/to/arm-libdirs cargo ...
Now, the environment variables are available depending on the current architecture being built.
I'll try to implement this and send a pull request, but I really know nothing about Groovy. Wish me luck!
EDIT:
I was thinking it could also look something like:
cargoNdk {
env {
arm64 [
"PKG_CONFIG_LIBDIR": "...",
"...": "..."
]
// Same for other architectures
}
}
How could I set target-specific environment variables?