2013-05-13 15:18:18 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# exit this script if any commmand fails
|
|
|
|
set -e
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
COCOS2DX_ROOT="$DIR"/../..
|
|
|
|
|
2014-02-12 22:01:46 +08:00
|
|
|
if [ -z "$NDK_ROOT" ]; then
|
|
|
|
export NDK_ROOT=$HOME/bin/android-ndk
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$PYTHON_BIN" ]; then
|
|
|
|
export PYTHON_BIN=/usr/bin/python
|
|
|
|
fi
|
2014-02-11 14:12:13 +08:00
|
|
|
|
2014-03-10 18:13:39 +08:00
|
|
|
if [ "$GEN_BINDING"x = "YES"x ]; then
|
|
|
|
# Re-generation of the javascript bindings can perform push of the new
|
|
|
|
# version back to github. We don't do this for pull requests, or if
|
|
|
|
# GH_USER/GH_EMAIL/GH_PASSWORD environment variables are not set correctly
|
|
|
|
# by the encoded variables in the .travis.yml file. (e.g. if cloned repo's
|
|
|
|
# want to use travis).
|
|
|
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if [ -z "${GH_EMAIL}" ]; then
|
|
|
|
echo "GH_EMAIL not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "${GH_USER}" ]; then
|
|
|
|
echo "GH_USER not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "${GH_PASSWORD}" ]; then
|
|
|
|
echo "GH_USER not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-02-13 11:33:11 +08:00
|
|
|
|
2014-03-10 18:13:39 +08:00
|
|
|
cd $COCOS2DX_ROOT/tools/travis-scripts
|
2015-07-03 18:27:42 +08:00
|
|
|
./generate-bindings.sh $TRAVIS_BRANCH
|
2014-03-10 18:13:39 +08:00
|
|
|
elif [ "$GEN_COCOS_FILES"x = "YES"x ]; then
|
2014-02-13 11:33:11 +08:00
|
|
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if [ -z "${GH_EMAIL}" ]; then
|
|
|
|
echo "GH_EMAIL not set"
|
2014-02-27 16:23:38 +08:00
|
|
|
exit 1
|
2014-02-13 11:33:11 +08:00
|
|
|
fi
|
|
|
|
if [ -z "${GH_USER}" ]; then
|
|
|
|
echo "GH_USER not set"
|
2014-02-27 16:23:38 +08:00
|
|
|
exit 1
|
2014-02-13 11:33:11 +08:00
|
|
|
fi
|
|
|
|
if [ -z "${GH_PASSWORD}" ]; then
|
|
|
|
echo "GH_USER not set"
|
2014-02-27 16:23:38 +08:00
|
|
|
exit 1
|
2014-02-13 11:33:11 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd $COCOS2DX_ROOT/tools/travis-scripts
|
2015-07-03 18:27:42 +08:00
|
|
|
./generate-cocosfiles.sh $TRAVIS_BRANCH
|
2013-06-25 01:41:48 +08:00
|
|
|
elif [ "$PLATFORM"x = "android"x ]; then
|
|
|
|
export NDK_ROOT=$HOME/bin/android-ndk
|
2013-07-24 17:26:45 +08:00
|
|
|
|
2013-08-27 21:52:06 +08:00
|
|
|
# Generate binding glue codes
|
|
|
|
echo "Generating bindings glue codes ..."
|
2013-06-25 01:41:48 +08:00
|
|
|
cd $COCOS2DX_ROOT/tools/travis-scripts
|
2014-03-10 18:13:39 +08:00
|
|
|
./generate-bindings.sh
|
2014-03-06 14:00:48 +08:00
|
|
|
./generate-cocosfiles.sh
|
2013-06-25 01:41:48 +08:00
|
|
|
|
2013-06-11 11:31:24 +08:00
|
|
|
cd $COCOS2DX_ROOT
|
2013-07-24 17:26:45 +08:00
|
|
|
|
|
|
|
# Create a directory for temporary objects
|
2014-03-11 17:42:57 +08:00
|
|
|
mkdir android_build_objs
|
2013-07-24 17:26:45 +08:00
|
|
|
|
2014-03-11 17:42:57 +08:00
|
|
|
PROJECTS=("cpp-empty-test" "cpp-tests" "lua-empty-test/project" "lua-tests/project")
|
|
|
|
for i in ${PROJECTS[*]}; do
|
|
|
|
ln -s $COCOS2DX_ROOT/android_build_objs $COCOS2DX_ROOT/tests/$i/proj.android/obj
|
|
|
|
done
|
2013-07-24 17:26:45 +08:00
|
|
|
|
2013-11-01 11:46:02 +08:00
|
|
|
# Build all samples
|
|
|
|
echo "Building all samples ..."
|
|
|
|
cd $COCOS2DX_ROOT/build
|
2014-03-11 17:42:57 +08:00
|
|
|
./android-build.py -n "NDK_BUG=0 -j10" all
|
2013-07-24 17:26:45 +08:00
|
|
|
|
2013-06-25 01:41:48 +08:00
|
|
|
elif [ "$PLATFORM"x = "nacl"x ]; then
|
|
|
|
export NACL_SDK_ROOT=$HOME/bin/nacl_sdk/pepper_canary
|
|
|
|
export PATH=$PATH:$NACL_SDK_ROOT/toolchain/linux_x86_newlib/bin
|
|
|
|
export PATH=$PATH:$NACL_SDK_ROOT/toolchain/linux_arm_newlib/bin
|
2013-11-01 11:46:02 +08:00
|
|
|
cd $COCOS2DX_ROOT/build
|
2013-05-13 15:18:18 +08:00
|
|
|
make -j4
|
2013-06-25 01:41:48 +08:00
|
|
|
elif [ "$PLATFORM"x = "linux"x ]; then
|
2013-08-27 21:52:06 +08:00
|
|
|
# Generate binding glue codes
|
|
|
|
echo "Generating bindings glue codes ..."
|
|
|
|
cd $COCOS2DX_ROOT/tools/travis-scripts
|
2014-03-10 18:13:39 +08:00
|
|
|
./generate-bindings.sh
|
2014-03-06 14:00:48 +08:00
|
|
|
./generate-cocosfiles.sh
|
2013-08-27 21:52:06 +08:00
|
|
|
|
2014-02-12 22:01:46 +08:00
|
|
|
echo "Building cocos2d-x"
|
2013-11-01 11:46:02 +08:00
|
|
|
cd $COCOS2DX_ROOT/build
|
2013-11-04 18:59:39 +08:00
|
|
|
mkdir -p linux-build
|
|
|
|
cd linux-build
|
2013-12-10 18:26:10 +08:00
|
|
|
cmake ../..
|
2013-11-04 18:59:39 +08:00
|
|
|
make -j10
|
2014-02-12 22:02:47 +08:00
|
|
|
|
2013-06-25 01:41:48 +08:00
|
|
|
elif [ "$PLATFORM"x = "emscripten"x ]; then
|
2013-08-27 21:52:06 +08:00
|
|
|
# Generate binding glue codes
|
|
|
|
echo "Generating bindings glue codes ..."
|
|
|
|
cd $COCOS2DX_ROOT/tools/travis-scripts
|
2014-03-10 18:13:39 +08:00
|
|
|
./generate-bindings.sh
|
2014-03-06 14:00:48 +08:00
|
|
|
./generate-cocosfiles.sh
|
2013-08-27 21:52:06 +08:00
|
|
|
|
2013-11-01 11:46:02 +08:00
|
|
|
cd $COCOS2DX_ROOT/build
|
2013-06-10 21:57:26 +08:00
|
|
|
export PYTHON=/usr/bin/python
|
|
|
|
export LLVM=$HOME/bin/clang+llvm-3.2/bin
|
2013-06-19 13:15:29 +08:00
|
|
|
export LLVM_ROOT=$LLVM
|
2013-06-25 23:11:28 +08:00
|
|
|
EMCC_DEBUG=1 make PLATFORM=emscripten -j 8
|
2014-05-12 21:55:11 +08:00
|
|
|
elif [ "$PLATFORM"x = "mac-ios"x ]; then
|
2014-05-12 21:59:32 +08:00
|
|
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2014-05-12 21:55:11 +08:00
|
|
|
if [ "$PUSH_TO_MAC"x != "YES"x ]; then
|
|
|
|
cd $COCOS2DX_ROOT/tools/travis-scripts
|
|
|
|
./generate-bindings.sh
|
|
|
|
./generate-cocosfiles.sh
|
|
|
|
|
|
|
|
cd $COCOS2DX_ROOT
|
|
|
|
xctool -project build/cocos2d_tests.xcodeproj -scheme "$SCHEME" -jobs 8 -arch "$ARCH" -sdk "$SDK" build
|
|
|
|
fi
|
2013-06-25 01:41:48 +08:00
|
|
|
else
|
|
|
|
echo "Unknown \$PLATFORM: '$PLATFORM'"
|
|
|
|
exit 1
|
2013-05-21 16:13:47 +08:00
|
|
|
fi
|