mirror of https://github.com/axmolengine/axmol.git
fixed #1201: simplify the writing of Android.mk and correct corresponding template
This commit is contained in:
parent
c048fe77c6
commit
75601fbc02
|
@ -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)
|
|
|
@ -1,16 +1,42 @@
|
||||||
# set params
|
# set params
|
||||||
NDK_ROOT_LOCAL=/cygdrive/e/android/android-ndk-r7b
|
NDK_ROOT_LOCAL=/cygdrive/d/programe/android/ndk/android-ndk-r7b
|
||||||
COCOS2DX_ROOT_LOCAL=/cygdrive/f/Project/dumganhar/cocos2d-x
|
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
|
# try to get global variable
|
||||||
if [ $NDK_ROOT"aaa" != "aaa" ]; then
|
if [ $NDK_ROOT"aaa" != "aaa" ]; then
|
||||||
echo "use global definition of NDK_ROOT: $NDK_ROOT"
|
echo "use global definition of NDK_ROOT: $NDK_ROOT"
|
||||||
NDK_ROOT_LOCAL=$NDK_ROOT
|
NDK_ROOT_LOCAL=$NDK_ROOT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $COCOS2DX_ROOT"aaa" != "aaa" ]; then
|
if [ $COCOS2DX_ROOT"aaa" != "aaa" ]; then
|
||||||
echo "use global definition of COCOS2DX_ROOT: $COCOS2DX_ROOT"
|
echo "use global definition of COCOS2DX_ROOT: $COCOS2DX_ROOT"
|
||||||
COCOS2DX_ROOT_LOCAL=$COCOS2DX_ROOT
|
COCOS2DX_ROOT_LOCAL=$COCOS2DX_ROOT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GAME_ROOT=$COCOS2DX_ROOT_LOCAL/HelloLua
|
GAME_ROOT=$COCOS2DX_ROOT_LOCAL/HelloLua
|
||||||
|
@ -19,7 +45,7 @@ GAME_RESOURCE_ROOT=$GAME_ROOT/Resources
|
||||||
|
|
||||||
# make sure assets is exist
|
# make sure assets is exist
|
||||||
if [ -d $GAME_ANDROID_ROOT/assets ]; then
|
if [ -d $GAME_ANDROID_ROOT/assets ]; then
|
||||||
rm -rf $GAME_ANDROID_ROOT/assets
|
rm -rf $GAME_ANDROID_ROOT/assets
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir $GAME_ANDROID_ROOT/assets
|
mkdir $GAME_ANDROID_ROOT/assets
|
||||||
|
@ -27,17 +53,22 @@ mkdir $GAME_ANDROID_ROOT/assets
|
||||||
# copy resources
|
# copy resources
|
||||||
for file in $GAME_RESOURCE_ROOT/*
|
for file in $GAME_RESOURCE_ROOT/*
|
||||||
do
|
do
|
||||||
if [ -d $file ]; then
|
if [ -d $file ]; then
|
||||||
cp -rf $file $GAME_ANDROID_ROOT/assets
|
cp -rf $file $GAME_ANDROID_ROOT/assets
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $file ]; then
|
if [ -f $file ]; then
|
||||||
cp $file $GAME_ANDROID_ROOT/assets
|
cp $file $GAME_ANDROID_ROOT/assets
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# build
|
# build
|
||||||
pushd $NDK_ROOT_LOCAL
|
if [[ $buildexternalsfromsource ]]; then
|
||||||
./ndk-build -C $GAME_ANDROID_ROOT $*
|
echo "Building external dependencies from source"
|
||||||
popd
|
$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
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||||
*
|
*
|
||||||
* This class was automatically generated by the
|
* This class was automatically generated by the
|
||||||
* aapt tool from the resource data it found. It
|
* aapt tool from the resource data it found. It
|
||||||
* should not be modified by hand.
|
* should not be modified by hand.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.cocos2dx.hellolua;
|
package org.cocos2dx.hellolua;
|
||||||
|
|
||||||
public final class R {
|
public final class R {
|
||||||
public static final class attr {
|
public static final class attr {
|
||||||
}
|
}
|
||||||
public static final class drawable {
|
public static final class drawable {
|
||||||
public static final int icon=0x7f020000;
|
public static final int icon=0x7f020000;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int test_demo_gl_surfaceview=0x7f050001;
|
public static final int test_demo_gl_surfaceview=0x7f050001;
|
||||||
public static final int textField=0x7f050000;
|
public static final int textField=0x7f050000;
|
||||||
}
|
}
|
||||||
public static final class layout {
|
public static final class layout {
|
||||||
public static final int game_demo=0x7f030000;
|
public static final int game_demo=0x7f030000;
|
||||||
}
|
}
|
||||||
public static final class string {
|
public static final class string {
|
||||||
public static final int app_name=0x7f040000;
|
public static final int app_name=0x7f040000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \
|
LOCAL_MODULE := game_shared
|
||||||
cocos2dx \
|
|
||||||
CocosDenshion/android \
|
|
||||||
lua/proj.android/jni \
|
|
||||||
))
|
|
||||||
subdirs += $(LOCAL_PATH)/../../Classes/Android.mk $(LOCAL_PATH)/helloworld/Android.mk
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
APP_STL := gnustl_static
|
APP_STL := gnustl_static
|
||||||
APP_CPPFLAGS += -frtti
|
APP_CPPFLAGS := -frtti
|
||||||
|
APP_CPPFLAGS += -fexceptions
|
||||||
APP_MODULES := cocos2dx_static cocosdenshion_shared lua_shared game_logic_static game_shared
|
|
||||||
|
|
|
@ -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)
|
|
|
@ -8,4 +8,4 @@
|
||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-10
|
target=android-8
|
||||||
|
|
|
@ -77,9 +77,7 @@ public class HelloLua extends Cocos2dxActivity{
|
||||||
private LuaGLSurfaceView mGLView;
|
private LuaGLSurfaceView mGLView;
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("cocosdenshion");
|
|
||||||
System.loadLibrary("lua");
|
|
||||||
System.loadLibrary("game");
|
System.loadLibrary("game");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
ae3ae184f6137f05f4caa10d92a1d2f99dca3c54
|
99a350af562498cb7fcbaec3063f86f9d05889fe
|
|
@ -1,8 +1,7 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE := lua_shared
|
LOCAL_MODULE := cocos_lua_static
|
||||||
|
|
||||||
LOCAL_MODULE_FILENAME := liblua
|
LOCAL_MODULE_FILENAME := liblua
|
||||||
|
|
||||||
|
@ -52,4 +51,4 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \
|
||||||
$(LOCAL_PATH)/../../lua
|
$(LOCAL_PATH)/../../lua
|
||||||
|
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
|
@ -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
|
|
|
@ -2,9 +2,35 @@
|
||||||
NDK_ROOT=__ndkroot__
|
NDK_ROOT=__ndkroot__
|
||||||
COCOS2DX_ROOT=__cocos2dxroot__
|
COCOS2DX_ROOT=__cocos2dxroot__
|
||||||
GAME_ROOT=$COCOS2DX_ROOT/__projectname__
|
GAME_ROOT=$COCOS2DX_ROOT/__projectname__
|
||||||
GAME_ANDROID_ROOT=$GAME_ROOT/android
|
GAME_ANDROID_ROOT=$GAME_ROOT/proj.android
|
||||||
RESOURCE_ROOT=$GAME_ROOT/Resources
|
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
|
# make sure assets is exist
|
||||||
if [ -d $GAME_ANDROID_ROOT/assets ]; then
|
if [ -d $GAME_ANDROID_ROOT/assets ]; then
|
||||||
rm -rf $GAME_ANDROID_ROOT/assets
|
rm -rf $GAME_ANDROID_ROOT/assets
|
||||||
|
@ -15,15 +41,24 @@ mkdir $GAME_ANDROID_ROOT/assets
|
||||||
# copy resources
|
# copy resources
|
||||||
for file in $RESOURCE_ROOT/*
|
for file in $RESOURCE_ROOT/*
|
||||||
do
|
do
|
||||||
if [ -d $file ]; then
|
if [ -d "$file" ]; then
|
||||||
cp -rf $file $GAME_ANDROID_ROOT/assets
|
cp -rf "$file" $GAME_ANDROID_ROOT/assets
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $file ]; then
|
if [ -f "$file" ]; then
|
||||||
cp $file $GAME_ANDROID_ROOT/assets
|
cp "$file" $GAME_ANDROID_ROOT/assets
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# build
|
if [[ $buildexternalsfromsource ]]; then
|
||||||
$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT $*
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
|
@ -19,18 +19,18 @@ convert_package_path_to_dir(){
|
||||||
|
|
||||||
# make director andorid and copy all files and directories into it
|
# make director andorid and copy all files and directories into it
|
||||||
move_files_into_android(){
|
move_files_into_android(){
|
||||||
mkdir $APP_DIR/android
|
mkdir $APP_DIR/proj.android
|
||||||
|
|
||||||
for file in $APP_DIR/*
|
for file in $APP_DIR/*
|
||||||
do
|
do
|
||||||
if [ -d $file ]; then
|
if [ -d $file ]; then
|
||||||
if [ $file != $APP_DIR/android ]; then
|
if [ $file != $APP_DIR/proj.android ]; then
|
||||||
mv -f $file $APP_DIR/android
|
mv -f $file $APP_DIR/proj.android
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $file ]; then
|
if [ -f $file ]; then
|
||||||
mv $file $APP_DIR/android
|
mv $file $APP_DIR/proj.android
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -57,27 +57,24 @@ copy_resouces(){
|
||||||
|
|
||||||
# from HelloWorld copy src and jni to APP_DIR
|
# from HelloWorld copy src and jni to APP_DIR
|
||||||
copy_src_and_jni(){
|
copy_src_and_jni(){
|
||||||
cp -rf $HELLOWORLD_ROOT/android/jni $APP_DIR/android
|
cp -rf $HELLOWORLD_ROOT/proj.android/jni $APP_DIR/proj.android
|
||||||
cp -rf $HELLOWORLD_ROOT/android/src $APP_DIR/android
|
cp -rf $HELLOWORLD_ROOT/proj.android/src $APP_DIR/proj.android
|
||||||
|
|
||||||
# repalce Android.mk and Application.mk
|
# repalce Android.mk
|
||||||
sh $COCOS2DX_ROOT/template/android/classesmk.sh $APP_DIR/Classes/Android.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA
|
sh $COCOS2DX_ROOT/template/android/gamemk.sh $APP_DIR/proj.android/jni/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
|
# copy build_native.sh and replace something
|
||||||
copy_build_native(){
|
copy_build_native(){
|
||||||
# here should use # instead of /, why??
|
# 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
|
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/android/build_native.sh
|
chmod u+x $APP_DIR/proj.android/build_native.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
# replace AndroidManifext.xml and change the activity name
|
# replace AndroidManifext.xml and change the activity name
|
||||||
# use sed to replace the specified line
|
# use sed to replace the specified line
|
||||||
modify_androidmanifest(){
|
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
|
# modify ApplicationDemo.java
|
||||||
|
@ -86,40 +83,24 @@ modify_applicationdemo(){
|
||||||
|
|
||||||
# rename APP_DIR/android/src/org/cocos2dx/application/ApplicationDemo.java to
|
# 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
|
# 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
|
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/android/src/org/cocos2dx/application
|
rm -fr $APP_DIR/proj.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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modify_layout(){
|
modify_layout(){
|
||||||
cp $HELLOWORLD_ROOT/android/res/layout/helloworld_demo.xml $APP_DIR/android/res/layout
|
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/android/res/layout/helloworld_demo.xml > $APP_DIR/android/res/layout/game_demo.xml
|
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/android/res/layout/main.xml
|
rm -f $APP_DIR/proj.android/res/layout/main.xml
|
||||||
rm -f $APP_DIR/android/res/layout/helloworld_demo.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.
|
# 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
|
# These work are done in ADT
|
||||||
copy_icon(){
|
copy_icon(){
|
||||||
if [ ! -d $APP_DIR/android/res/drawable-hdpi ]; then
|
if [ ! -d $APP_DIR/proj.android/res/drawable-hdpi ]; then
|
||||||
cp -r $HELLOWORLD_ROOT/android/res/drawable-hdpi $APP_DIR/android/res
|
cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-hdpi $APP_DIR/proj.android/res
|
||||||
cp -r $HELLOWORLD_ROOT/android/res/drawable-ldpi $APP_DIR/android/res
|
cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-ldpi $APP_DIR/proj.android/res
|
||||||
cp -r $HELLOWORLD_ROOT/android/res/drawable-mdpi $APP_DIR/android/res
|
cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-mdpi $APP_DIR/proj.android/res
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,29 @@ NEED_BOX2D=$2
|
||||||
NEED_CHIPMUNK=$3
|
NEED_CHIPMUNK=$3
|
||||||
NEED_LUA=$4
|
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
|
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
|
fi
|
||||||
|
|
||||||
if [ $NEED_CHIPMUNK = "true" ]; then
|
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
|
fi
|
||||||
|
|
||||||
if [ $NEED_LUA = "true" ]; then
|
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
|
fi
|
||||||
|
|
||||||
cat > $FILE << EOF
|
cat > $FILE << EOF
|
||||||
|
@ -28,21 +39,13 @@ LOCAL_MODULE := game_shared
|
||||||
|
|
||||||
LOCAL_MODULE_FILENAME := libgame
|
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
|
||||||
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)
|
include \$(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
\$(call import-module,cocos2dx/platform/third_party/android/modules/libcurl)
|
$MODULES_TO_CALL
|
||||||
\$(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
|
EOF
|
||||||
|
|
|
@ -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
|
|
|
@ -30,12 +30,6 @@ class SimpleAudioEngine
|
||||||
*/
|
*/
|
||||||
static SimpleAudioEngine* sharedEngine();
|
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
|
@brief Preload background music
|
||||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||||
|
|
Loading…
Reference in New Issue