From 75601fbc025a7d2639863ff8d474d1b8fe44aac5 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 2 May 2012 17:29:16 +0800 Subject: [PATCH] fixed #1201: simplify the writing of Android.mk and correct corresponding template --- HelloLua/Classes/Android.mk | 28 -------- HelloLua/proj.android/build_native.sh | 65 ++++++++++++++----- .../gen/org/cocos2dx/hellolua/R.java | 52 +++++++-------- HelloLua/proj.android/jni/Android.mk | 29 +++++++-- HelloLua/proj.android/jni/Application.mk | 7 +- .../proj.android/jni/helloworld/Android.mk | 23 ------- HelloLua/proj.android/project.properties | 2 +- .../src/org/cocos2dx/hellolua/HelloLua.java | 4 +- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- lua/proj.android/jni/Android.mk | 5 +- template/android/application.sh | 27 -------- template/android/build_native.sh | 49 ++++++++++++-- template/android/classesmk.sh | 48 -------------- template/android/copy_files.sh | 61 ++++++----------- template/android/gamemk.sh | 37 ++++++----- template/android/gamestaticmk.sh | 33 ---------- tools/tolua++/SimpleAudioEngine.pkg | 6 -- 17 files changed, 187 insertions(+), 291 deletions(-) delete mode 100644 HelloLua/Classes/Android.mk mode change 100644 => 100755 HelloLua/proj.android/build_native.sh delete mode 100644 HelloLua/proj.android/jni/helloworld/Android.mk delete mode 100644 template/android/application.sh delete mode 100644 template/android/classesmk.sh delete mode 100644 template/android/gamestaticmk.sh diff --git a/HelloLua/Classes/Android.mk b/HelloLua/Classes/Android.mk deleted file mode 100644 index 407e777ef0..0000000000 --- a/HelloLua/Classes/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := game_logic_static - -LOCAL_MODULE_FILENAME := libgame_logic - -LOCAL_SRC_FILES := \ -AppDelegate.cpp \ -../../lua/cocos2dx_support/CCLuaEngine.cpp \ -../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ -../../lua/cocos2dx_support/LuaCocos2d.cpp \ -../../lua/cocos2dx_support/tolua_fix.c - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_STATIC_LIBRARIES += xml2_static_prebuilt -LOCAL_STATIC_LIBRARIES += jpeg_static_prebuilt -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static - -LOCAL_SHARED_LIBRARIES := cocosdenshion_shared lua_shared - -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) diff --git a/HelloLua/proj.android/build_native.sh b/HelloLua/proj.android/build_native.sh old mode 100644 new mode 100755 index 0ef51c7883..1915d06719 --- a/HelloLua/proj.android/build_native.sh +++ b/HelloLua/proj.android/build_native.sh @@ -1,16 +1,42 @@ # set params -NDK_ROOT_LOCAL=/cygdrive/e/android/android-ndk-r7b -COCOS2DX_ROOT_LOCAL=/cygdrive/f/Project/dumganhar/cocos2d-x +NDK_ROOT_LOCAL=/cygdrive/d/programe/android/ndk/android-ndk-r7b +COCOS2DX_ROOT_LOCAL=/cygdrive/e/cocos2d-x + +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 +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 +echo "use global definition of COCOS2DX_ROOT: $COCOS2DX_ROOT" +COCOS2DX_ROOT_LOCAL=$COCOS2DX_ROOT fi GAME_ROOT=$COCOS2DX_ROOT_LOCAL/HelloLua @@ -19,7 +45,7 @@ GAME_RESOURCE_ROOT=$GAME_ROOT/Resources # make sure assets is exist if [ -d $GAME_ANDROID_ROOT/assets ]; then - rm -rf $GAME_ANDROID_ROOT/assets +rm -rf $GAME_ANDROID_ROOT/assets fi mkdir $GAME_ANDROID_ROOT/assets @@ -27,17 +53,22 @@ mkdir $GAME_ANDROID_ROOT/assets # copy resources for file in $GAME_RESOURCE_ROOT/* do - if [ -d $file ]; then - cp -rf $file $GAME_ANDROID_ROOT/assets - fi +if [ -d $file ]; then +cp -rf $file $GAME_ANDROID_ROOT/assets +fi - if [ -f $file ]; then - cp $file $GAME_ANDROID_ROOT/assets - fi +if [ -f $file ]; then +cp $file $GAME_ANDROID_ROOT/assets +fi done # build -pushd $NDK_ROOT_LOCAL -./ndk-build -C $GAME_ANDROID_ROOT $* -popd - +if [[ $buildexternalsfromsource ]]; then +echo "Building external dependencies from source" +$NDK_ROOT_LOCAL/ndk-build -C $GAME_ANDROID_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 $GAME_ANDROID_ROOT $* \ +NDK_MODULE_PATH=${COCOS2DX_ROOT_LOCAL}:${COCOS2DX_ROOT_LOCAL}/cocos2dx/platform/third_party/android/prebuilt +fi diff --git a/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java b/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java index ba4eac96cd..bad0413877 100644 --- a/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java +++ b/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java @@ -1,26 +1,26 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.cocos2dx.hellolua; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int test_demo_gl_surfaceview=0x7f050001; - public static final int textField=0x7f050000; - } - public static final class layout { - public static final int game_demo=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package org.cocos2dx.hellolua; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int icon=0x7f020000; + } + public static final class id { + public static final int test_demo_gl_surfaceview=0x7f050001; + public static final int textField=0x7f050000; + } + public static final class layout { + public static final int game_demo=0x7f030000; + } + public static final class string { + public static final int app_name=0x7f040000; + } +} diff --git a/HelloLua/proj.android/jni/Android.mk b/HelloLua/proj.android/jni/Android.mk index e2b1dcd516..7144854a1b 100644 --- a/HelloLua/proj.android/jni/Android.mk +++ b/HelloLua/proj.android/jni/Android.mk @@ -1,11 +1,26 @@ LOCAL_PATH := $(call my-dir) + include $(CLEAR_VARS) -subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \ - cocos2dx \ - CocosDenshion/android \ - lua/proj.android/jni \ - )) -subdirs += $(LOCAL_PATH)/../../Classes/Android.mk $(LOCAL_PATH)/helloworld/Android.mk +LOCAL_MODULE := game_shared -include $(subdirs) +LOCAL_MODULE_FILENAME := libgame + +LOCAL_SRC_FILES := helloworld/main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../../lua/cocos2dx_support/CCLuaEngine.cpp \ + ../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ + ../../../lua/cocos2dx_support/LuaCocos2d.cpp \ + ../../../lua/cocos2dx_support/tolua_fix.c + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,cocos2dx) +$(call import-module,CocosDenshion/android) +$(call import-module,lua/proj.android/jni) diff --git a/HelloLua/proj.android/jni/Application.mk b/HelloLua/proj.android/jni/Application.mk index 8f0cab314b..cb24aada5f 100644 --- a/HelloLua/proj.android/jni/Application.mk +++ b/HelloLua/proj.android/jni/Application.mk @@ -1,4 +1,3 @@ -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti - -APP_MODULES := cocos2dx_static cocosdenshion_shared lua_shared game_logic_static game_shared \ No newline at end of file +APP_STL := gnustl_static +APP_CPPFLAGS := -frtti +APP_CPPFLAGS += -fexceptions diff --git a/HelloLua/proj.android/jni/helloworld/Android.mk b/HelloLua/proj.android/jni/helloworld/Android.mk deleted file mode 100644 index 50e4fb8d4c..0000000000 --- a/HelloLua/proj.android/jni/helloworld/Android.mk +++ /dev/null @@ -1,23 +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_WHOLE_STATIC_LIBRARIES := game_logic_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static - -LOCAL_SHARED_LIBRARIES := cocosdenshion_shared lua_shared - -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) diff --git a/HelloLua/proj.android/project.properties b/HelloLua/proj.android/project.properties index f049142c17..ea89160e01 100644 --- a/HelloLua/proj.android/project.properties +++ b/HelloLua/proj.android/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-10 +target=android-8 diff --git a/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java b/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java index 85d3b23b8e..b8cb76b3de 100644 --- a/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java +++ b/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java @@ -77,9 +77,7 @@ public class HelloLua extends Cocos2dxActivity{ private LuaGLSurfaceView mGLView; - static { - System.loadLibrary("cocosdenshion"); - System.loadLibrary("lua"); + static { System.loadLibrary("game"); } } diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 299dc0b33a..e35fb068da 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -ae3ae184f6137f05f4caa10d92a1d2f99dca3c54 \ No newline at end of file +99a350af562498cb7fcbaec3063f86f9d05889fe \ No newline at end of file diff --git a/lua/proj.android/jni/Android.mk b/lua/proj.android/jni/Android.mk index b0100a64e6..34739f5758 100644 --- a/lua/proj.android/jni/Android.mk +++ b/lua/proj.android/jni/Android.mk @@ -1,8 +1,7 @@ LOCAL_PATH := $(call my-dir) - include $(CLEAR_VARS) -LOCAL_MODULE := lua_shared +LOCAL_MODULE := cocos_lua_static LOCAL_MODULE_FILENAME := liblua @@ -52,4 +51,4 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ $(LOCAL_PATH)/../../lua -include $(BUILD_SHARED_LIBRARY) +include $(BUILD_STATIC_LIBRARY) \ No newline at end of file diff --git a/template/android/application.sh b/template/android/application.sh deleted file mode 100644 index 6fb420c15b..0000000000 --- a/template/android/application.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/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=$APP_MODULES" box2d_shared" -fi - -if [ $NEED_CHIPMUNK = "true" ]; then - APP_MODULES=$APP_MODULES" chipmunk_shared" -fi - -if [ $NEED_LUA = "true" ]; then - APP_MODULES=$APP_MODULES" lua_shared" -fi - -APP_MODULES=$APP_MODULES" game_shared" - -cat > $FILE << EOF -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -$APP_MODULES -EOF diff --git a/template/android/build_native.sh b/template/android/build_native.sh index a4de90f564..9c6d50ada5 100644 --- a/template/android/build_native.sh +++ b/template/android/build_native.sh @@ -2,9 +2,35 @@ NDK_ROOT=__ndkroot__ COCOS2DX_ROOT=__cocos2dxroot__ GAME_ROOT=$COCOS2DX_ROOT/__projectname__ -GAME_ANDROID_ROOT=$GAME_ROOT/android +GAME_ANDROID_ROOT=$GAME_ROOT/proj.android RESOURCE_ROOT=$GAME_ROOT/Resources +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 + # make sure assets is exist if [ -d $GAME_ANDROID_ROOT/assets ]; then rm -rf $GAME_ANDROID_ROOT/assets @@ -15,15 +41,24 @@ mkdir $GAME_ANDROID_ROOT/assets # copy resources for file in $RESOURCE_ROOT/* do - if [ -d $file ]; then - cp -rf $file $GAME_ANDROID_ROOT/assets + if [ -d "$file" ]; then + cp -rf "$file" $GAME_ANDROID_ROOT/assets fi - if [ -f $file ]; then - cp $file $GAME_ANDROID_ROOT/assets + if [ -f "$file" ]; then + cp "$file" $GAME_ANDROID_ROOT/assets fi done -# build -$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT $* +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 + + diff --git a/template/android/classesmk.sh b/template/android/classesmk.sh deleted file mode 100644 index 735f7f312d..0000000000 --- a/template/android/classesmk.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -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=$LOCAL_SHARED_LIBRARIES" box2d_shared" -fi - -if [ $NEED_CHIPMUNK = "true" ]; then - LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" chipmunk_shared" -fi - -if [ $NEED_LUA = "true" ]; then - LOCAL_SHARED_LIBRARIES=$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 diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh index 1798001c1c..b127ecc876 100644 --- a/template/android/copy_files.sh +++ b/template/android/copy_files.sh @@ -19,18 +19,18 @@ convert_package_path_to_dir(){ # make director andorid and copy all files and directories into it move_files_into_android(){ - mkdir $APP_DIR/android + mkdir $APP_DIR/proj.android for file in $APP_DIR/* do if [ -d $file ]; then - if [ $file != $APP_DIR/android ]; then - mv -f $file $APP_DIR/android + if [ $file != $APP_DIR/proj.android ]; then + mv -f $file $APP_DIR/proj.android fi fi if [ -f $file ]; then - mv $file $APP_DIR/android + mv $file $APP_DIR/proj.android fi done } @@ -57,27 +57,24 @@ copy_resouces(){ # from HelloWorld copy src and jni to APP_DIR copy_src_and_jni(){ - cp -rf $HELLOWORLD_ROOT/android/jni $APP_DIR/android - cp -rf $HELLOWORLD_ROOT/android/src $APP_DIR/android + cp -rf $HELLOWORLD_ROOT/proj.android/jni $APP_DIR/proj.android + cp -rf $HELLOWORLD_ROOT/proj.android/src $APP_DIR/proj.android - # repalce Android.mk and 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 + # repalce Android.mk + sh $COCOS2DX_ROOT/template/android/gamemk.sh $APP_DIR/proj.android/jni/Android.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA } # copy build_native.sh and replace something copy_build_native(){ # here should use # instead of /, why?? - sed "s#__cocos2dxroot__#$COCOS2DX_ROOT#;s#__ndkroot__#$NDK_ROOT#;s#__projectname__#$APP_NAME#" $COCOS2DX_ROOT/template/android/build_native.sh > $APP_DIR/android/build_native.sh - chmod u+x $APP_DIR/android/build_native.sh + sed "s#__cocos2dxroot__#$COCOS2DX_ROOT#;s#__ndkroot__#$NDK_ROOT#;s#__projectname__#$APP_NAME#" $COCOS2DX_ROOT/template/android/build_native.sh > $APP_DIR/proj.android/build_native.sh + chmod u+x $APP_DIR/proj.android/build_native.sh } # replace AndroidManifext.xml and change the activity name # use sed to replace the specified line modify_androidmanifest(){ - sed "s/ApplicationDemo/$APP_NAME/;s/org\.cocos2dx\.application/$PACKAGE_PATH/" $HELLOWORLD_ROOT/android/AndroidManifest.xml > $APP_DIR/android/AndroidManifest.xml + sed "s/ApplicationDemo/$APP_NAME/;s/org\.cocos2dx\.application/$PACKAGE_PATH/" $HELLOWORLD_ROOT/proj.android/AndroidManifest.xml > $APP_DIR/proj.android/AndroidManifest.xml } # modify ApplicationDemo.java @@ -86,40 +83,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/$APP_NAME.java - rm -fr $APP_DIR/android/src/org/cocos2dx/application - - # load need .so - CONTENT= - if [ $NEED_BOX2D = "true" ];then - CONTENT=$CONTENT'System.loadLibrary("box2d");' - fi - - if [ $NEED_CHIPMUNK = "true" ]; then - CONTENT=$CONTENT'System.loadLibrary("chipmunk");' - fi - - if [ $NEED_LUA = "true" ]; then - CONTENT=$CONTENT'System.loadLibrary("lua");' - fi - - sed -i -e "s/System.loadLibrary(\"cocosdenshion\")\;/System.loadLibrary(\"cocosdenshion\")\;$CONTENT/" $APP_DIR/android/src/$PACKAGE_PATH_DIR/$APP_NAME.java + sed "s/ApplicationDemo/$APP_NAME/;s/helloworld/game/;s/org\.cocos2dx\.application/$PACKAGE_PATH/" $APP_DIR/proj.android/src/org/cocos2dx/application/ApplicationDemo.java > $APP_DIR/proj.android/src/$PACKAGE_PATH_DIR/$APP_NAME.java + rm -fr $APP_DIR/proj.android/src/org/cocos2dx/application } modify_layout(){ - cp $HELLOWORLD_ROOT/android/res/layout/helloworld_demo.xml $APP_DIR/android/res/layout - sed "s/helloworld_gl_surfaceview/game_gl_surfaceview/" $APP_DIR/android/res/layout/helloworld_demo.xml > $APP_DIR/android/res/layout/game_demo.xml - rm -f $APP_DIR/android/res/layout/main.xml - rm -f $APP_DIR/android/res/layout/helloworld_demo.xml + cp $HELLOWORLD_ROOT/proj.android/res/layout/helloworld_demo.xml $APP_DIR/proj.android/res/layout + sed "s/helloworld_gl_surfaceview/game_gl_surfaceview/" $APP_DIR/proj.android/res/layout/helloworld_demo.xml > $APP_DIR/proj.android/res/layout/game_demo.xml + rm -f $APP_DIR/proj.android/res/layout/main.xml + rm -f $APP_DIR/proj.android/res/layout/helloworld_demo.xml } # android.bat of android 4.0 don't create res/drawable-hdpi res/drawable-ldpi and res/drawable-mdpi. # These work are done in ADT copy_icon(){ - if [ ! -d $APP_DIR/android/res/drawable-hdpi ]; then - cp -r $HELLOWORLD_ROOT/android/res/drawable-hdpi $APP_DIR/android/res - cp -r $HELLOWORLD_ROOT/android/res/drawable-ldpi $APP_DIR/android/res - cp -r $HELLOWORLD_ROOT/android/res/drawable-mdpi $APP_DIR/android/res + if [ ! -d $APP_DIR/proj.android/res/drawable-hdpi ]; then + cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-hdpi $APP_DIR/proj.android/res + cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-ldpi $APP_DIR/proj.android/res + cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-mdpi $APP_DIR/proj.android/res fi } diff --git a/template/android/gamemk.sh b/template/android/gamemk.sh index 208054a693..4878fe1f85 100644 --- a/template/android/gamemk.sh +++ b/template/android/gamemk.sh @@ -5,18 +5,29 @@ NEED_BOX2D=$2 NEED_CHIPMUNK=$3 NEED_LUA=$4 -LOCAL_SHARED_LIBRARIES="LOCAL_SHARED_LIBRARIES := cocosdenshion_shared" +LOCAL_STATIC_LIBRARIES="LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static" +MODULES_TO_CALL="\$(call import-module,CocosDenshion/android) \$(call import-module,cocos2dx)" +LOCAL_SRC_FILES="LOCAL_SRC_FILES := helloworld/main.cpp \\ + ../../Classes/AppDelegate.cpp \\ + ../../Classes/HelloWorldScene.cpp" if [ $NEED_BOX2D = "true" ];then - LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" box2d_shared" + LOCAL_STATIC_LIBRARIES=$LOCAL_STATIC_LIBRARIES" box2d_static" + MODULES_TO_CALL=$MODULES_TO_CALL" \$(call import-module,Box2D)" fi if [ $NEED_CHIPMUNK = "true" ]; then - LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" chipmunk_shared" + LOCAL_STATIC_LIBRARIES=$LOCAL_STATIC_LIBRARIES" chipmunk_static" + MODULES_TO_CALL=$MODULES_TO_CALL" \$(call import-module,chipmunk)" fi if [ $NEED_LUA = "true" ]; then - LOCAL_SHARED_LIBRARIES=$LOCAL_SHARED_LIBRARIES" lua_shared" + LOCAL_STATIC_LIBRARIES=$LOCAL_STATIC_LIBRARIES" cocos_lua_static" + MODULES_TO_CALL=$MODULES_TO_CALL" \$(call import-module,lua/proj.android/jni)" + LOCAL_SRC_FILES=$LOCAL_SRC_FILES" ../../../lua/cocos2dx_support/CCLuaEngine.cpp \\ + ../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \\ + ../../../lua/cocos2dx_support/LuaCocos2d.cpp \\ + ../../../lua/cocos2dx_support/tolua_fix.c" fi cat > $FILE << EOF @@ -28,21 +39,13 @@ LOCAL_MODULE := game_shared LOCAL_MODULE_FILENAME := libgame -LOCAL_SRC_FILES := main.cpp +$LOCAL_SRC_FILES + +LOCAL_C_INCLUDES := \$(LOCAL_PATH)/../../Classes -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 +$LOCAL_STATIC_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) +$MODULES_TO_CALL EOF diff --git a/template/android/gamestaticmk.sh b/template/android/gamestaticmk.sh deleted file mode 100644 index b152ae8b3b..0000000000 --- a/template/android/gamestaticmk.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -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 diff --git a/tools/tolua++/SimpleAudioEngine.pkg b/tools/tolua++/SimpleAudioEngine.pkg index 4c011350dd..47002d2fdc 100644 --- a/tools/tolua++/SimpleAudioEngine.pkg +++ b/tools/tolua++/SimpleAudioEngine.pkg @@ -30,12 +30,6 @@ class SimpleAudioEngine */ static SimpleAudioEngine* sharedEngine(); - /** - @brief Set the zip file name - @param pszZipFileName The relative path of the .zip file - */ - static void setResource(const char* pszZipFileName); - /** @brief Preload background music @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo