I want to build a lib that work in multi-Android arch, so I added all the targets:
$ rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android arm-linux-androideabi
And to avoid having long line at build, like this
$ cargo build --target x86_64-linux-android
I added the target to the .cargo/conf
as:
[build]
target = "x86_64-linux-android"
#target = "aarch64-linux-android"
#target = "armv7-linux-androideabi"
#target = "i686-linux-android"
[target.x86_64-linux-android]
ar = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android-ar"
linker = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android23-clang"
[target.aarch64-linux-android]
ar = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar"
linker = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android23-clang"
[target.armv7-linux-androideabi]
ar = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar"
linker = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi23-clang"
[target.i686-linux-android]
ar = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android-ar"
linker = "/Users/hasan/Library/Android/sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android23-clang"
So, I can compile using cargo build --release
But every time I need to compile for a given target I need to go to the file above, andselect the target I want to compile it, or back for using the --target
flag.
Is there a way to combine all the targets
in the .cargo/config
file, or any other way, so that all the targets are compiled only by running singe command, that is:
$ cargo build --release