SparkyNZ
SparkyNZ

Reputation: 6676

ndk-build of static lib - why is it building other files?

I have a project structure as follows. All I want to do is build a static library with SQLite source but for some reason when I run ndk-build, it builds other source too - as if it is including Android.mk files in other locations.

jni/SQLite
jni/SQLite/Android.mk (the only .mk file that I want to build)
jni/TT
jni/Application.mk
jni/Android.mk   (for building everything such as SDL2)

TT is a symbolic link to /work/TT which contains a number of cross-platform source files including SQLite, SDL2 and other source.

/work/TT
/work/TT/SQLite
/work/TT/SQLite/sqlite3.c
/work/TT/SDL2
..

Here is jni/SQLite/Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

TT_PATH := /work/TT

SRC_SQLITE := $(TT_PATH)/SQLite/sqlite3.c

LOCAL_C_INCLUDES += $(NDK_APP_PROJECT_PATH)/jni
LOCAL_MODULE    := SQLite
LOCAL_SRC_FILES := $(SRC_SQLITE)
include $(BUILD_STATIC_LIBRARY)

Why are other files being built? What do I need to do to build SQLite only?

At the command prompt I am in the following folder: jni/SQLite

I run ndk-build (same folder as the Android.mk contents above)

I expect to see sqlite3.c being the only file compiled. But no, I see all of the SDL2 project files being built..

Once all files have been compiled, if I run ndk-build again I see this:

MacbookPro:SQLite admin$ ndk-build
[armeabi-v7a] Install        : libSDL2.so => libs/armeabi-v7a/libSDL2.so
[armeabi-v7a] Install        : libmain.so => libs/armeabi-v7a/libmain.so

This clearly shows modules SDL2 and main being built.. but why?

Perhaps I am supposed to use:

ndk-build -f Android.mk

..to build my one and only desired Android.mk instead of automatically having my jni folder searched/built?

When I do that I get the following error but at least it looks as though it is trying to run the one specific Android.mk:

MacbookPro:SQLite admin$ ndk-build -f Android.mk
Android NDK: Trying to define local module 'SQLite' in Android.mk.    
Android NDK: But this module was already defined by /Work/TT/android-TT/app/src/main/jni/SQLite/Android.mk.    
/Android/android-ndk-r9d/build/core/build-module.mk:34: *** Android NDK: Aborting.    .  Stop.

My Application.mk is as follows but this is not present in the SQLite folder where I run ndk-build, this is the jni/Application.mk:

# Uncomment this if you're using STL in your project
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
APP_STL := gnustl_static
APP_PLATFORM := android-14
APP_ABI := armeabi-v7a

UPDATE: I tried:

ndk-build -d -f Android.mk 

..and the debug output shows that the SDL2/Android.mk and other .mk files are still being called. How do I stop this recursive behaviour so it only builds the Android.mk in the current folder?

This is a snippet of the debug output that I see:

Reading makefile `/Work/TT/android-TT/app/src/main/jni/SDL/Android.mk' (search path) (no ~ expansion)...
Reading makefile `/Work/TT/android-TT/app/src/main/obj/local/armeabi-v7a/objs/main/SQLite/sqlite3.o.d' (search path) (don't care) (no ~ expansion)...

Upvotes: 0

Views: 556

Answers (1)

SparkyNZ
SparkyNZ

Reputation: 6676

The answer to my problem is to do this:

ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk

This will build the current folder Android.mk as required.

Upvotes: 2

Related Questions