2011-03-24 09:37:56 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# This script should be called by create-android-project.bat
|
|
|
|
# or should be runned in linux shell. It can not be runned under
|
|
|
|
# cygwin.
|
|
|
|
# Don't modify the script until you know what you do.
|
|
|
|
|
2011-04-26 14:51:17 +08:00
|
|
|
# set environment paramters
|
2011-12-20 16:50:39 +08:00
|
|
|
NDK_ROOT_LOCAL="/home/laschweinski/android/android-ndk-r5"
|
|
|
|
ANDROID_SDK_ROOT_LOCAL="/home/laschweinski/android/android-sdk-linux_86"
|
|
|
|
|
|
|
|
# try to get global variable
|
2011-12-23 14:15:01 +08:00
|
|
|
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 [ $ANDROID_SDK_ROOT"aaa" != "aaa" ]; then
|
|
|
|
echo "use global definition of ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT"
|
|
|
|
ANDROID_SDK_ROOT_LOCAL=$ANDROID_SDK_ROOT
|
|
|
|
fi
|
2011-04-26 14:51:17 +08:00
|
|
|
|
2011-03-24 09:37:56 +08:00
|
|
|
# check if it was called by .bat file
|
2011-05-20 16:59:19 +08:00
|
|
|
if [ $# -eq 5 ];then
|
|
|
|
if [ $5 = "windows" ];then
|
2011-03-24 09:37:56 +08:00
|
|
|
# called by .bat file
|
2011-05-20 16:59:19 +08:00
|
|
|
sh $1/template/android/copy_files.sh $1 $2 $3 $4
|
2011-03-24 09:37:56 +08:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# the bash file should not be called by cygwin
|
2011-08-05 10:07:14 +08:00
|
|
|
KERNEL_NAME=`uname -s | grep "CYGWIN*"`
|
|
|
|
if [ $KERNEL_NAME"hi" != "hi" ]; then
|
2011-03-24 09:37:56 +08:00
|
|
|
echo "Error!!!"
|
|
|
|
echo "Don't run in cygwin. You should run corresponding bat."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ok, it was run under linux
|
|
|
|
|
|
|
|
# check it was runned in cocos2d-x root
|
|
|
|
check_path(){
|
|
|
|
if [ ! -f create-android-project.sh ];then
|
|
|
|
echo Error!!!
|
|
|
|
echo Please run in cocos2dx root
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
create_android_project(){
|
2011-06-25 14:13:08 +08:00
|
|
|
echo "Input package path. For example: org.cocos2dx.example"
|
2011-05-20 17:40:28 +08:00
|
|
|
read PACKAGE_PATH
|
2012-01-04 15:00:14 +08:00
|
|
|
echo "Now cocos2d-x supports Android 2.1-update1, 2.2, 2.3 & 3.0"
|
2011-03-24 13:48:05 +08:00
|
|
|
echo "Other versions have not tested."
|
2011-12-20 16:50:39 +08:00
|
|
|
$ANDROID_SDK_ROOT_LOCAL/tools/android list targets
|
2011-03-24 09:37:56 +08:00
|
|
|
echo "input target id:"
|
|
|
|
read TARGET_ID
|
|
|
|
echo "input your project name:"
|
|
|
|
read PROJECT_NAME
|
|
|
|
PROJECT_DIR=`pwd`/$PROJECT_NAME
|
2011-12-29 10:39:46 +08:00
|
|
|
|
|
|
|
# check if PROJECT_DIR is exist
|
|
|
|
if [ -d $PROJECT_DIR ]; then
|
|
|
|
echo "$PROJECT_DIR is exist, please use another name"
|
|
|
|
exit
|
|
|
|
fi
|
2011-03-24 09:37:56 +08:00
|
|
|
|
2011-12-20 16:50:39 +08:00
|
|
|
$ANDROID_SDK_ROOT_LOCAL/tools/android create project -n $PROJECT_NAME -t $TARGET_ID -k $PACKAGE_PATH -a $PROJECT_NAME -p $PROJECT_DIR
|
2011-03-24 09:37:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
check_path
|
|
|
|
create_android_project
|
|
|
|
|
2011-12-23 16:00:31 +08:00
|
|
|
if [ $# -eq 1 ]; then
|
|
|
|
# invoked by create-linux-android-project.sh
|
|
|
|
sh `pwd`/template/linux/mycopy_files.sh `pwd` $PROJECT_NAME $NDK_ROOT_LOCAL $PACKAGE_PATH
|
|
|
|
else
|
|
|
|
# invoke template/android/copy_files.sh
|
|
|
|
sh `pwd`/template/android/copy_files.sh `pwd` $PROJECT_NAME $NDK_ROOT_LOCAL $PACKAGE_PATH
|
|
|
|
fi
|
|
|
|
|