Skip to content

Commit

Permalink
[travis ci] Adds 'for-each-file-in-dir.sh' for generating file list i…
Browse files Browse the repository at this point in the history
…n cocos2d. CocosRobot will send a PR for that change.
  • Loading branch information
James Chen committed Mar 6, 2014
1 parent 2d890fe commit dfdb6c4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: cpp
env:
matrix:
- GEN_COCOS_FILES=YES
- PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++
- PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++
# Since switching to C++11 only the ARM version of the nactive client
Expand Down
29 changes: 29 additions & 0 deletions tools/travis-scripts/for-each-file-in-dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# exit this script if any commmand fails
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$DIR"/../..

shopt -s dotglob

echo_all_files() {
for file in $1/*
do
if [ -d "$file" ]; then
echo_all_files "$file"
else
relative_path="${file##*${PROJECT_ROOT}/}"
prefix=${relative_path:0:5}
if [ "$prefix"x != ".git/"x ]; then
echo "\"$relative_path\","
fi
fi
done
}

echo "["
echo_all_files ${PROJECT_ROOT}
echo "]"

14 changes: 6 additions & 8 deletions tools/travis-scripts/generate-cocosfiles.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COCOS2DX_ROOT="$DIR"/../..
COCOSFILES_CREATOR_ROOT=$COCOS2DX_ROOT/tools/project-creator/config-create
PROJECT_ROOT="$DIR"/../..

COMMITTAG="[AUTO][ci skip]"

# Exit on error
Expand All @@ -11,17 +11,15 @@ set -e
generate_cocosfiles_json()
{
echo "Updates cocos_files.json"
pushd "$COCOSFILES_CREATOR_ROOT"
./create_config.py
popd
./for-each-file-in-dir.sh > ${PROJECT_ROOT}/templates/cocos2dx_files.json
}

if [ "$GEN_COCOS_FILES"x != "YES"x ]; then
generate_cocosfiles_json
exit 0
fi

pushd "$COCOS2DX_ROOT"
pushd "$PROJECT_ROOT"
#Set git user for cocos2d-x repo
git config user.email ${GH_EMAIL}
git config user.name ${GH_USER}
Expand Down Expand Up @@ -51,7 +49,7 @@ echo Using "$ELAPSEDSECS" in the branch names for pseudo-uniqueness

# 2. Check if there are any files that are different from the index

pushd "$COCOS2DX_ROOT"
pushd "$PROJECT_ROOT"

# Run status to record the output in the log
git status
Expand Down Expand Up @@ -88,7 +86,7 @@ COCOS_BRANCH=update_cocosfiles_"$ELAPSEDSECS"
pushd "${DIR}"

# 3. In Cocos2D-X repo, Checkout a branch named "updategeneratedsubmodule" Update the submodule reference to point to the commit with generated bindings
cd "${COCOS2DX_ROOT}"
cd "${PROJECT_ROOT}"
git add .
git checkout -b "$COCOS_BRANCH"
git commit -m "$COMMITTAG : updating tools/project-creator/module/cocos_files.json"
Expand Down

0 comments on commit dfdb6c4

Please sign in to comment.