axmol/HelloWorld/proj.android/build_native.sh

72 lines
1.5 KiB
Bash
Raw Normal View History

2010-12-18 18:23:31 +08:00
# set params
NDK_ROOT_LOCAL=/cygdrive/e/android/android-ndk-r8
COCOS2DX_ROOT_LOCAL=/cygdrive/f/Project/dumganhar/cocos2d-x
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-12-20 16:50:39 +08:00
# try to get global variable
if [ $NDK_ROOT"aaa" != "aaa" ]; then
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
echo "use global definition of COCOS2DX_ROOT: $COCOS2DX_ROOT"
COCOS2DX_ROOT_LOCAL=$COCOS2DX_ROOT
2011-12-20 16:50:39 +08:00
fi
2012-04-19 11:46:08 +08:00
HELLOWORLD_ROOT=$COCOS2DX_ROOT_LOCAL/HelloWorld/proj.android
2010-12-20 14:17:51 +08:00
2011-01-21 15:45:55 +08:00
# make sure assets is exist
if [ -d $HELLOWORLD_ROOT/assets ]; then
rm -rf $HELLOWORLD_ROOT/assets
2010-12-20 14:17:51 +08:00
fi
2011-01-21 15:45:55 +08:00
mkdir $HELLOWORLD_ROOT/assets
# copy resources
for file in $COCOS2DX_ROOT_LOCAL/HelloWorld/Resources/*
2011-01-21 15:45:55 +08:00
do
if [ -d $file ]; then
cp -rf $file $HELLOWORLD_ROOT/assets
fi
2011-01-21 15:45:55 +08:00
if [ -f $file ]; then
cp $file $HELLOWORLD_ROOT/assets
fi
2011-01-21 15:45:55 +08:00
done
if [[ $buildexternalsfromsource ]]; then
echo "Building external dependencies from source"
$NDK_ROOT_LOCAL/ndk-build -C $HELLOWORLD_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 $HELLOWORLD_ROOT $* \
NDK_MODULE_PATH=${COCOS2DX_ROOT_LOCAL}:${COCOS2DX_ROOT_LOCAL}/cocos2dx/platform/third_party/android/prebuilt
fi