Skip to content

Commit

Permalink
[ci skip]Travis enable pull request (#16494)
Browse files Browse the repository at this point in the history
* refactor travis and build pull request

* delete unneeded file
  • Loading branch information
minggo committed Sep 1, 2016
1 parent 1c40d5e commit db21e5f
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 482 deletions.
94 changes: 73 additions & 21 deletions .travis.yml
@@ -1,19 +1,62 @@
language: cpp
env:
matrix:
- GEN_BINDING=YES
- GEN_COCOS_FILES=YES
# - PLATFORM=mac-ios PUSH_TO_MAC=YES
# - PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++
# Disable clang build on linux temporarily since we're using "-stdlib=libc++ " which wasn't installed on travis machine.
# - PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++
# Since switching to C++11 only the ARM version of the nactive client
# port currently builds. TODO(sbc): Re-enable all architectures.
# Disabled travis-ci build for native client port since it doesn't support std::thread, std::mutex.
# - PLATFORM=nacl DEBUG=1 NACL_ARCH=arm
# - PLATFORM=android
# - PLATFORM=emscripten DEBUG=1
global:
matrix:
include:
# linux
- os: linux
env: BUILD_TARGET=linux
language: cpp
sudo: required
addons:
apt:
sources:
- george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3
packages:
- cmake
- cmake-data
# android
- os: linux
env: BUILD_TARGET=android
language: android
sudo: required
android:
components:
- android-10
# mac lua-tests + js-tests
- os: osx
env: BUILD_TARGET=mac
language: cpp
osx_image: xcode7.3
sudo: required
python:
- "2.7"
cache: pip
# mac cpp-tests
- os: osx
env: BUILD_TARGET=mac BUILD_CPP=true
language: cpp
osx_image: xcode7.3
sudo: required
python:
- "2.7"
cache: pip
# iOS lua-tests + js-tests
- os: osx
env: BUILD_TARGET=ios
language: cpp
osx_image: xcode7.3
sudo: required
python:
- "2.7"
cache: pip
# iOS cpp-tests
- os: osx
env: BUILD_TARGET=ios BUILD_CPP=true
language: cpp
osx_image: xcode7.3
sudo: required
python:
- "2.7"
cache: pip
global:
- secure: |-
cHXOjAda+t2tmBVuVAiQfvhDN+unToO6hX1rc3dJeGDOk4rlQnylJacjA7o/
enkWeHagbW2Ja4h7BxQz4h7dada8zEbIbEMK4VEHx6AWwQM+GIEqkJPv5g8k
Expand All @@ -28,13 +71,22 @@ env:
X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI=
- secure: PGMnEvysYv9Mnjrof05v9MU41ZlVO7A7SQb4oLuYqhBf0stvZUVEF4fmkOcXRPAd4Cg41aAbtE8RyGaqIFaKHtjHFtTdisM9XVXqL+eMfv5L+8nFCk4S5Fi/ohglO+FBJ9X/NLfAfRZmlwJR+UedU5AJwqlQbKraNkyv/FmDMUc=
script:
- export CC=$CC_COMPILER
- export CXX=$CXX_COMPILER
- tools/travis-scripts/run-script.sh
before_install:
- tools/travis-scripts/before-install.sh

# whitelist
cache:
bundler: true

notifications:
email: false

# blocklist
branches:
only:
- v3
except:
- v1
- v2
- v4-develop
- v3-doc
- v3.11_backup
- v35-for-tizen
4 changes: 2 additions & 2 deletions build/install-deps-linux.sh
Expand Up @@ -9,7 +9,7 @@ if [ ! $(command -v apt-get) ]; then
fi

#install g++-4.9
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y > /dev/null
sudo apt-get update

#try to remove glfw2
Expand Down Expand Up @@ -49,7 +49,7 @@ if [ -n "$MISSING" ]; then
TXTCOLOR_DEFAULT="\033[0;m"
TXTCOLOR_GREEN="\033[0;32m"
echo -e $TXTCOLOR_GREEN"Missing packages: $MISSING.\nYou may be asked for your password for package installation."$TXTCOLOR_DEFAULT
sudo apt-get --force-yes --yes install $MISSING
sudo apt-get --force-yes --yes install $MISSING > /dev/null
fi

# install glfw
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/SetCompilerOptions.cmake
Expand Up @@ -53,7 +53,7 @@ macro (SetCompilerOptions)
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder -Wno-invalid-offsetof -fPIC")
if(CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
Expand Down
6 changes: 3 additions & 3 deletions cocos/platform/mac/cocos2d-prefix.pch
Expand Up @@ -14,9 +14,9 @@
#include <assert.h>
#include <sys/time.h>
#include <sys/select.h>
#import <OpenGL/gl.h>
#import <OpenGL/glu.h>
#import <OpenGL/glext.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>

#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
Expand Down
145 changes: 78 additions & 67 deletions tools/travis-scripts/before-install.sh
Expand Up @@ -7,91 +7,102 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COCOS2DX_ROOT="$DIR"/../..
HOST_NAME=""

pushd $COCOS2DX_ROOT
python download-deps.py -r=yes
popd

mkdir -p $HOME/bin
cd $HOME/bin

install_android_ndk()
function install_android_ndk()
{
mkdir -p $HOME/bin
cd $HOME/bin

# Download android ndk
if [ "$PLATFORM"x = "mac-ios"x ]; then
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
HOST_NAME="darwin"
else
HOST_NAME="linux"
fi
echo "Download android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 ..."
curl -O http://dl.google.com/android/ndk/android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2
echo "Decompress android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 ..."
tar xjf android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2

FILE_NAME=android-ndk-r10d-${HOST_NAME}-x86_64.bin

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
# Rename ndk
mv android-ndk-r9d android-ndk
mv android-ndk-r10d android-ndk
}

function install_linux_environment()
{
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
sudo pip install PyYAML
sudo pip install Cheetah
}

install_nacl_sdk()
# set up environment according os and target
function install_environement_for_pull_request()
{
# NaCl compilers are built for 32-bit linux so we need to install
# the runtime support for this.
if [ ! -e "/lib/ld-linux.so.2" ]; then
sudo apt-get update
sudo apt-get install libc6:i386 libstdc++6:i386
# 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
fi
if [ ! -d nacl_sdl ]; then
echo "Download nacl_sdk ..."
wget http://storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip
echo "Decompress nacl_sdk.zip"
unzip nacl_sdk.zip

if [ "$TRAVIS_OS_NAME" == "osx" ]; then
install_python_module_for_osx
fi
nacl_sdk/naclsdk update --force pepper_canary
}

if [ "$GEN_COCOS_FILES"x = "YES"x ]; then
exit 0
elif [ "$GEN_BINDING"x = "YES"x ]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
exit 0
fi
install_android_ndk
elif [ "$PLATFORM"x = "linux"x ]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7 g++-4.7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 90 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
g++ --version
bash $COCOS2DX_ROOT/build/install-deps-linux.sh
install_android_ndk
elif [ "$PLATFORM"x = "nacl"x ]; then
install_nacl_sdk
elif [ "$PLATFORM"x = "android"x ]; then
# should generate binding codes & cocos_files.json after merging
function install_environement_for_after_merge()
{
install_android_ndk
elif [ "$PLATFORM"x = "emscripten"x ]; then
sudo rm -rf /dev/shm && sudo ln -s /run/shm /dev/shm
download_deps

install_android_ndk
elif [ "$PLATFORM"x = "mac-ios"x ]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
exit 0
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
install_python_module_for_osx
fi
}

if [ "$PUSH_TO_MAC"x = "YES"x ]; then
cd $COCOS2DX_ROOT
git config user.email ${GH_EMAIL_MAC}
git config user.name ${GH_USER_MAC}
git checkout -B $TRAVIS_BRANCH
cp tools/travis-scripts/travis_mac.yml ./.travis.yml
git add .travis.yml
cat .travis.yml
git commit --amend -m "`git log -1 --pretty=%B`"
git remote add travis-mac https://$GH_USER_MAC:$GH_PASSWORD_MAC@github.com/cocos-travis-mac/cocos2d-x.git
git push -f travis-mac $TRAVIS_BRANCH 2> /dev/null > /dev/null
else
echo "xctool version: `xctool --version`"
install_android_ndk
fi
else
echo "Unknown \$PLATFORM: '$PLATFORM'"
exit 1
# 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
install_environement_for_after_merge
fi

0 comments on commit db21e5f

Please sign in to comment.