LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
#LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
# 遍历目录及子目录的函数
define walk
$(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e)))
endef
FILE_LIST := hellocpp/main.cpp
# 遍历Classes目录
ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes)
# 从所有文件中提取出所有.cpp文件
FILE_LIST += $(filter %.cpp, $(ALLFILES))
ALLFILES = $(call walk, $(LOCAL_PATH)/../../Libs/NS_Library)
FILE_LIST += $(filter %.cpp %c, $(ALLFILES))
ALLFILES = $(call walk,$(LOCAL_PATH)/../../Libs/PushNotification/android)
FILE_LIST += $(filter %.cpp, $(ALLFILES))
ALLFILES = $(call walk,$(LOCAL_PATH)/../../Libs/SystemInfo/android)
FILE_LIST += $(filter %.cpp, $(ALLFILES))
ALLFILES = $(call walk,$(LOCAL_PATH)/../../Libs/OpenUDID/android)
FILE_LIST += $(filter %.cpp, $(ALLFILES))
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
#提取所有.h
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/NS_Library
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.android
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.win32
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.linux
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.mac
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/parser/Debug.win32
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/openUDID
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/openUDID/ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/openUDID/win32
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/PushNotification
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/PushNotification/ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/PushNotification/win32
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/PushNotification/android
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/SystemInfo
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/SystemInfo/ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/SystemInfo/win32
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, D:\docode\cocos2dx\engines\cocos2d-x-2.2.3;)
$(call import-add-path, D:\docode\cocos2dx\engines\cocos2d-x-2.2.3\cocos2dx\platform\third_party\android\prebuilt)
$(call import-module,cocos2dx)
$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)
$(call import-module,CocosDenshion/android)
$(call import-module,extensions)
$(call import-module,external/Box2D)
include $(CLEAR_VARS)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
#LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
# 遍历目录及子目录的函数
define walk
$(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e)))
endef
FILE_LIST := hellocpp/main.cpp
# 遍历Classes目录
ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes)
# 从所有文件中提取出所有.cpp文件
FILE_LIST += $(filter %.cpp, $(ALLFILES))
ALLFILES = $(call walk, $(LOCAL_PATH)/../../Libs/NS_Library)
FILE_LIST += $(filter %.cpp %c, $(ALLFILES))
ALLFILES = $(call walk,$(LOCAL_PATH)/../../Libs/PushNotification/android)
FILE_LIST += $(filter %.cpp, $(ALLFILES))
ALLFILES = $(call walk,$(LOCAL_PATH)/../../Libs/SystemInfo/android)
FILE_LIST += $(filter %.cpp, $(ALLFILES))
ALLFILES = $(call walk,$(LOCAL_PATH)/../../Libs/OpenUDID/android)
FILE_LIST += $(filter %.cpp, $(ALLFILES))
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
#提取所有.h
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/NS_Library
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.android
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.win32
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.linux
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/proj.mac
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/NS_Library/parser/Debug.win32
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/openUDID
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/openUDID/ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/openUDID/win32
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/PushNotification
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/PushNotification/ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/PushNotification/win32
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/PushNotification/android
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Libs/SystemInfo
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/SystemInfo/ios
LOCAL_C_INCLUDES -= $(LOCAL_PATH)/../../Libs/SystemInfo/win32
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, D:\docode\cocos2dx\engines\cocos2d-x-2.2.3;)
$(call import-add-path, D:\docode\cocos2dx\engines\cocos2d-x-2.2.3\cocos2dx\platform\third_party\android\prebuilt)
$(call import-module,cocos2dx)
$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)
$(call import-module,CocosDenshion/android)
$(call import-module,extensions)
$(call import-module,external/Box2D)
$(call import-module,external/chipmunk)
##################支持c++11新特性##########################
在Application.mk中加入下面两句:
APP_CPPFLAGS += -std=c++11
NDK_TOOLCHAIN_VERSION=4.8 (r9是4.8,项目右键查看属性,在C/C++ general中的Paths and Symbols 下查看NDK_ROOT相关引用)