2012-05-28 16:58:16 +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-28 16:58: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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $COCOS2DX_ROOT"aaa" != "aaa" ]; then
|
|
|
|
echo "use global definition of COCOS2DX_ROOT: $COCOS2DX_ROOT"
|
|
|
|
COCOS2DX_ROOT_LOCAL=$COCOS2DX_ROOT
|
|
|
|
fi
|
|
|
|
|
2012-07-20 17:06:00 +08:00
|
|
|
TEST_JS_ROOT=$COCOS2DX_ROOT_LOCAL/samples/TestJavascript/proj.android
|
2012-05-28 16:58:16 +08:00
|
|
|
|
|
|
|
# make sure assets is exist
|
|
|
|
if [ -d $TEST_JS_ROOT/assets ]; then
|
|
|
|
rm -rf $TEST_JS_ROOT/assets
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir $TEST_JS_ROOT/assets
|
|
|
|
|
|
|
|
# copy resources
|
2012-07-20 17:06:00 +08:00
|
|
|
for file in $COCOS2DX_ROOT_LOCAL/samples/TestJavascript/Resources/*
|
2012-05-28 16:58:16 +08:00
|
|
|
do
|
|
|
|
if [ -d "$file" ]; then
|
|
|
|
cp -rf "$file" $TEST_JS_ROOT/assets
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$file" ]; then
|
|
|
|
cp "$file" $TEST_JS_ROOT/assets
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-06-26 12:09:23 +08:00
|
|
|
|
2012-05-28 16:58:16 +08:00
|
|
|
if [[ $buildexternalsfromsource ]]; then
|
|
|
|
echo "Building external dependencies from source"
|
|
|
|
$NDK_ROOT_LOCAL/ndk-build -C $TEST_JS_ROOT $* \
|
2012-07-20 17:06:00 +08:00
|
|
|
NDK_MODULE_PATH=${COCOS2DX_ROOT_LOCAL}:${COCOS2DX_ROOT_LOCAL}/cocos2dx/platform/third_party/android/prebuilt
|
2012-05-28 16:58:16 +08:00
|
|
|
else
|
|
|
|
echo "Using prebuilt externals"
|
|
|
|
$NDK_ROOT_LOCAL/ndk-build -C $TEST_JS_ROOT $* \
|
2012-07-20 17:06:00 +08:00
|
|
|
NDK_MODULE_PATH=${COCOS2DX_ROOT_LOCAL}:${COCOS2DX_ROOT_LOCAL}/cocos2dx/platform/third_party/android/prebuilt
|
2012-05-28 16:58:16 +08:00
|
|
|
fi
|