Issue
Is there any way to check if a library already defined, then skip define it again.
I have some Android make file with library defined as the following:
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := libfoo.so
include $(PREBUILT_SHARED_LIBRARY)
And have another Android.mk that includes all of other small libraries, just to automate building multiple projects at the same time.
But the problem it will throw an error because some of the libs already defined in another Android.mk files, so is there any way to check if the library is defined, then no need to define it again ?
Solution
There isn't anything built in the NDK build that would reliably do this (ndk-build itself can obviously check, but the way it does so is an implementation detail rather than an API, unfortunately).
One option is to just set a variable yourself, essentially like you'd do with a C include guard, i.e.
ifdef foo_defined
foo_defined := true
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := libfoo.so
include $(PREBUILT_SHARED_LIBRARY)
endif
From the sound of things though, it sounds like maybe you'd be better served by refactoring your build scripts so you don't end up with things being defined twice? Not sure how feasible that is for you. You might be interested in https://developer.android.com/ndk/guides/android_mk#import-module (I'll work on getting some better docs for that functionality, since it's basically unheard of).
Answered By - Dan Albert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.