原文地址:http://hsienwei.blogspot.com/2013/05/cocos2d-xbuildnativesh.html 需要翻墙
修改cocos2d-x提供build_native.sh經驗
- 分為Debug與Release兩個版本
- 分為國際版與韓國版
while getopts "sh" OPTION; do
case "$OPTION" in
s)
buildexternalsfromsource=1
;;
h)
usage
exit 0
;;
esac
done
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
for p in $*
do
echo "$p"
case $p in
"kr")
echo "force build kr"
forcebuildkr=1
#Can not pass this parameter to next call bash
;;
"debug")
echo "get debug"
debugflag=1
#Can not pass this parameter to next call bash
;;
"-s")
buildexternalsfromsource=1
param="$param$p "
;;
"-h")
usage
exit 0
;;
*)
param="$param$p "
;;
esac
done
if [[ "$debugflag" ]]; then
echo "debug on!!"
if [[ "$forcebuildkr" ]]; then
echo "force build kr!!"
usedebugappmk="${APP_ANDROID_ROOT}/jni/Application_debug_kr.mk"
else
echo "build global!!"
usedebugappmk="${APP_ANDROID_ROOT}/jni/Application_debug.mk"
fi
else
echo "debug off!!"
if [[ "$forcebuildkr" ]]; then
echo "force build kr!!"
usedebugappmk="${APP_ANDROID_ROOT}/jni/Application_kr.mk"
else
echo "build global!!"
usedebugappmk="${APP_ANDROID_ROOT}/jni/Application.mk"
fi
fi
"$NDK_ROOT"/ndk-build NDK_APPLICATION_MK="$usedebugappmk" -C "$APP_ANDROID_ROOT" $param \
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
控制資源
# copy ver android
for file in "$APP_ROOT"/Resource_android/*
do
if [ -d "$file" ]; then
cp -rf "$file" "$APP_ANDROID_ROOT"/assets
fi
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/assets
fi
done
if [[ "$debugflag" -ne 1 ]]; then
echo "delete .lua .bat .exe"
if [ -e "del_lua.sh" ]; then
./del_lua.sh
fi
fi