Skip to content

Commit

Permalink
Cleanup travis build scripts.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbc100 committed Jun 25, 2013
1 parent d9985d0 commit 58c3faf
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 74 deletions.
24 changes: 7 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
61 changes: 30 additions & 31 deletions tools/travis-scripts/before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ LLVM_PACKAGE=""
LLVM_PACKAGE_SUFFIX=""

mkdir -p $HOME/bin
pushd $HOME/bin

cd $HOME/bin

install_android_ndk()
{
Expand Down Expand Up @@ -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}
Expand All @@ -50,7 +49,7 @@ install_llvm()
else
tar xjf ${LLVM_PACKAGE}${LLVM_PACKAGE_SUFFIX}
fi

# Rename llvm
mv ${LLVM_PACKAGE} clang+llvm-${LLVM_VERSION}
}
Expand All @@ -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
7 changes: 3 additions & 4 deletions tools/travis-scripts/generate-jsbindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
59 changes: 37 additions & 22 deletions tools/travis-scripts/run-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,42 @@ 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
ln -s ../../../../android_build_objs obj
./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
Expand All @@ -32,29 +49,24 @@ 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
export LLVM_ROOT=$LLVM
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

Expand All @@ -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

0 comments on commit 58c3faf

Please sign in to comment.