Reputation: 3562
Is there any way to relocate my source code (including all .h .cpp and .mk files) outside of project folder? In other words, i want to move out content of jni folder out of android project folder. Now, physical structure of my project looks like this:
.../ProjectFolder/AndroidProjectFolder/jni/(sources and make files)
.../ProjectFolder/AndroidProjectFolder/(other android project files)
.../ProjectFolder/iosProjectFolder/(other ios project files)
I want to make like this:
.../ProjectFolder/src/(sources and make files)
.../ProjectFolder/AndroidProjectFolder/(other android project files)
.../ProjectFolder/iosProjectFolder/(other ios project files)
Is there any correct way to do it?
Upvotes: 1
Views: 608
Reputation: 496
Yes, you can do that. I use the directory above jni for instance MyProject/src/ This sample builds a shared library...You can also build static libraries. Notice the $(call my-dir)/.. the 'call my-dir)' points to the jni directory that contains the Android.mk file. So adding the /.. backs it up a directory.
LOCAL_PATH := $(call my-dir)/..
include $(CLEAR_VARS)
FILE_LIST := $(wildcard $(LOCAL_PATH)/src/*.cpp)
ifdef DEBUG
CONFIG_DIR := Debug
LOCAL_CFLAGS := -Werror -Wno-psabi -O0 -ggdb -D_DEBUG
LOCAL_CXXFLAGS := -Werror -Wno-psabi -O0 -ggdb -D_DEBUG -fexceptions
LOCAL_LINK_FLAGS := -ggdb
else
CONFIG_DIR := Release
LOCAL_CFLAGS := -Werror -Wno-psabi -O2 -DNDEBUG
LOCAL_CXXFLAGS := -Werror -Wno-psabi -O2 -DNDEBUG -fexceptions
endif
LOCAL_MODULE := MyProject
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_LDFLAGS := $(LOCAL_LINK_FLAGS)
LOCAL_LDLIBS += -lGLESv2 -landroid -llog -lGLESv1_CM -lEGL
include $(BUILD_SHARED_LIBRARY)
Upvotes: 5