Merge pull request #1434 from folecr/autogenscript

Jenkins script for auto-generating and committing JS bindings.
This commit is contained in:
minggo 2012-10-09 18:29:17 -07:00
commit b7cfb6cbe9
1 changed files with 73 additions and 10 deletions

View File

@ -2,24 +2,87 @@
# Generate JS bindings for Cocos2D-X
# ... using Android NDK system headers
# ... and automatically update submodule references
# ... and push these changes to remote repos
# Dependencies (see ../../../tojs/genbindings.sh
# Dependencies
#
# For bindings generator:
# (see ../../../tojs/genbindings.sh
# ... for the defaults used if the environment is not customized)
#
# * $PYTHON_BIN
# * $CLANG_ROOT
# * $NDK_ROOT
#
# For automatically pushing changes:
#
# * REMOTE_COCOS2DX_REPOSITORY
# * REMOTE_AUTOGEN_BINDINGS_REPOSITORY
# * Ensure you have ssh access to above repositories
compileresult=0
# Exit on error
set -e
if [ -z "${REMOTE_COCOS2DX_REPOSITORY+aaa}" ]; then
echo Environment variable must be set REMOTE_COCOS2DX_REPOSITORY
# example
# REMOTE_COCOS2DX_REPOSITORY="git@github.com:cocos2d/cocos2d-x.git"
# REMOTE_COCOS2DX_REPOSITORY="$HOME/test/cocos2d-x"
exit 1
fi
if [ -z "${REMOTE_AUTOGEN_BINDINGS_REPOSITORY+aaa}" ]; then
echo Environment variable must be set REMOTE_AUTOGEN_BINDINGS_REPOSITORY
# example
# REMOTE_COCOS2DX_REPOSITORY="git@github.com:folecr/cocos2dx-autogen-bindings.git"
# REMOTE_COCOS2DX_REPOSITORY="$HOME/test/cocos2dx-autogen-bindings"
exit 1
fi
if [ -z "${COMMITTAG+aaa}" ]; then
# ... if COMMITTAG is not set, use this machine's hostname
COMMITTAG=`hostname -s`
fi
echo Using "'$COMMITTAG'" in the commit messages
ELAPSEDSECS=`date +%s`
echo Using "$ELAPSEDSECS" in the branch names for pseudo-uniqueness
GENERATED_BRANCH=autogeneratedbindings_"$ELAPSEDSECS"
COCOS_BRANCH=updategeneratedsubmodule_"$ELAPSEDSECS"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COCOS2DX_ROOT="$DIR"/../../../../ /bin/bash ../../../tojs/genbindings.sh
COCOS2DX_ROOT="$DIR"/../../../..
GENERATED_GITDIR="$COCOS2DX_ROOT"/scripting/javascript/bindings/generated/.git
GENERATED_WORKTREE="$COCOS2DX_ROOT"/scripting/javascript/bindings/generated
compileresult=$[$compileresult+$?]
# git command shortcut
gitcmd_GEN="git --git-dir=$GENERATED_GITDIR --work-tree=$GENERATED_WORKTREE"
# return the compileresult.
if [ $compileresult != 0 ]; then
exit 1
else
exit 0
fi
# testing...
${gitcmd_GEN} status
# 1. Generate JS bindings
COCOS2DX_ROOT="$COCOS2DX_ROOT" /bin/bash ../../../tojs/genbindings.sh
# 2. In JSBindings repo, Check out a branch named "autogeneratedbindings" and commit the auto generated bindings to it
${gitcmd_GEN} add README cocos2dx.cpp cocos2dx.hpp cocos2dxapi.js
${gitcmd_GEN} checkout origin/master -b "$GENERATED_BRANCH"
${gitcmd_GEN} commit -m "$COMMITTAG : autogenerated bindings"
# 3. In JSBindings repo, Push the commit with generated bindings to "master" of the auto generated bindings repository
${gitcmd_GEN} push "$REMOTE_AUTOGEN_BINDINGS_REPOSITORY" "$GENERATED_BRANCH":master
pushd "${DIR}"
# 4. In Cocos2D-X repo, Checkout a branch named "updategeneratedsubmodule" Update the submodule reference to point to the commit with generated bindings
cd "${COCOS2DX_ROOT}"
git add scripting/javascript/bindings/generated
git checkout origin/gles20 -b "$COCOS_BRANCH"
git commit -m "$COMMITTAG : updating submodule reference to latest autogenerated bindings"
# 5. In Cocos2D-X repo, Push the commit with updated submodule to "gles20" of the cocos2d-x repository
git push "$REMOTE_COCOS2DX_REPOSITORY" "$COCOS_BRANCH":gles20
popd