2019-11-23 20:27:39 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# exit this script if any commmand fails
|
|
|
|
set -e
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2021-05-18 16:40:30 +08:00
|
|
|
ADXE_ROOT="$DIR"/../..
|
2019-11-23 20:27:39 +08:00
|
|
|
HOST_NAME=""
|
|
|
|
CURL="curl --retry 999 --retry-max-time 0"
|
|
|
|
|
2021-05-15 00:44:30 +08:00
|
|
|
function install_android_sdk()
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2020-10-07 22:45:05 +08:00
|
|
|
echo "Installing android ndk ..."
|
|
|
|
# sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
|
|
|
# sudo python get-pip.py
|
|
|
|
# sudo python -m pip install retry
|
2021-04-22 22:01:47 +08:00
|
|
|
python -m pip install --upgrade pip
|
2020-10-07 22:45:05 +08:00
|
|
|
which python
|
|
|
|
which pip
|
2021-04-22 22:01:47 +08:00
|
|
|
python -V
|
|
|
|
pip -V
|
2020-10-07 22:45:05 +08:00
|
|
|
pip install retry
|
2021-04-22 22:01:47 +08:00
|
|
|
mkdir -p ~/.android/ && touch ~/.android/repositories.cfg # Ensure cmdline-tools works well
|
2021-05-15 11:54:17 +08:00
|
|
|
# cmdlinetools: commandlinetools-mac-7302050_latest.zip commandlinetools-win-7302050_latest.zip commandlinetools-linux-7302050_latest.zip
|
|
|
|
# platforms:android-30 build-tools:30.0.3
|
|
|
|
# full cmd: echo yes|cmdline-tools/bin/sdkmanager --verbose --sdk_root=sdk platform-tools "cmdline-tools;latest" "platforms;android-28" "build-tools;29.0.2" "ndk;19.2.5345600"
|
2020-09-25 11:07:56 +08:00
|
|
|
if [ "$BUILD_TARGET" == "android" ]\
|
|
|
|
|| [ "$BUILD_TARGET" == "android_lua" ] ; then
|
2021-05-18 16:40:30 +08:00
|
|
|
python $ADXE_ROOT/tools/appveyor-scripts/setup_android.py
|
2019-11-23 20:27:39 +08:00
|
|
|
else
|
2021-05-18 16:40:30 +08:00
|
|
|
python $ADXE_ROOT/tools/appveyor-scripts/setup_android.py --ndk_only
|
2019-11-23 20:27:39 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_linux_environment()
|
|
|
|
{
|
|
|
|
echo "Installing linux dependence packages ..."
|
2021-05-18 16:40:30 +08:00
|
|
|
echo -e "y" | bash $ADXE_ROOT/install-deps-linux.sh
|
2019-11-23 20:27:39 +08:00
|
|
|
echo "Installing linux dependence packages finished!"
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_python_module_for_osx()
|
|
|
|
{
|
|
|
|
pip install PyYAML
|
|
|
|
sudo pip install Cheetah
|
|
|
|
}
|
|
|
|
|
|
|
|
# set up environment according os and target
|
|
|
|
function install_environement_for_pull_request()
|
|
|
|
{
|
|
|
|
echo "Building pull request ..."
|
|
|
|
|
|
|
|
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install ninja-build
|
|
|
|
ninja --version
|
2020-11-12 17:48:31 +08:00
|
|
|
|
|
|
|
sudo apt-get install nasm
|
2020-11-12 18:01:27 +08:00
|
|
|
nasm -v
|
2020-10-07 22:45:05 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if [ "$BUILD_TARGET" == "linux" ]; then
|
|
|
|
install_linux_environment
|
|
|
|
fi
|
2021-05-15 00:44:30 +08:00
|
|
|
|
|
|
|
if [ "$BUILD_TARGET" == "android" ]; then
|
|
|
|
install_android_sdk
|
|
|
|
fi
|
2019-11-23 20:27:39 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
2020-11-12 17:48:31 +08:00
|
|
|
brew install nasm
|
2020-11-12 18:01:27 +08:00
|
|
|
nasm -v
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
install_python_module_for_osx
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# should generate binding codes & cocos_files.json after merging
|
2021-05-15 00:44:30 +08:00
|
|
|
# function install_environement_for_after_merge()
|
|
|
|
# {
|
|
|
|
# if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
|
|
|
# install_python_module_for_osx
|
|
|
|
# fi
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-05-15 00:44:30 +08:00
|
|
|
# echo "Building merge commit ..."
|
|
|
|
# }
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2020-10-07 22:45:05 +08:00
|
|
|
# install newer python for android for ssl connection
|
|
|
|
if [ "$BUILD_TARGET" == "android" ]; then
|
2020-10-24 18:41:20 +08:00
|
|
|
if [ $GITHUB_CI ]; then
|
|
|
|
echo "Installing pyenv for github ci..."
|
|
|
|
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
|
|
|
|
export PATH="/home/runner/.pyenv/bin:$PATH"
|
|
|
|
else
|
|
|
|
# upgrade pyenv
|
|
|
|
cd $(pyenv root) && git checkout master && git pull && cd -
|
|
|
|
fi
|
2020-10-07 22:45:05 +08:00
|
|
|
pyenv install --list
|
|
|
|
pyenv install $PYENV_VERSION
|
|
|
|
pyenv versions
|
|
|
|
# pip install pyOpenSSL ndg-httpsclient pyasn1
|
|
|
|
# set by PYENV_VERSION environment variable implicit
|
|
|
|
# pyenv global $PYENV_VERSION
|
|
|
|
fi
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
python -V
|
2020-10-07 22:45:05 +08:00
|
|
|
cmake --version
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
if [ "$BUILD_TARGET" == "android_cocos_new_test" ]; then
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install ninja-build
|
|
|
|
ninja --version
|
2020-10-07 22:45:05 +08:00
|
|
|
sudo pip install retry
|
2021-05-18 16:40:30 +08:00
|
|
|
python $ADXE_ROOT/tools/appveyor-scripts/setup_android.py
|
2019-11-23 20:27:39 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BUILD_TARGET" == "linux_cocos_new_test" ]; then
|
|
|
|
install_linux_environment
|
|
|
|
# linux new lua project, so need to install
|
2020-10-07 22:45:05 +08:00
|
|
|
sudo pip install retry
|
2021-05-18 16:40:30 +08:00
|
|
|
python $ADXE_ROOT/tools/appveyor-scripts/setup_android.py --ndk_only
|
2019-11-23 20:27:39 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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
|
2021-05-15 00:44:30 +08:00
|
|
|
# if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
|
|
|
# # only one job need to send PR, linux virtual machine has better performance
|
|
|
|
# if [ $TRAVIS_OS_NAME == "linux" ] && [ x$GEN_BINDING_AND_COCOSFILE == x"true" ]; then
|
|
|
|
# install_environement_for_after_merge
|
|
|
|
# fi
|
|
|
|
# fi
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
echo "before-install.sh execution finished!"
|