2011-06-23 11:34:33 +08:00
|
|
|
# set params
|
2012-05-04 14:31:56 +08:00
|
|
|
NDK_ROOT_LOCAL=/cygdrive/e/android/android-ndk-r8
|
|
|
|
COCOS2DX_ROOT_LOCAL=/cygdrive/f/Project/dumganhar/cocos2d-x
|
2012-05-02 17:29:16 +08:00
|
|
|
|
|
|
|
buildexternalsfromsource=
|
|
|
|
|
|
|
|
usage(){
|
|
|
|
cat << EOF
|
|
|
|
usage: $0 [options]
|
|
|
|
|
|
|
|
Build C/C++ native code using Android NDK
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-s Build externals from source
|
|
|
|
-h this help
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
while getopts "s" OPTION; do
|
|
|
|
case "$OPTION" in
|
|
|
|
s)
|
|
|
|
buildexternalsfromsource=1
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2011-06-23 11:34:33 +08:00
|
|
|
|
2011-12-20 16:50:39 +08:00
|
|
|
# try to get global variable
|
|
|
|
if [ $NDK_ROOT"aaa" != "aaa" ]; then
|
2012-05-02 17:29:16 +08:00
|
|
|
echo "use global definition of NDK_ROOT: $NDK_ROOT"
|
|
|
|
NDK_ROOT_LOCAL=$NDK_ROOT
|
2011-12-20 16:50:39 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $COCOS2DX_ROOT"aaa" != "aaa" ]; then
|
2012-05-02 17:29:16 +08:00
|
|
|
echo "use global definition of COCOS2DX_ROOT: $COCOS2DX_ROOT"
|
|
|
|
COCOS2DX_ROOT_LOCAL=$COCOS2DX_ROOT
|
2011-12-20 16:50:39 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
GAME_ROOT=$COCOS2DX_ROOT_LOCAL/HelloLua
|
2012-04-20 15:23:00 +08:00
|
|
|
GAME_ANDROID_ROOT=$GAME_ROOT/proj.android
|
2012-02-14 18:04:56 +08:00
|
|
|
GAME_RESOURCE_ROOT=$GAME_ROOT/Resources
|
2011-06-23 11:34:33 +08:00
|
|
|
|
|
|
|
# make sure assets is exist
|
|
|
|
if [ -d $GAME_ANDROID_ROOT/assets ]; then
|
2012-05-02 17:29:16 +08:00
|
|
|
rm -rf $GAME_ANDROID_ROOT/assets
|
2011-06-23 11:34:33 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir $GAME_ANDROID_ROOT/assets
|
|
|
|
|
|
|
|
# copy resources
|
|
|
|
for file in $GAME_RESOURCE_ROOT/*
|
|
|
|
do
|
2012-05-02 17:29:16 +08:00
|
|
|
if [ -d $file ]; then
|
|
|
|
cp -rf $file $GAME_ANDROID_ROOT/assets
|
|
|
|
fi
|
2011-06-23 11:34:33 +08:00
|
|
|
|
2012-05-02 17:29:16 +08:00
|
|
|
if [ -f $file ]; then
|
|
|
|
cp $file $GAME_ANDROID_ROOT/assets
|
|
|
|
fi
|
2011-06-23 11:34:33 +08:00
|
|
|
done
|
|
|
|
|
2012-06-26 12:09:23 +08:00
|
|
|
|
2011-06-23 11:34:33 +08:00
|
|
|
# build
|
2012-05-02 17:29:16 +08:00
|
|
|
if [[ $buildexternalsfromsource ]]; then
|
|
|
|
echo "Building external dependencies from source"
|
|
|
|
$NDK_ROOT_LOCAL/ndk-build -C $GAME_ANDROID_ROOT $* \
|
|
|
|
NDK_MODULE_PATH=${COCOS2DX_ROOT_LOCAL}:${COCOS2DX_ROOT_LOCAL}/cocos2dx/platform/third_party/android/source
|
|
|
|
else
|
|
|
|
echo "Using prebuilt externals"
|
|
|
|
$NDK_ROOT_LOCAL/ndk-build -C $GAME_ANDROID_ROOT $* \
|
|
|
|
NDK_MODULE_PATH=${COCOS2DX_ROOT_LOCAL}:${COCOS2DX_ROOT_LOCAL}/cocos2dx/platform/third_party/android/prebuilt
|
|
|
|
fi
|