cocos2dx 提高 build_native.sh 编译速度
进入生成的obj文件夹看看proj.android\obj\local\armeabi
发现是编译时生成的静态库动态库,我们不想每次生成一个新跨平台项目的时候都全部重新编译一次,可以重复利用这些类库
解决方案是在cocos2d-x-2.1.5目录下新建prebuild目录,把proj.android\obj\local\armeabi下(libcocos2dcpp.so就不用了)的类库都copy到prebuild,增加一个类似这样的Android.mk
LOCAL_PATH:=$(callmy-dir)
include$(CLEAR_VARS)
LOCAL_MODULE:=cocos2dx_static
LOCAL_MODULE_FILENAME:=libcocos2d
LOCAL_SRC_FILES:=./libcocos2d.a
LOCAL_EXPORT_C_INCLUDES:=\
$(LOCAL_PATH)/../cocos2dx\
$(LOCAL_PATH)/../cocos2dx/include\
$(LOCAL_PATH)/../cocos2dx/kazmath/include\
$(LOCAL_PATH)/../cocos2dx/platform/android\
#LOCAL_LDLIBS:=-lGLESv2\
#-llog\
#-lz
LOCAL_EXPORT_LDLIBS:=-lGLESv2\
-llog\
-lz
#LOCAL_CFLAGS:=-Wno-psabi-DUSE_FILE32API
#LOCAL_EXPORT_CFLAGS:=-Wno-psabi-DUSE_FILE32API
LOCAL_WHOLE_STATIC_LIBRARIES:=cocos_libpng_static
LOCAL_WHOLE_STATIC_LIBRARIES+=cocos_jpeg_static
LOCAL_WHOLE_STATIC_LIBRARIES+=cocos_libwebp_static
LOCAL_WHOLE_STATIC_LIBRARIES+=cocos_libtiff_static
include$(PREBUILT_STATIC_LIBRARY)
include$(CLEAR_VARS)
LOCAL_MODULE:=cocosdenshion_static
LOCAL_MODULE_FILENAME:=libcocosdenshion
LOCAL_SRC_FILES:=./libcocosdenshion.a
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/../CocosDenshion/include
#LOCAL_CFLAGS+=-Wno-psabi
#LOCAL_EXPORT_CFLAGS+=-Wno-psabi
include$(PREBUILT_STATIC_LIBRARY)
include$(CLEAR_VARS)
LOCAL_MODULE:=box2d_static
LOCAL_MODULE_FILENAME:=libbox2d
LOCAL_SRC_FILES:=./libbox2d.a
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/../external
include$(PREBUILT_STATIC_LIBRARY)
include$(CLEAR_VARS)
LOCAL_MODULE:=chipmunk_static
LOCAL_MODULE_FILENAME:=libchipmunk
LOCAL_SRC_FILES:=./libchipmunk.a
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/../external/chipmunk/include/chipmunk
#LOCAL_CFLAGS:=-std=c99
include$(PREBUILT_STATIC_LIBRARY)
include$(CLEAR_VARS)
LOCAL_MODULE:=cocos_extension_static
LOCAL_MODULE_FILENAME:=libextension
LOCAL_SRC_FILES:=./libextension.a
LOCAL_EXPORT_C_INCLUDES:=\
$(LOCAL_PATH)/../extensions\
$(LOCAL_PATH)/../extensions/CCBReader\
$(LOCAL_PATH)/../extensions/GUI/CCControlExtension\
$(LOCAL_PATH)/../extensions/GUI/CCScrollView\
$(LOCAL_PATH)/../extensions/network\
$(LOCAL_PATH)/../extensions/LocalStorage\
$(LOCAL_PATH)/../extensions/CCArmature
LOCAL_WHOLE_STATIC_LIBRARIES:=cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES+=cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES+=cocos_curl_static
LOCAL_WHOLE_STATIC_LIBRARIES+=box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES+=chipmunk_static
LOCAL_WHOLE_STATIC_LIBRARIES+=libwebsockets_static
#LOCAL_CFLAGS+=-DCC_ENABLE_CHIPMUNK_INTEGRATION=1
#LOCAL_EXPORT_CFLAGS+=-DCC_ENABLE_CHIPMUNK_INTEGRATION=1
#LOCAL_CPPFLAGS+=-DCC_ENABLE_CHIPMUNK_INTEGRATION=1
#LOCAL_EXPORT_CPPFLAGS+=-DCC_ENABLE_CHIPMUNK_INTEGRATION=1
#LOCAL_CFLAGS:=-fexceptions
include$(PREBUILT_STATIC_LIBRARY)
$(callimport-module,libjpeg)
$(callimport-module,libpng)
$(callimport-module,libwebp)
$(callimport-module,libtiff)
$(callimport-module,libcurl)
$(callimport-module,external/libwebsockets/android)
来试一下COCOS2DX自带的demo,F:\cocos2d-x\cocos2d-x-2.1.5\samples\Cpp\TestCpp
TestCpp和pro.android/jni里都有Android.mk,打开修改尾部代码
TestCpp下的Android.mk
#$(callimport-module,CocosDenshion/android)
#$(callimport-module,external/Box2D)
#$(callimport-module,external/chipmunk)
#$(callimport-module,cocos2dx)
#$(callimport-module,extensions)
$(callimport-module,prebuild)
proj.android/jni里的Android.mk
$(callimport-module,samples/Cpp/TestCpp)
#$(callimport-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)
#$(callimport-module,cocos2dx)
#$(callimport-module,CocosDenshion/android)
#$(callimport-module,extensions)
#$(callimport-module,external/Box2D)
#$(callimport-module,external/chipmunk)
$(callimport-module,prebuild)
cygwin进入到F:\cocos2d-x\cocos2d-x-2.1.5\samples\Cpp\TestCpp\proj.android
./build_native.sh
发现编译快多了,只是编译了Classes和jni部分,其他都利旧。现在可以导入到eclipse里运行TestCpp了么么哒