From 58c3faf209a6fbdf10960ddcf0d4876dc494031a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 24 Jun 2013 10:41:48 -0700 Subject: [PATCH] Cleanup travis build scripts. before-install.sh and run-script.sh now both given an error if no PLATFORM was not specified correctly. Environment variables are now set as part of run-script.sh. This makes the travis output simpler and makes it possible to run run-script.sh outside of travis. javascript binding generation will not exit early if GH_USER etc are not set. This allows the travis scripts to be run in cloned repos which were otherwise erroring out trying to go the JS bindings commit. When generating javascript bindgings, don't username and email with '--global'. It should be sufficient to set this only for the binding repo. --- .travis.yml | 24 +++----- tools/travis-scripts/before-install.sh | 61 ++++++++++----------- tools/travis-scripts/generate-jsbindings.sh | 7 +-- tools/travis-scripts/run-script.sh | 59 ++++++++++++-------- 4 files changed, 77 insertions(+), 74 deletions(-) diff --git a/.travis.yml b/.travis.yml index 994cff4e0134..de74e3154376 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ ---- language: cpp -env: - matrix: +env: + matrix: - GEN_JSB=YES - PLATFORM=linux DEBUG=1 # Since switching to C++11 only the ARM version of the nactive client @@ -10,7 +9,7 @@ env: # - PLATFORM=nacl DEBUG=1 NACL_ARCH=arm - PLATFORM=android - PLATFORM=emscripten DEBUG=1 - global: + global: - secure: |- cHXOjAda+t2tmBVuVAiQfvhDN+unToO6hX1rc3dJeGDOk4rlQnylJacjA7o/ enkWeHagbW2Ja4h7BxQz4h7dada8zEbIbEMK4VEHx6AWwQM+GIEqkJPv5g8k @@ -23,16 +22,7 @@ env: Wsngwo3jlZtvuPfr3RNhqrz/liNIhKYnlw4KYJO90gMQ9ZQKRTlMv2BMiPw/ 9lV+vgJQDRcFe7dKwtC86vk10EU7Ym2bhVmhMxi/AlmJXgavjmPVdizRT7rh X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI= -script: -- 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 -- export NDK_ROOT=$HOME/bin/android-ndk -- export PYTHON=/usr/bin/python -- export LLVM=$HOME/bin/clang+llvm-3.2/bin -- export LLVM_ROOT=$LLVM -- ./tools/travis-scripts/run-script.sh - -before_install: -- ./tools/travis-scripts/before-install.sh - +script: +- tools/travis-scripts/run-script.sh +before_install: +- tools/travis-scripts/before-install.sh diff --git a/tools/travis-scripts/before-install.sh b/tools/travis-scripts/before-install.sh index 85ff56fcf652..592a0b2ead2b 100755 --- a/tools/travis-scripts/before-install.sh +++ b/tools/travis-scripts/before-install.sh @@ -11,8 +11,7 @@ LLVM_PACKAGE="" LLVM_PACKAGE_SUFFIX="" mkdir -p $HOME/bin -pushd $HOME/bin - +cd $HOME/bin install_android_ndk() { @@ -40,7 +39,7 @@ install_llvm() LLVM_PACKAGE="clang+llvm-3.3-Ubuntu-13.04-x86_64-linux-gnu" LLVM_PACKAGE_SUFFIX=".tar.bz2" fi - + # Download llvm echo "Download ${LLVM_PACKAGE} ..." curl -O http://llvm.org/releases/${LLVM_VERSION}/${LLVM_PACKAGE}${LLVM_PACKAGE_SUFFIX} @@ -50,7 +49,7 @@ install_llvm() else tar xjf ${LLVM_PACKAGE}${LLVM_PACKAGE_SUFFIX} fi - + # Rename llvm mv ${LLVM_PACKAGE} clang+llvm-${LLVM_VERSION} } @@ -71,49 +70,49 @@ install_llvm_3_2() mv clang+llvm-3.2-x86_64-${HOST_NAME} clang+llvm-3.2 } +install_nacl_sdk() +{ + # 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 + 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 + fi + nacl_sdk/naclsdk update --force pepper_canary +} + if [ "$GEN_JSB"x = "YES"x ]; then if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then exit 0 fi install_android_ndk install_llvm -fi - -if [ "$PLATFORM"x = "linux"x ]; then +elif [ "$PLATFORM"x = "linux"x ]; then bash $COCOS2DX_ROOT/install-deps-linux.sh -fi - -if [ "$PLATFORM"x = "nacl"x ]; then - # NaCl compilers are built for 32-bit linux so we need to install - # the runtime support for this. - sudo apt-get update - sudo apt-get install libc6:i386 libstdc++6:i386 - 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 - nacl_sdk/naclsdk update --force pepper_canary -fi - -if [ "$PLATFORM"x = "android"x ]; then +elif [ "$PLATFORM"x = "nacl"x ]; then + install_nacl_sdk +elif [ "$PLATFORM"x = "android"x ]; then install_android_ndk install_llvm -fi - -if [ "$PLATFORM"x = "emscripten"x ]; then +elif [ "$PLATFORM"x = "emscripten"x ]; then sudo rm -rf /dev/shm && sudo ln -s /run/shm /dev/shm install_llvm_3_2 -fi - -if [ "$PLATFORM"x = "ios"x ]; then +elif [ "$PLATFORM"x = "ios"x ]; then install_android_ndk install_llvm - + pushd $COCOS2DX_ROOT git submodule add https://github.com/facebook/xctool.git ./xctool git submodule init git submodule update popd +else + echo "Unknown \$PLATFORM: '$PLATFORM'" + exit 1 fi - -popd diff --git a/tools/travis-scripts/generate-jsbindings.sh b/tools/travis-scripts/generate-jsbindings.sh index e73a586d4bbe..c04ac38b49a3 100755 --- a/tools/travis-scripts/generate-jsbindings.sh +++ b/tools/travis-scripts/generate-jsbindings.sh @@ -49,14 +49,13 @@ if [ "$GEN_JSB"x != "YES"x ]; then exit 0 fi -#Set git user -git config --global user.email ${GH_EMAIL} -git config --global user.name ${GH_USER} - # Update submodule of auto-gen JSBinding repo. pushd "$GENERATED_WORKTREE" git checkout -B master +#Set git user +git config user.email ${GH_EMAIL} +git config user.name ${GH_USER} #Set remotes git remote add upstream https://${GH_USER}:${GH_PASSWORD}@github.com/folecr/cocos2dx-autogen-bindings.git 2> /dev/null > /dev/null diff --git a/tools/travis-scripts/run-script.sh b/tools/travis-scripts/run-script.sh index 53b4dbea1c77..558f2b5e9b4a 100755 --- a/tools/travis-scripts/run-script.sh +++ b/tools/travis-scripts/run-script.sh @@ -5,14 +5,6 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" COCOS2DX_ROOT="$DIR"/../.. -if [ "$GEN_JSB"x = "YES"x ]; then - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - exit 0 - fi - cd $COCOS2DX_ROOT/tools/travis-scripts - ./generate-jsbindings.sh -fi - build_android() { cd $COCOS2DX_ROOT/samples/$1/$2/proj.android @@ -20,10 +12,35 @@ build_android() ./build_native.sh } -if [ "$PLATFORM"x = "android"x ]; then +if [ "$GEN_JSB"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 0 + fi + if [ -z "${GH_USER}" ]; then + echo "GH_USER not set" + exit 0 + fi + if [ -z "${GH_PASSWORD}" ]; then + echo "GH_USER not set" + exit 0 + fi + export NDK_ROOT=$HOME/bin/android-ndk cd $COCOS2DX_ROOT/tools/travis-scripts ./generate-jsbindings.sh - +elif [ "$PLATFORM"x = "android"x ]; then + export NDK_ROOT=$HOME/bin/android-ndk + cd $COCOS2DX_ROOT/tools/travis-scripts + ./generate-jsbindings.sh + cd $COCOS2DX_ROOT mkdir android_build_objs build_android Cpp HelloCpp @@ -32,19 +49,16 @@ if [ "$PLATFORM"x = "android"x ]; then build_android Javascript TestJavascript build_android Lua HelloLua build_android Lua TestLua -fi - -if [ "$PLATFORM"x = "nacl"x ]; then +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 cd $COCOS2DX_ROOT make -j4 -fi - -if [ "$PLATFORM"x = "linux"x ]; then +elif [ "$PLATFORM"x = "linux"x ]; then cd $COCOS2DX_ROOT make -j4 -fi - -if [ "$PLATFORM"x = "emscripten"x ]; then +elif [ "$PLATFORM"x = "emscripten"x ]; then cd $COCOS2DX_ROOT export PYTHON=/usr/bin/python export LLVM=$HOME/bin/clang+llvm-3.2/bin @@ -52,9 +66,7 @@ if [ "$PLATFORM"x = "emscripten"x ]; then sudo mkdir -p /Library/Fonts sudo cp samples/Cpp/TestCpp/Resources/fonts/arial.ttf /Library/Fonts/Arial.ttf EMCC_DEBUG=1 make -f Makefile.emscripten -j 8 -fi - -if [ "$PLATFORM"x = "ios"x ]; then +elif [ "$PLATFORM"x = "ios"x ]; then cd $COCOS2DX_ROOT/tools/travis-scripts ./generate-jsbindings.sh @@ -70,4 +82,7 @@ if [ "$PLATFORM"x = "ios"x ]; then #xctool/xctool.sh -project samples/Javascript/WatermelonWithMe/proj.ios/WatermelonWithMe.xcodeproj -scheme WatermelonWithMe test xctool/xctool.sh -project samples/Lua/HelloLua/proj.ios/HelloLua.xcodeproj -scheme HelloLua test xctool/xctool.sh -project samples/Lua/TestLua/proj.ios/TestLua.xcodeproj -scheme TestLua test +else + echo "Unknown \$PLATFORM: '$PLATFORM'" + exit 1 fi