0

In my Android application, I have quite a few open-source C++ projects that are built as static libraries. Essentially, Android.mk builds all the libraries as static and links them all to create my final core.so library.

Our nightly build checks out all the files from the source control in a clean directory and builds everything that is needed.

I am looking at how I can optimize our nightly build. As the third-party code does not change (may be once every six months), I would like to build them just once and check in the generated libs. I am guessing these libs would have a ".a" extension. The nighly build will simply check out these libs and link them to create my final core.so.

Basically, I am hoping I can break my existing Android.mk into two different ones - one for building static libraries and one for building the final shared library that the Android code can use.

I am wondering if this is possible. Regards.

1 Answer 1

2

You're looking for prebuilt library support.

Assuming your static library declaration looks something like this:

include $(CLEAR_VARS)
 LOCAL_MODULE := foo
 LOCAL_SRC_FILES := foo/foo.c
 LOCAL_EXPORT_CFLAGS := -DFOO=1
include $(BUILD_STATIC_LIBRARY)

you can make it use a prebuilt instead:

include $(CLEAR_VARS)
 LOCAL_MODULE := foo
 LOCAL_SRC_FILES := libs/foo.a
include $(PREBUILT_STATIC_LIBRARY)

and include in your core lib just the same:

include $(CLEAR_VARS)
 LOCAL_MODULE := myCore
 LOCAL_SRC_FILES := core/core.c
 LOCAL_STATIC_LIBRARIES := foo
include $(BUILD_SHARED_LIBRARY)

So you could have a seperate Android.mk, or just use a conditional variable.

ifeq ($(USE_PREBUILT_LIBS),)
 # declare with BUILD_STATIC_LIBRARY
else
 # declare with PREBUILT_STATIC_LIBRARY
endif
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your help. How do I fire creation of prebuilt static libraries? Which directory do prebuilt static libraries get stored?
The point of a prebuilt library is you create it however you want, and store it wherever you want (hence your reference to checking them in yourself). It sounded like you wanted to use the .as from your current build process?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.