2011-03-23 14:30:14 +08:00
|
|
|
# set params
|
2011-12-20 16:50:39 +08:00
|
|
|
NDK_ROOT=__ndkroot__
|
2011-03-23 14:30:14 +08:00
|
|
|
COCOS2DX_ROOT=__cocos2dxroot__
|
2011-05-09 15:21:08 +08:00
|
|
|
GAME_ROOT=$COCOS2DX_ROOT/__projectname__
|
2012-05-02 17:29:16 +08:00
|
|
|
GAME_ANDROID_ROOT=$GAME_ROOT/proj.android
|
2011-08-23 17:17:09 +08:00
|
|
|
RESOURCE_ROOT=$GAME_ROOT/Resources
|
2011-03-23 14:30:14 +08:00
|
|
|
|
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-03-23 14:30:14 +08:00
|
|
|
# make sure assets is exist
|
2011-05-09 15:21:08 +08:00
|
|
|
if [ -d $GAME_ANDROID_ROOT/assets ]; then
|
|
|
|
rm -rf $GAME_ANDROID_ROOT/assets
|
2011-03-23 14:30:14 +08:00
|
|
|
fi
|
|
|
|
|
2011-05-09 15:21:08 +08:00
|
|
|
mkdir $GAME_ANDROID_ROOT/assets
|
2011-03-23 14:30:14 +08:00
|
|
|
|
|
|
|
# copy resources
|
|
|
|
for file in $RESOURCE_ROOT/*
|
|
|
|
do
|
2012-05-02 17:29:16 +08:00
|
|
|
if [ -d "$file" ]; then
|
|
|
|
cp -rf "$file" $GAME_ANDROID_ROOT/assets
|
2011-03-23 14:30:14 +08:00
|
|
|
fi
|
|
|
|
|
2012-05-02 17:29:16 +08:00
|
|
|
if [ -f "$file" ]; then
|
|
|
|
cp "$file" $GAME_ANDROID_ROOT/assets
|
2011-03-23 14:30:14 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-06-01 15:36:16 +08:00
|
|
|
# copy icons (if they exist)
|
|
|
|
file=$GAME_ANDROID_ROOT/assets/Icon-72.png
|
|
|
|
if [ -f "$file" ]; then
|
|
|
|
cp $file $GAME_ANDROID_ROOT/res/drawable-hdpi/icon.png
|
|
|
|
fi
|
|
|
|
file=$GAME_ANDROID_ROOT/assets/Icon-48.png
|
|
|
|
if [ -f "$file" ]; then
|
|
|
|
cp $file $GAME_ANDROID_ROOT/res/drawable-mdpi/icon.png
|
|
|
|
fi
|
|
|
|
file=$GAME_ANDROID_ROOT/assets/Icon-32.png
|
|
|
|
if [ -f "$file" ]; then
|
|
|
|
cp $file $GAME_ANDROID_ROOT/res/drawable-ldpi/icon.png
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2012-05-02 17:29:16 +08:00
|
|
|
if [[ $buildexternalsfromsource ]]; then
|
|
|
|
echo "Building external dependencies from source"
|
|
|
|
$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \
|
|
|
|
NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source
|
|
|
|
else
|
|
|
|
echo "Using prebuilt externals"
|
|
|
|
$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \
|
|
|
|
NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2011-03-23 14:30:14 +08:00
|
|
|
|