From c0d2118aace343ccaf942a2afec26b8dbe055ea5 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 29 Feb 2012 17:48:45 +0800 Subject: [PATCH 1/3] issue #982: android template support lua box2d and chipmunk --- create-android-project.bat | 2 +- create-android-project.sh | 62 +++++++++++++++++++++++++--- create-linux-eclipse-project.sh | 2 +- template/android/AndroidTemplate1.mk | 25 ----------- template/android/AndroidTemplate2.mk | 10 ----- template/android/Application.mk | 3 -- template/android/application.sh | 25 +++++++++++ template/android/classesmk.sh | 46 +++++++++++++++++++++ template/android/copy_files.sh | 26 ++++++++++-- template/android/gamemk.sh | 46 +++++++++++++++++++++ template/android/gamestaticmk.sh | 31 ++++++++++++++ 11 files changed, 228 insertions(+), 50 deletions(-) delete mode 100644 template/android/AndroidTemplate1.mk delete mode 100644 template/android/AndroidTemplate2.mk delete mode 100644 template/android/Application.mk create mode 100644 template/android/application.sh create mode 100644 template/android/classesmk.sh create mode 100644 template/android/gamemk.sh create mode 100644 template/android/gamestaticmk.sh diff --git a/create-android-project.bat b/create-android-project.bat index 6302474da5..21eec4934b 100644 --- a/create-android-project.bat +++ b/create-android-project.bat @@ -45,6 +45,6 @@ for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%cd%"') do set _CURRENTDIR=%%A for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%_NDKROOT%"') do set _NDKROOT=%%A :: Throw away temporary env vars and invoke script, passing any args that were passed to us -endlocal & %_CYGBIN%\bash --login "%_CYGSCRIPT%" %_CURRENTDIR% %_PROJECTNAME% %_NDKROOT% %_PACKAGEPATH% "windows" +endlocal & %_CYGBIN%\bash --login "%_CYGSCRIPT%" %_CURRENTDIR% %_PROJECTNAME% %_NDKROOT% %_PACKAGEPATH% "windows" -b pause diff --git a/create-android-project.sh b/create-android-project.sh index 518025f279..e9df062562 100755 --- a/create-android-project.sh +++ b/create-android-project.sh @@ -8,6 +8,10 @@ NDK_ROOT_LOCAL="/home/laschweinski/android/android-ndk-r5" ANDROID_SDK_ROOT_LOCAL="/home/laschweinski/android/android-sdk-linux_86" +NEED_BOX2D=false +NEED_CHIPMUNK=false +NEED_LUA=false + # try to get global variable if [ $NDK_ROOT"aaa" != "aaa" ]; then echo "use global definition of NDK_ROOT: $NDK_ROOT" @@ -19,16 +23,60 @@ if [ $ANDROID_SDK_ROOT"aaa" != "aaa" ]; then ANDROID_SDK_ROOT_LOCAL=$ANDROID_SDK_ROOT fi +# parameters passed to .bat or .sh +PARAMS= + +print_usage(){ + echo ERROR!!! + echo usage + echo "$0(or corresponding bat file on windows) [-b|--box2d] [-c|--chipmunk] [-l|--lua]" +} + +check_param(){ + for param in ${PARAMS[@]} + do + case $param in + -b | --box2d) + echo using box2d + NEED_BOX2D=true + ;; + -c | --chipmunk) + echo using chipmunk + NEED_CHIPMUNK=true + ;; + -l | --lua) + echo using lua + NEED_LUA=true + ;; + -linux) + // skip it + ;; + *) + print_usage + exit 1 + esac + done + + if [ $NEED_BOX2D == "true" ]; then + if [ $NEED_CHIPMUNK == "true" ]; then + echo Warning!!! + echo Use box2d and chipmunk together???? + fi + fi +} + # check if it was called by .bat file -if [ $# -eq 5 ];then +if [ $# -ge 5 ];then if [ $5 = "windows" ];then # called by .bat file - sh $1/template/android/copy_files.sh $1 $2 $3 $4 + length=`expr $# - 5` + PARAMS=${@:6:$length} + check_param + sh $1/template/android/copy_files.sh $1 $2 $3 $4 $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA exit fi fi - # the bash file should not be called by cygwin KERNEL_NAME=`uname -s | grep "CYGWIN*"` if [ $KERNEL_NAME"hi" != "hi" ]; then @@ -70,13 +118,15 @@ create_android_project(){ } check_path +PARAMS=$@ +check_param create_android_project -if [ $# -eq 1 ]; then +if [ $0 == "linux" ]; then # invoked by create-linux-android-project.sh - sh `pwd`/template/linux/mycopy_files.sh `pwd` $PROJECT_NAME $NDK_ROOT_LOCAL $PACKAGE_PATH + sh `pwd`/template/linux/mycopy_files.sh `pwd` $PROJECT_NAME $NDK_ROOT_LOCAL $PACKAGE_PATH $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA else # invoke template/android/copy_files.sh - sh `pwd`/template/android/copy_files.sh `pwd` $PROJECT_NAME $NDK_ROOT_LOCAL $PACKAGE_PATH + sh `pwd`/template/android/copy_files.sh `pwd` $PROJECT_NAME $NDK_ROOT_LOCAL $PACKAGE_PATH $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA fi diff --git a/create-linux-eclipse-project.sh b/create-linux-eclipse-project.sh index 5fb14ee94b..8f5679e28b 100755 --- a/create-linux-eclipse-project.sh +++ b/create-linux-eclipse-project.sh @@ -6,4 +6,4 @@ # set environment paramters -sh `pwd`/create-android-project.sh linux +sh `pwd`/create-android-project.sh linux $@ diff --git a/template/android/AndroidTemplate1.mk b/template/android/AndroidTemplate1.mk deleted file mode 100644 index 1849647645..0000000000 --- a/template/android/AndroidTemplate1.mk +++ /dev/null @@ -1,25 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := game_shared - -LOCAL_MODULE_FILENAME := libgame - -LOCAL_SRC_FILES := main.cpp - -LOCAL_STATIC_LIBRARIES := png_static_prebuilt -LOCAL_STATIC_LIBRARIES += xml2_static_prebuilt -LOCAL_STATIC_LIBRARIES += jpeg_static_prebuilt -LOCAL_STATIC_LIBRARIES += curl_static_prebuilt -LOCAL_WHOLE_STATIC_LIBRARIES := game_logic_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static - -LOCAL_SHARED_LIBRARIES := cocosdenshion_shared - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx/platform/third_party/android/modules/libcurl) -$(call import-module,cocos2dx/platform/third_party/android/modules/libpng) -$(call import-module,cocos2dx/platform/third_party/android/modules/libxml2) -$(call import-module,cocos2dx/platform/third_party/android/modules/libjpeg) diff --git a/template/android/AndroidTemplate2.mk b/template/android/AndroidTemplate2.mk deleted file mode 100644 index 87e30c591e..0000000000 --- a/template/android/AndroidTemplate2.mk +++ /dev/null @@ -1,10 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \ - cocos2dx \ - CocosDenshion/android \ - )) -subdirs += $(LOCAL_PATH)/../../Classes/Android.mk $(LOCAL_PATH)/helloworld/Android.mk - -include $(subdirs) diff --git a/template/android/Application.mk b/template/android/Application.mk deleted file mode 100644 index 0b0868cee6..0000000000 --- a/template/android/Application.mk +++ /dev/null @@ -1,3 +0,0 @@ -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := cocos2dx_static cocosdenshion_shared game_logic_static game_shared diff --git a/template/android/application.sh b/template/android/application.sh new file mode 100644 index 0000000000..aa65b732ca --- /dev/null +++ b/template/android/application.sh @@ -0,0 +1,25 @@ +FILE=$1 +NEED_BOX2D=$2 +NEED_CHIPMUNK=$3 +NEED_LUA=$4 + +APP_MODULES="APP_MODULES := cocos2dx_static cocosdenshion_shared" +if [ $NEED_BOX2D == "true" ];then + APP_MODULES+=" box2d_shared" +fi + +if [ $NEED_CHIPMUNK == "true" ]; then + APP_MODULES+=" chipmunk_shared" +fi + +if [ $NEED_LUA == "true" ]; then + APP_MODULES+=" lua_shared" +fi + +APP_MODULES+=" game_shared" + +cat > $FILE << EOF +APP_STL := gnustl_static +APP_CPPFLAGS += -frtti +$APP_MODULES +EOF diff --git a/template/android/classesmk.sh b/template/android/classesmk.sh new file mode 100644 index 0000000000..5bbf727b12 --- /dev/null +++ b/template/android/classesmk.sh @@ -0,0 +1,46 @@ +FILE=$1 +NEED_BOX2D=$2 +NEED_CHIPMUNK=$3 +NEED_LUA=$4 + +LOCAL_SHARED_LIBRARIES="LOCAL_SHARED_LIBRARIES := cocosdenshion_shared" + +if [ $NEED_BOX2D == "true" ];then + LOCAL_SHARED_LIBRARIES+=" box2d_shared" +fi + +if [ $NEED_CHIPMUNK == "true" ]; then + LOCAL_SHARED_LIBRARIES+=" chipmunk_shared" +fi + +if [ $NEED_LUA == "true" ]; then + LOCAL_SHARED_LIBRARIES+=" lua_shared" +fi + +cat > $FILE << EOF +LOCAL_PATH := \$(call my-dir) + +include \$(CLEAR_VARS) + +LOCAL_MODULE := game_logic_static + +LOCAL_MODULE_FILENAME := libgame_logic + +LOCAL_SRC_FILES := AppDelegate.cpp \\ + HelloWorldScene.cpp + +LOCAL_EXPORT_C_INCLUDES := \$(LOCAL_PATH) + +LOCAL_STATIC_LIBRARIES := png_static_prebuilt +LOCAL_STATIC_LIBRARIES += xml2_static_prebuilt +LOCAL_STATIC_LIBRARIES += jpeg_static_prebuilt +LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static + +$LOCAL_SHARED_LIBRARIES + +include \$(BUILD_STATIC_LIBRARY) + +\$(call import-module,cocos2dx/platform/third_party/android/modules/libpng) +\$(call import-module,cocos2dx/platform/third_party/android/modules/libxml2) +\$(call import-module,cocos2dx/platform/third_party/android/modules/libjpeg) +EOF \ No newline at end of file diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh index e865f24ea0..4c50082650 100644 --- a/template/android/copy_files.sh +++ b/template/android/copy_files.sh @@ -7,6 +7,9 @@ APP_DIR=$COCOS2DX_ROOT/$APP_NAME HELLOWORLD_ROOT=$COCOS2DX_ROOT/HelloWorld NDK_ROOT=$3 PACKAGE_PATH=$4 +NEED_BOX2D=$5 +NEED_CHIPMUNK=$6 +NEED_LUA=$7 # xxx.yyy.zzz -> xxx/yyy/zzz convert_package_path_to_dir(){ @@ -57,8 +60,10 @@ copy_src_and_jni(){ cp -rf $HELLOWORLD_ROOT/android/src $APP_DIR/android # repalce Android.mk and Application.mk - cat $COCOS2DX_ROOT/template/android/AndroidTemplate1.mk > $APP_DIR/android/jni/helloworld/Android.mk - cat $COCOS2DX_ROOT/template/android/Application.mk > $APP_DIR/android/jni/Application.mk + sh $COCOS2DX_ROOT/template/android/classesmk.sh $APP_DIR/Classes/Android.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA + sh $COCOS2DX_ROOT/template/android/gamestaticmk.sh $APP_DIR/android/jni/Android.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA + sh $COCOS2DX_ROOT/template/android/gamemk.sh $APP_DIR/android/jni/helloworld/Android.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA + sh $COCOS2DX_ROOT/template/android/application.sh $APP_DIR/android/jni/Application.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA } # copy build_native.sh and replace something @@ -80,11 +85,24 @@ modify_applicationdemo(){ # rename APP_DIR/android/src/org/cocos2dx/application/ApplicationDemo.java to # APP_DIR/android/src/org/cocos2dx/application/$APP_NAME.java, change helloworld to game - sed "s/ApplicationDemo/$APP_NAME/;s/helloworld/game/;s/org\.cocos2dx\.application/$PACKAGE_PATH/" $APP_DIR/android/src/org/cocos2dx/application/ApplicationDemo.java > $APP_DIR/android/src/$PACKAGE_PATH_DIR/tempfile.java + sed "s/ApplicationDemo/$APP_NAME/;s/helloworld/game/;s/org\.cocos2dx\.application/$PACKAGE_PATH/" $APP_DIR/android/src/org/cocos2dx/application/ApplicationDemo.java > $APP_DIR/android/src/$PACKAGE_PATH_DIR/$APP_NAME.java rm -fr $APP_DIR/android/src/org/cocos2dx/application - mv $APP_DIR/android/src/$PACKAGE_PATH_DIR/tempfile.java $APP_DIR/android/src/$PACKAGE_PATH_DIR/$APP_NAME.java + # load need .so + CONTENT= + if [ $NEED_BOX2D == "true" ];then + CONTENT+='System.loadLibrary("box2d");' + fi + + if [ $NEED_CHIPMUNK == "true" ]; then + CONTENT+='System.loadLibrary("chipmunk");' + fi + + if [ $NEED_LUA == "true" ]; then + CONTENT+='System.loadLibrary("lua");' + fi + sed -i "/cocosdenshion/ i\ $CONTENT" $APP_DIR/android/src/$PACKAGE_PATH_DIR/$APP_NAME.java } modify_layout(){ diff --git a/template/android/gamemk.sh b/template/android/gamemk.sh new file mode 100644 index 0000000000..feb71945bd --- /dev/null +++ b/template/android/gamemk.sh @@ -0,0 +1,46 @@ +FILE=$1 +NEED_BOX2D=$2 +NEED_CHIPMUNK=$3 +NEED_LUA=$4 + +LOCAL_SHARED_LIBRARIES="LOCAL_SHARED_LIBRARIES := cocosdenshion_shared" + +if [ $NEED_BOX2D == "true" ];then + LOCAL_SHARED_LIBRARIES+=" box2d_shared" +fi + +if [ $NEED_CHIPMUNK == "true" ]; then + LOCAL_SHARED_LIBRARIES+=" chipmunk_shared" +fi + +if [ $NEED_LUA == "true" ]; then + LOCAL_SHARED_LIBRARIES+=" lua_shared" +fi + +cat > $FILE << EOF +LOCAL_PATH := \$(call my-dir) + +include \$(CLEAR_VARS) + +LOCAL_MODULE := game_shared + +LOCAL_MODULE_FILENAME := libgame + +LOCAL_SRC_FILES := main.cpp + +LOCAL_STATIC_LIBRARIES := png_static_prebuilt +LOCAL_STATIC_LIBRARIES += xml2_static_prebuilt +LOCAL_STATIC_LIBRARIES += jpeg_static_prebuilt +LOCAL_STATIC_LIBRARIES += curl_static_prebuilt +LOCAL_WHOLE_STATIC_LIBRARIES := game_logic_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static + +$LOCAL_SHARED_LIBRARIES + +include \$(BUILD_SHARED_LIBRARY) + +\$(call import-module,cocos2dx/platform/third_party/android/modules/libcurl) +\$(call import-module,cocos2dx/platform/third_party/android/modules/libpng) +\$(call import-module,cocos2dx/platform/third_party/android/modules/libxml2) +\$(call import-module,cocos2dx/platform/third_party/android/modules/libjpeg) +EOF \ No newline at end of file diff --git a/template/android/gamestaticmk.sh b/template/android/gamestaticmk.sh new file mode 100644 index 0000000000..4df459e2bc --- /dev/null +++ b/template/android/gamestaticmk.sh @@ -0,0 +1,31 @@ +FILE=$1 +NEED_BOX2D=$2 +NEED_CHIPMUNK=$3 +NEED_LUA=$4 + +if [ $NEED_BOX2D == "true" ];then + BOX2D="Box2D" +fi + +if [ $NEED_CHIPMUNK == "true" ]; then + CHIPMUNK="chipmunk" +fi + +if [ $NEED_LUA == "true" ]; then + LUA="lua/proj.android/jni" +fi + +cat > $FILE << EOF +LOCAL_PATH := \$(call my-dir) +include \$(CLEAR_VARS) + +subdirs := \$(addprefix \$(LOCAL_PATH)/../../../,\$(addsuffix /Android.mk, \\ + cocos2dx \\ + CocosDenshion/android \\ + $BOX2D $CHIPMUNK $LUA \\ + )) + +subdirs += \$(LOCAL_PATH)/../../Classes/Android.mk \$(LOCAL_PATH)/helloworld/Android.mk + +include \$(subdirs) +EOF \ No newline at end of file From a87e76c399c27bef746b9afe75cd4f012793d4f5 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 1 Mar 2012 02:51:58 +0800 Subject: [PATCH 2/3] fixed #982: android template works ok on linux --- create-android-project.sh | 8 ++++---- template/android/application.sh | 16 +++++++++------- template/android/classesmk.sh | 16 +++++++++------- template/android/copy_files.sh | 13 +++++++------ template/android/gamemk.sh | 16 +++++++++------- template/android/gamestaticmk.sh | 10 ++++++---- 6 files changed, 44 insertions(+), 35 deletions(-) diff --git a/create-android-project.sh b/create-android-project.sh index e9df062562..c0ce7b5b68 100755 --- a/create-android-project.sh +++ b/create-android-project.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This script should be called by create-android-project.bat # or should be runned in linux shell. It can not be runned under # cygwin. @@ -57,8 +57,8 @@ check_param(){ esac done - if [ $NEED_BOX2D == "true" ]; then - if [ $NEED_CHIPMUNK == "true" ]; then + if [ $NEED_BOX2D = "true" ]; then + if [ $NEED_CHIPMUNK = "true" ]; then echo Warning!!! echo Use box2d and chipmunk together???? fi @@ -122,7 +122,7 @@ PARAMS=$@ check_param create_android_project -if [ $0 == "linux" ]; then +if [ $0 = "linux" ]; then # invoked by create-linux-android-project.sh sh `pwd`/template/linux/mycopy_files.sh `pwd` $PROJECT_NAME $NDK_ROOT_LOCAL $PACKAGE_PATH $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA else diff --git a/template/android/application.sh b/template/android/application.sh index aa65b732ca..6fb420c15b 100644 --- a/template/android/application.sh +++ b/template/android/application.sh @@ -1,22 +1,24 @@ +#!/bin/bash + FILE=$1 NEED_BOX2D=$2 NEED_CHIPMUNK=$3 NEED_LUA=$4 APP_MODULES="APP_MODULES := cocos2dx_static cocosdenshion_shared" -if [ $NEED_BOX2D == "true" ];then - APP_MODULES+=" box2d_shared" +if [ $NEED_BOX2D = "true" ];then + APP_MODULES=$APP_MODULES" box2d_shared" fi -if [ $NEED_CHIPMUNK == "true" ]; then - APP_MODULES+=" chipmunk_shared" +if [ $NEED_CHIPMUNK = "true" ]; then + APP_MODULES=$APP_MODULES" chipmunk_shared" fi -if [ $NEED_LUA == "true" ]; then - APP_MODULES+=" lua_shared" +if [ $NEED_LUA = "true" ]; then + APP_MODULES=$APP_MODULES" lua_shared" fi -APP_MODULES+=" game_shared" +APP_MODULES=$APP_MODULES" game_shared" cat > $FILE << EOF APP_STL := gnustl_static diff --git a/template/android/classesmk.sh b/template/android/classesmk.sh index 5bbf727b12..735f7f312d 100644 --- a/template/android/classesmk.sh +++ b/template/android/classesmk.sh @@ -1,3 +1,5 @@ +#!/bin/bash + FILE=$1 NEED_BOX2D=$2 NEED_CHIPMUNK=$3 @@ -5,16 +7,16 @@ NEED_LUA=$4 LOCAL_SHARED_LIBRARIES="LOCAL_SHARED_LIBRARIES := cocosdenshion_shared" -if [ $NEED_BOX2D == "true" ];then - LOCAL_SHARED_LIBRARIES+=" box2d_shared" +if [ $NEED_BOX2D = "true" ];then + LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" box2d_shared" fi -if [ $NEED_CHIPMUNK == "true" ]; then - LOCAL_SHARED_LIBRARIES+=" chipmunk_shared" +if [ $NEED_CHIPMUNK = "true" ]; then + LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" chipmunk_shared" fi -if [ $NEED_LUA == "true" ]; then - LOCAL_SHARED_LIBRARIES+=" lua_shared" +if [ $NEED_LUA = "true" ]; then + LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" lua_shared" fi cat > $FILE << EOF @@ -43,4 +45,4 @@ include \$(BUILD_STATIC_LIBRARY) \$(call import-module,cocos2dx/platform/third_party/android/modules/libpng) \$(call import-module,cocos2dx/platform/third_party/android/modules/libxml2) \$(call import-module,cocos2dx/platform/third_party/android/modules/libjpeg) -EOF \ No newline at end of file +EOF diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh index 4c50082650..ae11cccf4f 100644 --- a/template/android/copy_files.sh +++ b/template/android/copy_files.sh @@ -1,3 +1,4 @@ +#!/bin/bash # check the args # $1: root of cocos2dx $2: app name $3: ndk root $4:pakcage path @@ -90,16 +91,16 @@ modify_applicationdemo(){ # load need .so CONTENT= - if [ $NEED_BOX2D == "true" ];then - CONTENT+='System.loadLibrary("box2d");' + if [ $NEED_BOX2D = "true" ];then + CONTENT=$CONTENT'System.loadLibrary("box2d");' fi - if [ $NEED_CHIPMUNK == "true" ]; then - CONTENT+='System.loadLibrary("chipmunk");' + if [ $NEED_CHIPMUNK = "true" ]; then + CONTENT=$CONTENT'System.loadLibrary("chipmunk");' fi - if [ $NEED_LUA == "true" ]; then - CONTENT+='System.loadLibrary("lua");' + if [ $NEED_LUA = "true" ]; then + CONTENT=$CONTENT'System.loadLibrary("lua");' fi sed -i "/cocosdenshion/ i\ $CONTENT" $APP_DIR/android/src/$PACKAGE_PATH_DIR/$APP_NAME.java diff --git a/template/android/gamemk.sh b/template/android/gamemk.sh index feb71945bd..208054a693 100644 --- a/template/android/gamemk.sh +++ b/template/android/gamemk.sh @@ -1,3 +1,5 @@ +#!/bin/bash + FILE=$1 NEED_BOX2D=$2 NEED_CHIPMUNK=$3 @@ -5,16 +7,16 @@ NEED_LUA=$4 LOCAL_SHARED_LIBRARIES="LOCAL_SHARED_LIBRARIES := cocosdenshion_shared" -if [ $NEED_BOX2D == "true" ];then - LOCAL_SHARED_LIBRARIES+=" box2d_shared" +if [ $NEED_BOX2D = "true" ];then + LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" box2d_shared" fi -if [ $NEED_CHIPMUNK == "true" ]; then - LOCAL_SHARED_LIBRARIES+=" chipmunk_shared" +if [ $NEED_CHIPMUNK = "true" ]; then + LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" chipmunk_shared" fi -if [ $NEED_LUA == "true" ]; then - LOCAL_SHARED_LIBRARIES+=" lua_shared" +if [ $NEED_LUA = "true" ]; then + LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" lua_shared" fi cat > $FILE << EOF @@ -43,4 +45,4 @@ include \$(BUILD_SHARED_LIBRARY) \$(call import-module,cocos2dx/platform/third_party/android/modules/libpng) \$(call import-module,cocos2dx/platform/third_party/android/modules/libxml2) \$(call import-module,cocos2dx/platform/third_party/android/modules/libjpeg) -EOF \ No newline at end of file +EOF diff --git a/template/android/gamestaticmk.sh b/template/android/gamestaticmk.sh index 4df459e2bc..b152ae8b3b 100644 --- a/template/android/gamestaticmk.sh +++ b/template/android/gamestaticmk.sh @@ -1,17 +1,19 @@ +#!/bin/bash + FILE=$1 NEED_BOX2D=$2 NEED_CHIPMUNK=$3 NEED_LUA=$4 -if [ $NEED_BOX2D == "true" ];then +if [ $NEED_BOX2D = "true" ];then BOX2D="Box2D" fi -if [ $NEED_CHIPMUNK == "true" ]; then +if [ $NEED_CHIPMUNK = "true" ]; then CHIPMUNK="chipmunk" fi -if [ $NEED_LUA == "true" ]; then +if [ $NEED_LUA = "true" ]; then LUA="lua/proj.android/jni" fi @@ -28,4 +30,4 @@ subdirs := \$(addprefix \$(LOCAL_PATH)/../../../,\$(addsuffix /Android.mk, \\ subdirs += \$(LOCAL_PATH)/../../Classes/Android.mk \$(LOCAL_PATH)/helloworld/Android.mk include \$(subdirs) -EOF \ No newline at end of file +EOF From 8e0d0304b736a9c6d55c3737b0bd77a5b131ed8d Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 1 Mar 2012 03:13:33 +0800 Subject: [PATCH 3/3] fixed #982: modify create-linux-eclipse-project.sh to support lua box2d and chipmunk --- create-linux-eclipse-project.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create-linux-eclipse-project.sh b/create-linux-eclipse-project.sh index 8f5679e28b..876f3ba975 100755 --- a/create-linux-eclipse-project.sh +++ b/create-linux-eclipse-project.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This script should be called by create-android-project.bat # or should be runned in linux shell. It can not be runned under # cygwin. @@ -6,4 +6,4 @@ # set environment paramters -sh `pwd`/create-android-project.sh linux $@ +bash `pwd`/create-android-project.sh -linux $@