2011-08-19 13:07:50 +08:00
|
|
|
#!/bin/bash
|
2010-12-17 15:43:36 +08:00
|
|
|
# set params
|
2012-07-21 13:49:20 +08:00
|
|
|
NDK_ROOT_LOCAL=/home/james/Software/android/android-ndk-r8b
|
|
|
|
COCOS2DX_ROOT_LOCAL=/home/james/Project/cocos2d-x
|
2012-05-02 12:00:39 +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-12-20 16:50:39 +08:00
|
|
|
|
|
|
|
# try to get global variable
|
|
|
|
if [ $NDK_ROOT"aaa" != "aaa" ]; then
|
2012-05-02 12:00:39 +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 12:00:39 +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
|
|
|
|
|
2012-07-20 17:06:00 +08:00
|
|
|
TESTS_ROOT=$COCOS2DX_ROOT_LOCAL/samples/TestCpp/proj.android
|
2010-12-20 14:17:51 +08:00
|
|
|
|
2011-01-19 16:00:19 +08:00
|
|
|
# make sure assets is exist
|
2011-01-21 15:45:55 +08:00
|
|
|
if [ -d $TESTS_ROOT/assets ]; then
|
2012-05-02 12:00:39 +08:00
|
|
|
rm -rf $TESTS_ROOT/assets
|
2011-01-19 16:00:19 +08:00
|
|
|
fi
|
|
|
|
|
2011-01-21 15:45:55 +08:00
|
|
|
mkdir $TESTS_ROOT/assets
|
|
|
|
|
2011-01-19 16:00:19 +08:00
|
|
|
# copy resources
|
2012-07-20 17:06:00 +08:00
|
|
|
for file in $COCOS2DX_ROOT_LOCAL/samples/TestCpp/Resources/*
|
2011-01-21 15:45:55 +08:00
|
|
|
do
|
2012-05-02 12:00:39 +08:00
|
|
|
if [ -d $file ]; then
|
|
|
|
cp -rf $file $TESTS_ROOT/assets
|
|
|
|
fi
|
2011-01-21 15:45:55 +08:00
|
|
|
|
2012-05-02 12:00:39 +08:00
|
|
|
if [ -f $file ]; then
|
|
|
|
cp $file $TESTS_ROOT/assets
|
|
|
|
fi
|
2011-01-21 15:45:55 +08:00
|
|
|
done
|
2010-12-20 14:17:51 +08:00
|
|
|
|
2011-07-27 11:51:19 +08:00
|
|
|
# remove test_image_rgba4444.pvr.gz
|
|
|
|
rm -f $TESTS_ROOT/assets/Images/test_image_rgba4444.pvr.gz
|
2012-06-28 17:34:50 +08:00
|
|
|
rm -f $TESTS_ROOT/assets/Images/test_1021x1024_rgba8888.pvr.gz
|
|
|
|
rm -f $TESTS_ROOT/assets/Images/test_1021x1024_rgb888.pvr.gz
|
|
|
|
rm -f $TESTS_ROOT/assets/Images/test_1021x1024_rgba4444.pvr.gz
|
|
|
|
rm -f $TESTS_ROOT/assets/Images/test_1021x1024_a8.pvr.gz
|
2010-12-20 14:17:51 +08:00
|
|
|
|
2012-05-02 12:00:39 +08:00
|
|
|
# build
|
|
|
|
if [[ $buildexternalsfromsource ]]; then
|
|
|
|
echo "Building external dependencies from source"
|
|
|
|
$NDK_ROOT_LOCAL/ndk-build -C $TESTS_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 $TESTS_ROOT $* \
|
|
|
|
NDK_MODULE_PATH=${COCOS2DX_ROOT_LOCAL}:${COCOS2DX_ROOT_LOCAL}/cocos2dx/platform/third_party/android/prebuilt
|
|
|
|
fi
|