2012-09-25 12:14:41 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-09-15 08:29:38 +08:00
|
|
|
# exit this script if any commmand fails
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# read user.cfg if it exists and is readable
|
|
|
|
|
|
|
|
_CFG_FILE=$(dirname "$0")"/user.cfg"
|
2012-09-25 12:14:41 +08:00
|
|
|
if [ -f "$_CFG_FILE" ]
|
2012-09-15 08:29:38 +08:00
|
|
|
then
|
|
|
|
[ -r "$_CFG_FILE" ] || die "Fatal Error: $_CFG_FILE exists but is unreadable"
|
|
|
|
. "$_CFG_FILE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# paths
|
|
|
|
|
2012-09-25 12:14:41 +08:00
|
|
|
if [ -z "${NDK_ROOT+aaa}" ]; then
|
|
|
|
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
|
|
|
|
NDK_ROOT="$HOME/bin/android-ndk"
|
|
|
|
fi
|
|
|
|
|
2012-09-15 08:29:38 +08:00
|
|
|
if [ -z "${CLANG_ROOT+aaa}" ]; then
|
2013-06-21 21:49:23 +08:00
|
|
|
# ... if CLANG_ROOT is not set, use "$HOME/bin/clang+llvm-3.3"
|
|
|
|
CLANG_ROOT="$HOME/bin/clang+llvm-3.3"
|
2012-09-15 08:29:38 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${PYTHON_BIN+aaa}" ]; then
|
|
|
|
# ... if PYTHON_BIN is not set, use "/usr/bin/python2.7"
|
|
|
|
PYTHON_BIN="/usr/bin/python2.7"
|
|
|
|
fi
|
|
|
|
|
2012-09-19 05:01:29 +08:00
|
|
|
# find current dir
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2012-09-15 08:29:38 +08:00
|
|
|
# paths with defaults hardcoded to relative paths
|
|
|
|
|
2012-09-19 05:01:29 +08:00
|
|
|
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
|
|
|
|
COCOS2DX_ROOT="$DIR/../../"
|
|
|
|
fi
|
|
|
|
|
2012-09-15 08:29:38 +08:00
|
|
|
if [ -z "${CXX_GENERATOR_ROOT+aaa}" ]; then
|
2013-04-09 11:03:39 +08:00
|
|
|
CXX_GENERATOR_ROOT="$COCOS2DX_ROOT/tools/bindings-generator"
|
2012-09-15 08:29:38 +08:00
|
|
|
fi
|
|
|
|
|
2012-09-19 05:01:29 +08:00
|
|
|
if [ -z "${TOJS_ROOT+aaa}" ]; then
|
|
|
|
TO_JS_ROOT="$COCOS2DX_ROOT/tools/tojs"
|
2012-09-15 08:29:38 +08:00
|
|
|
fi
|
|
|
|
|
2012-09-19 05:01:29 +08:00
|
|
|
echo "Paths"
|
2012-09-25 12:14:41 +08:00
|
|
|
echo " NDK_ROOT: $NDK_ROOT"
|
2012-09-19 05:01:29 +08:00
|
|
|
echo " CLANG_ROOT: $CLANG_ROOT"
|
|
|
|
echo " PYTHON_BIN: $PYTHON_BIN"
|
|
|
|
echo " COCOS2DX_ROOT: $COCOS2DX_ROOT"
|
|
|
|
echo " CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT"
|
|
|
|
echo " TO_JS_ROOT: $TO_JS_ROOT"
|
2012-09-15 08:29:38 +08:00
|
|
|
|
2012-09-25 12:14:41 +08:00
|
|
|
# write userconf.ini
|
|
|
|
|
|
|
|
_CONF_INI_FILE="$PWD/userconf.ini"
|
|
|
|
if [ -f "$_CONF_INI_FILE" ]
|
|
|
|
then
|
|
|
|
rm "$_CONF_INI_FILE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
_CONTENTS=""
|
|
|
|
_CONTENTS+="[DEFAULT]"'\n'
|
|
|
|
_CONTENTS+="androidndkdir=$NDK_ROOT"'\n'
|
|
|
|
_CONTENTS+="clangllvmdir=$CLANG_ROOT"'\n'
|
|
|
|
_CONTENTS+="cocosdir=$COCOS2DX_ROOT"'\n'
|
|
|
|
_CONTENTS+="cxxgeneratordir=$CXX_GENERATOR_ROOT"'\n'
|
2013-03-17 14:10:20 +08:00
|
|
|
_CONTENTS+="extra_flags="'\n'
|
|
|
|
|
2012-09-25 12:14:41 +08:00
|
|
|
echo
|
|
|
|
echo "generating userconf.ini..."
|
|
|
|
echo ---
|
|
|
|
echo -e "$_CONTENTS"
|
|
|
|
echo -e "$_CONTENTS" > "$_CONF_INI_FILE"
|
|
|
|
echo ---
|
|
|
|
|
2012-09-19 05:01:29 +08:00
|
|
|
# Generate bindings for cocos2dx
|
|
|
|
echo "Generating bindings for cocos2dx..."
|
2012-09-15 08:29:38 +08:00
|
|
|
set -x
|
2013-10-16 15:43:59 +08:00
|
|
|
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_auto
|
2013-03-11 16:39:28 +08:00
|
|
|
|
|
|
|
echo "Generating bindings for cocos2dx_extension..."
|
2013-10-16 15:43:59 +08:00
|
|
|
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_extension_auto
|
2013-10-21 22:09:21 +08:00
|
|
|
|
|
|
|
echo "Generating bindings for cocos2dx_builder..."
|
|
|
|
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_builder.ini -s cocos2dx_builder -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_builder_auto
|
|
|
|
|
2013-11-18 16:54:52 +08:00
|
|
|
echo "Generating bindings for cocos2dx_gui..."
|
|
|
|
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_gui.ini -s cocos2dx_gui -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_gui_auto
|
|
|
|
|
2013-10-21 22:09:21 +08:00
|
|
|
echo "Generating bindings for cocos2dx_studio..."
|
2013-12-20 15:10:15 +08:00
|
|
|
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto
|
|
|
|
|
|
|
|
echo "Generating bindings for cocos2dx_spine..."
|
|
|
|
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_spine.ini -s cocos2dx_spine -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_spine_auto
|