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"/../..
|
2013-05-21 16:13:47 +08:00
|
|
|
HOST_NAME=""
|
2013-06-21 21:27:45 +08:00
|
|
|
|
2016-09-01 16:25:47 +08:00
|
|
|
function install_android_ndk()
|
2013-05-13 15:18:18 +08:00
|
|
|
{
|
2016-09-01 16:25:47 +08:00
|
|
|
mkdir -p $HOME/bin
|
|
|
|
cd $HOME/bin
|
|
|
|
|
2013-05-13 15:18:18 +08:00
|
|
|
# Download android ndk
|
2016-09-01 16:25:47 +08:00
|
|
|
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
2013-05-21 16:13:47 +08:00
|
|
|
HOST_NAME="darwin"
|
2013-05-21 17:29:23 +08:00
|
|
|
else
|
|
|
|
HOST_NAME="linux"
|
2013-05-21 16:13:47 +08:00
|
|
|
fi
|
2016-09-01 16:25:47 +08:00
|
|
|
|
|
|
|
FILE_NAME=android-ndk-r10d-${HOST_NAME}-x86_64.bin
|
|
|
|
|
2017-12-01 17:29:34 +08:00
|
|
|
# the NDK is used to generate binding codes, should use r16 when fix binding codes with r16
|
2016-09-01 16:25:47 +08:00
|
|
|
echo "Download ${FILE_NAME} ..."
|
|
|
|
curl -O http://dl.google.com/android/ndk/${FILE_NAME}
|
|
|
|
sudo chmod +x ./$FILE_NAME
|
|
|
|
echo "Decompress ${FILE_NAME} ..."
|
|
|
|
./$FILE_NAME > /dev/null
|
2013-05-13 15:18:18 +08:00
|
|
|
# Rename ndk
|
2016-09-01 16:25:47 +08:00
|
|
|
mv android-ndk-r10d android-ndk
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_linux_environment()
|
|
|
|
{
|
2017-01-19 13:55:14 +08:00
|
|
|
mkdir -p $HOME/bin
|
|
|
|
pushd $HOME/bin
|
|
|
|
|
|
|
|
echo "GCC version: `gcc --version`"
|
|
|
|
# install new version cmake
|
|
|
|
CMAKE_VERSION="3.7.2"
|
|
|
|
CMAKE_DOWNLOAD_URL="https://cmake.org/files/v3.7/cmake-${CMAKE_VERSION}.tar.gz"
|
|
|
|
echo "Download ${CMAKE_DOWNLOAD_URL}"
|
|
|
|
curl -O ${CMAKE_DOWNLOAD_URL}
|
|
|
|
tar -zxf "cmake-${CMAKE_VERSION}.tar.gz"
|
|
|
|
cd "cmake-${CMAKE_VERSION}"
|
|
|
|
./configure > /dev/null
|
|
|
|
make -j2 > /dev/null
|
|
|
|
sudo make install > /dev/null
|
|
|
|
echo "CMake Version: `cmake --version`"
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
# install new version binutils
|
|
|
|
BINUTILS_VERSION="2.27"
|
|
|
|
BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.gz"
|
|
|
|
echo "Download ${BINUTILS_URL}"
|
|
|
|
curl -O ${BINUTILS_URL}
|
|
|
|
tar -zxf "binutils-${BINUTILS_VERSION}.tar.gz"
|
|
|
|
cd "binutils-${BINUTILS_VERSION}"
|
|
|
|
./configure > /dev/null
|
|
|
|
make -j2 > /dev/null
|
|
|
|
sudo make install > /dev/null
|
|
|
|
echo "ld Version: `ld --version`"
|
|
|
|
echo "which ld: `which ld`"
|
|
|
|
sudo rm /usr/bin/ld
|
|
|
|
popd
|
2016-09-01 16:25:47 +08:00
|
|
|
bash $COCOS2DX_ROOT/build/install-deps-linux.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
function download_deps()
|
|
|
|
{
|
|
|
|
# install dpes
|
|
|
|
pushd $COCOS2DX_ROOT
|
|
|
|
python download-deps.py -r=yes
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_android_environment()
|
|
|
|
{
|
|
|
|
sudo apt-get install ant -y
|
|
|
|
|
|
|
|
# todo: cocos should add parameter to avoid promt
|
|
|
|
sudo mkdir $HOME/.cocos
|
|
|
|
sudo touch $HOME/.cocos/local_cfg.json
|
|
|
|
echo '{"agreement_shown": true}' | sudo tee $HOME/.cocos/local_cfg.json
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_python_module_for_osx()
|
|
|
|
{
|
|
|
|
sudo easy_install pip
|
2017-12-01 17:29:34 +08:00
|
|
|
sudo -H pip install PyYAML
|
|
|
|
sudo -H pip install Cheetah
|
2013-05-13 15:18:18 +08:00
|
|
|
}
|
|
|
|
|
2016-09-01 16:25:47 +08:00
|
|
|
# set up environment according os and target
|
|
|
|
function install_environement_for_pull_request()
|
2013-06-25 01:41:48 +08:00
|
|
|
{
|
2016-09-01 16:25:47 +08:00
|
|
|
# use NDK's clang to generate binding codes
|
|
|
|
install_android_ndk
|
|
|
|
download_deps
|
|
|
|
|
|
|
|
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
|
|
|
if [ "$BUILD_TARGET" == "linux" ]; then
|
|
|
|
install_linux_environment
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BUILD_TARGET" == "android" ]; then
|
|
|
|
install_android_environment
|
|
|
|
fi
|
2013-06-25 01:41:48 +08:00
|
|
|
fi
|
2016-09-01 16:25:47 +08:00
|
|
|
|
|
|
|
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
|
|
|
install_python_module_for_osx
|
2013-06-25 01:41:48 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-09-01 16:25:47 +08:00
|
|
|
# should generate binding codes & cocos_files.json after merging
|
|
|
|
function install_environement_for_after_merge()
|
|
|
|
{
|
2013-05-13 15:18:18 +08:00
|
|
|
install_android_ndk
|
2016-09-01 16:25:47 +08:00
|
|
|
download_deps
|
2014-05-04 19:09:51 +08:00
|
|
|
|
2016-09-01 16:25:47 +08:00
|
|
|
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
|
|
|
install_python_module_for_osx
|
2014-05-12 21:59:32 +08:00
|
|
|
fi
|
2016-09-01 16:25:47 +08:00
|
|
|
}
|
2014-05-12 21:59:32 +08:00
|
|
|
|
2016-09-01 16:25:47 +08:00
|
|
|
# build pull request
|
|
|
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
|
|
|
install_environement_for_pull_request
|
|
|
|
fi
|
|
|
|
|
|
|
|
# run after merging
|
|
|
|
# - make cocos robot to send PR to cocos2d-x for new binding codes
|
|
|
|
# - generate cocos_files.json for template
|
|
|
|
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
2016-09-01 18:54:49 +08:00
|
|
|
# only one job need to send PR, linux virtual machine has better performance
|
|
|
|
if [ $TRAVIS_OS_NAME == "linux" ] && [ $GEN_BINDING_AND_COCOSFILE == "true" ]; then
|
|
|
|
install_environement_for_after_merge
|
|
|
|
fi
|
2013-05-21 16:13:47 +08:00
|
|
|
fi
|