Issue
In cmake you can specify ${ANDROID_ABI} when linking a static C++ lib to get the correct version of the library (e.g. arm64-v8a, armeabi-v7a, x86_64, etc)
target_link_libraries(mylib debug
foo/lib/${ANDROID_ABI}/libfoo.a
What's the equivalent of that in Bazel? If I have platform specific versions of libfoo.a in foo/lib/arm64-v8a, foo/lib/arm64-v8a, foo/lib/arm64-v8a, etc. How do I link the correct on in Bazel?
Solution
You can use select()
, config_setting
, and --fat_apk_cpu
for this:
cc_library(
name = "foo",
srcs = select({
"arm64-v8a": ["foo/lib/arm64-v8a/libfoo.a"],
"armeabi-v7a": ["foo/lib/armeabi-v7a/libfoo.a"],
"x86": ["foo/lib/x86/libfoo.a"],
"x86_64": ["foo/lib/x86_64/libfoo.a"],
}),
)
config_setting(
name = "arm64-v8a",
values = {
"cpu": "arm64-v8a",
},
)
config_setting(
name = "armeabi-v7a",
values = {
"cpu": "armeabi-v7a",
},
)
config_setting(
name = "x86",
values = {
"cpu": "x86",
},
)
config_setting(
name = "x86_64",
values = {
"cpu": "x86_64",
},
)
and your cc_library
rules can depend on foo
.
Then specify --fat_apk_cpu
on the command line, e.g. to build and package a .so
for each platform, specify --fat_apk_cpu=arm64-v8a,armeabi-v7a,x86,x86_64
, or some subset for what you're targeting, e.g. for an emulator --fat_apk_cpu=x86_64
Answered By - ahumesky
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.