This commit is contained in:
zhangbin 2014-03-06 16:50:07 +08:00
Родитель 99b2c5453e 62a121a54f
Коммит 7588a12f98
11 изменённых файлов: 361 добавлений и 55 удалений

Просмотреть файл

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

Просмотреть файл

@ -23,13 +23,15 @@ How to start a new game
-----------------------
1. Download the code from [cocos2d download site][4]
2. Enter `tools/project-creator`
3. Run the `create_project.py` script
2. Run `setup.py`
3. Run the `cocos` script
Example:
$ cd cocos2d-x/tools/project-creator
$ ./create_project.py -n mygame -k com.your_company.mygame -l cpp -p /home/mygame
$ cd cocos2d-x
$ ./setup.py
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
$ cocos new mygame -p com.your_company.mygame -l cpp -d /home/mygame
$ cd /home/mygame
### Build new project for android ###

Просмотреть файл

@ -76,7 +76,7 @@
* gcc 4.7 for Linux or Android. For Android ndk-r9 or newer is required.
* Visual Studio 2012 (for Windows)
## Run samples
## How to run TestCpp
### Mac OSX & iOS
@ -94,7 +94,7 @@ Can run sample on Android in two ways:
**By commnad**
$ cd cocos2d-x
$ ./install.py
$ ./setup.py
$ cd build
$ ./android-build.py -p 10
$ adb install cocos2d-x/tests/proj.android/bin/TestDemo-debug.apk
@ -104,7 +104,7 @@ Then click item on Android device to run tests. Available value of `-p` is the A
**Using Eclipse**
$ cd cocos2d-x
$ ./install.py
$ ./setup.py
$ cd build
$ ./android-build.py
@ -139,6 +139,16 @@ Run
$ cd bin/testcpp
$ ./testcpp
## How to start a new game
$ cd cocos2d-x
$ ./setup.py
$ source FILE_TO_RECORD_SYSTEM_VARIABLE
`FILE_TO_RECORD_SYSTEM_VARIABLE` may be `~/.bash_profile`, `~/.bash_login` or `~./.profile`
$ cocos new MyGame -p com.MyCompany.MyGame -l cpp -d directory_to_save
Because `cocos run` command is not ready, so you should do it manually as running `TestCpp`. After `cocos run` command is finished, can just run `cocos run` to run the new game on demand target.
# Highlights of v3.0

Просмотреть файл

@ -35,9 +35,9 @@ And it will read only one of them. So we will add environment variable in the sa
Which means that
* add environment variables into ~/.bash_profile if it exists
* otherwise it will the add environment variables into ~/.bash_login if it exists
* otherwise it will the add environment variable sinto ~/.profile if it exists
* otherwise it will the add environment variables into ~/.profile if it exists
Will create ~/.bash_profile when none of them exist, and add environment variable into it.
Will create ~/.bash_profile when none of them exist, and add environment variables into it.
'''
@ -56,7 +56,6 @@ class SetEnvVar(object):
self.ndk_root = ndk
# whether the value of "ndk_root" is passed or not
self.ndk_root_passed = False
self.file_to_write_environment = None
self.file_used_for_setup = ''
self.variable_found_in_env = False
@ -89,7 +88,7 @@ class SetEnvVar(object):
else:
file_to_write = os.path.join(home, '.bash_profile')
self.file_to_write_environment = file_to_write
self.file_used_for_setup = file_to_write
file = open(file_to_write, 'a')
if self.ndk_root_passed and self._find_string_in_file('export '.join(key), file_to_write):
@ -121,10 +120,7 @@ class SetEnvVar(object):
try:
result = os.environ[var]
self.variable_found_in_env = true
if result:
return True
else:
return False
return True
except Exception:
string_to_search = 'export %s' % var
home = os.path.expanduser('~')
@ -134,6 +130,7 @@ class SetEnvVar(object):
if os.path.exists(path):
if self._find_string_in_file(string_to_search, path):
self.file_used_for_setup = path
self.variable_found_in_env = True
return True
# search it in ~/.bash_login
@ -141,6 +138,7 @@ class SetEnvVar(object):
if os.path.exists(path):
if self._find_string_in_file(string_to_search, path):
self.file_used_for_setup = path
self.variable_found_in_env = True
return True
# search it in ~/.profile
@ -148,7 +146,10 @@ class SetEnvVar(object):
if os.path.exists(path):
if self._find_string_in_file(string_to_search, path):
self.file_used_for_setup = path
self.variable_found_in_env = True
return True
self.variable_found_in_env = False
return False
def _get_ndk_root(self):
@ -164,21 +165,28 @@ class SetEnvVar(object):
import tkFileDialog
root = Tkinter.Tk()
self._center(root)
def callback():
self.ndk_root = tkFileDialog.askdirectory()
root.destroy()
frame = Tkinter.Frame(root)
Tkinter.Label(frame, text='Select path for NDK_ROOT:').pack(side=Tkinter.LEFT)
Tkinter.Button(frame, text='...', command=callback).pack(side=Tkinter.LEFT)
frame.pack()
label_content = """
Please select path for NDK_ROOT. NDK is needed to develop Android native application.
More information of NDK please refer to https://developer.android.com/tools/sdk/ndk/index.html.
You can skip to it now without problem. But you will need it later to build the game for Android.
"""
Tkinter.Label(root, text=label_content).pack()
Tkinter.Button(root, text='select ndk_root', command=callback).pack()
self._center(root)
root.mainloop()
return True
return False
if self.ndk_root:
return True
else:
return False
else:
return False
# display a window in center and put it on top
def _center(self, win):
@ -193,23 +201,25 @@ class SetEnvVar(object):
def set_ndk_root(self, value):
print '-> Adding NDK_ROOT environment variable...',
self.ndk_root_updated = False
ndk_root_updated = False
if value:
self.ndk_root = value
ndk_root_updated = True
else:
ndk_root_updated = self._get_ndk_root()
ndk_root_selected = self._get_ndk_root()
if self.ndk_root:
os.environ[NDK_ROOT] = self.ndk_root
self._set_environment_variable(NDK_ROOT, self.ndk_root)
ndk_root_updated = True
print 'OK'
else:
ndk_root_updated = False
if not ndk_root_selected:
print 'SKIPPED'
else:
print 'ALREADY ADDED'
if ndk_root_updated:
print 'OK'
return ndk_root_updated
def set_console_root(self):
@ -246,9 +256,9 @@ class SetEnvVar(object):
if console_updated or ndk_root_updated:
result_string = '\nSet up successful:\n'
if console_updated:
result_string += '\tCOCOS_CONSOLE_ROOT was added into %s.\n' % self.file_to_write_environment
result_string += '\tCOCOS_CONSOLE_ROOT was added into %s.\n' % self.file_used_for_setup
if ndk_root_updated:
result_string += '\tNDK_ROOT was added into %s.\n' % self.file_to_write_environment
result_string += '\tNDK_ROOT was added into %s.\n' % self.file_used_for_setup
print result_string
else:

Просмотреть файл

@ -1 +1 @@
1283277b97cce107c19ac971a0648a5720e341c5
b8e377ea1413a393a14914cae394a4d6a414b2c4

@ -1 +1 @@
Subproject commit cef397668e1220f2b9b4262ee18fcffedb8347ca
Subproject commit c788443babb3505c4668cb7079f0c9a0e450c6e0

Просмотреть файл

@ -0,0 +1,112 @@
#This configure file use .gitingore rules.
#So you can config this file like config .gitingore
#
# Ignore thumbnails created by windows
Thumbs.db
.git
# ignore copy files
/lib
/linux-build
/samples
/templates
/tests
/plugin/samples
/tools
.gitattributes
.gitignore
.gitmodules
.travis.yml
setup.py
# Ignore files build by Visual Studio
win32-msvc-vs201*-x86
*.obj
*.exe
*.pdb
*.aps
*.vcproj.*.user
*.vspscc
*_i.c
*.i
*.icf
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug/
[Dd]ebug.win32/
*.sbr
*.sdf
obj/
[Rr]elease/
[Rr]elease.win32/
_ReSharper*/
[Tt]est[Rr]esult*
ipch/
*.opensdf
# Ignore files build by ndk and eclipse
libs/
bin/
obj/
gen/
assets/
local.properties
# Ignore python compiled files
*.pyc
# Ignore files build by airplay and marmalade
build_*_xcode/
build_*_vc10/
# Ignore files build by xcode
*.mode*v*
*.pbxuser
*.xcbkptlist
*.xcscheme
*.xcworkspacedata
*.xcuserstate
*.xccheckout
xcschememanagement.plist
.DS_Store
._.*
xcuserdata/
DerivedData/
# Ignore files built by AppCode
.idea/
# Ignore files built by bada
.Simulator-Debug/
.Target-Debug/
.Target-Release/
# Ignore files built by blackberry
Simulator/
Device-Debug/
Device-Release/
# Ignore vim swaps
*.swp
*.swo
# Ignore files created by create_project.py
/projects
# CTags
tags
#include
!/tools/cocos2d-console/console/bin/
!/plugin-x/plugin-x_ios.xcworkspace/

Просмотреть файл

@ -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 "]"

Просмотреть файл

@ -1,9 +1,11 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COCOS2DX_ROOT="$DIR"/../..
COCOSFILES_CREATOR_ROOT=$COCOS2DX_ROOT/tools/project-creator/config-create
COMMITTAG="[AUTO][ci skip]"
PROJECT_ROOT="$DIR"/../..
COMMITTAG="[AUTO][ci skip]: updating cocos2dx_files.json"
PUSH_REPO="https://api.github.com/repos/cocos2d/cocos2d-x/pulls"
OUTPUT_FILE_PATH="${PROJECT_ROOT}/templates/cocos2dx_files.json"
# Exit on error
set -e
@ -11,9 +13,7 @@ set -e
generate_cocosfiles_json()
{
echo "Updates cocos_files.json"
pushd "$COCOSFILES_CREATOR_ROOT"
./create_config.py
popd
./generate-template-files.py
}
if [ "$GEN_COCOS_FILES"x != "YES"x ]; then
@ -21,7 +21,7 @@ if [ "$GEN_COCOS_FILES"x != "YES"x ]; then
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}
@ -35,12 +35,6 @@ echo
echo cocos_files.json was generated successfully
echo
if [ -z "${COMMITTAG+aaa}" ]; then
# ... if COMMITTAG is not set, use this machine's hostname
COMMITTAG=`hostname -s`
fi
echo
echo Using "'$COMMITTAG'" in the commit messages
echo
@ -51,7 +45,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
@ -87,11 +81,10 @@ 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"
git commit -m "$COMMITTAG"
#Set remotes
git remote add upstream https://${GH_USER}:${GH_PASSWORD}@github.com/${GH_USER}/cocos2d-x.git 2> /dev/null > /dev/null
# 4. In Cocos2D-X repo, Push the commit to cocos2d-x repository
@ -101,6 +94,6 @@ git push -fq upstream "$COCOS_BRANCH" 2> /dev/null
# 5.
echo "Sending Pull Request to base repo ..."
curl --user "${GH_USER}:${GH_PASSWORD}" --request POST --data "{ \"title\": \"$COMMITTAG : updating tools/project-creator/module/cocos_files.json\", \"body\": \"\", \"head\": \"${GH_USER}:${COCOS_BRANCH}\", \"base\": \"${TRAVIS_BRANCH}\"}" https://api.github.com/repos/cocos2d/cocos2d-x/pulls 2> /dev/null > /dev/null
curl --user "${GH_USER}:${GH_PASSWORD}" --request POST --data "{ \"title\": \"$COMMITTAG\", \"body\": \"\", \"head\": \"${GH_USER}:${COCOS_BRANCH}\", \"base\": \"${TRAVIS_BRANCH}\"}" "${PUSH_REPO}" 2> /dev/null > /dev/null
popd

Просмотреть файл

@ -0,0 +1,149 @@
#!/usr/bin/python
#coding=utf-8
"""****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************"""
import os
import sys
import re
class CocosFileList:
"""
Function:
List cocos engine's files and save to "../module/cocos_file_list.json".
config "config.gitingore" file can set exclude or include files.
"""
def __init__(self):
self.excludeConfig=[]
self.inludeConfig=[]
self.rootDir = ""
self.fileList=[]
def readIngoreFile(self, fileName):
"""
Read configure file which use ".gitingore"'s rules.
"""
pfile = ""
try:
pfile = open(fileName, 'r')
except IOError:
return
for line in pfile:
line = line.strip()
if not line or line[0] == "#":
continue
#convert .gitingore regular expression to python's regular expression
line=line.replace('.', '\\.')
line=line.replace('*', '.*')
line="%s$" %line
if line[0] == "!":
self.inludeConfig.append(line[1:])
else:
self.excludeConfig.append(line)
pfile.close()
def parseFileList(self, rootDir):
self.rootDir = os.path.abspath(rootDir)
self.__parseFileList(rootDir)
def __parseFileList(self, folderdir):
"""
"""
for item in os.listdir(folderdir):
path = os.path.join(folderdir, item)
relativePath = path[len(self.rootDir)+1:len(path)]
relativePath = relativePath.replace('\\', '/')
if os.path.isdir(path):
if (
self.__bInclude("/%s" %relativePath) or
self.__bInclude("/%s/" %relativePath) or
self.__bInclude(item) or
self.__bInclude("%s/" %item)
):
self.fileList.append("%s/" %relativePath)
continue
if (
self.__bExclude("/%s" %relativePath) or
self.__bExclude("/%s/" %relativePath) or
self.__bExclude(item) or
self.__bExclude("%s/" %item)
):
continue
self.__parseFileList(path)
else:
if (
not self.__bInclude("/%s" %relativePath) and
not self.__bInclude(item)
):
if (
self.__bExclude("/%s" %relativePath) or
self.__bExclude(item)
):
continue
# print(relativePath)
self.fileList.append(relativePath)
def __bExclude(self, item):
bexclude = False
for index in range(len(self.excludeConfig)):
if re.match(self.excludeConfig[index], item):
bexclude = True
break
return bexclude
def __bInclude(self, item):
binclude = False
for index in range(len(self.inludeConfig)):
if re.match(self.inludeConfig[index], item):
binclude = True
break
return binclude
def writeFileList(self,fileName):
"""
Save content to file with json format.
"""
f = open(fileName,"w")
self.fileList.sort()
content = "[\n\"%s\"\n]" % ("\",\n\"".join(self.fileList))
f.write(content)
f.close()
return True
# ------------ main --------------
if __name__ == '__main__':
cocos_root =os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
cocos_file_path =os.path.abspath(os.path.join(cocos_root, "templates", "cocos2dx_files.json"))
cocos_file_ingore =os.path.abspath(os.path.join(os.path.dirname(__file__), "config.gitingore"))
# print ("begin list files")
cocosObj = CocosFileList()
cocosObj.readIngoreFile(cocos_file_ingore)
cocosObj.parseFileList(cocos_root)
cocosObj.writeFileList(cocos_file_path)
# print ("had list files to cocos_file_list.json")

Просмотреть файл

@ -32,14 +32,14 @@ if [ "$GEN_COCOS_FILES"x = "YES"x ]; then
fi
cd $COCOS2DX_ROOT/tools/travis-scripts
# ./generate-cocosfiles.sh
./generate-cocosfiles.sh
elif [ "$PLATFORM"x = "android"x ]; then
export NDK_ROOT=$HOME/bin/android-ndk
# Generate binding glue codes
echo "Generating bindings glue codes ..."
cd $COCOS2DX_ROOT/tools/travis-scripts
# ./generate-cocosfiles.sh
./generate-cocosfiles.sh
cd $COCOS2DX_ROOT
@ -66,7 +66,7 @@ elif [ "$PLATFORM"x = "linux"x ]; then
# Generate binding glue codes
echo "Generating bindings glue codes ..."
cd $COCOS2DX_ROOT/tools/travis-scripts
# ./generate-cocosfiles.sh
./generate-cocosfiles.sh
echo "Building cocos2d-x"
cd $COCOS2DX_ROOT/build
@ -79,7 +79,7 @@ elif [ "$PLATFORM"x = "emscripten"x ]; then
# Generate binding glue codes
echo "Generating bindings glue codes ..."
cd $COCOS2DX_ROOT/tools/travis-scripts
# ./generate-cocosfiles.sh
./generate-cocosfiles.sh
cd $COCOS2DX_ROOT/build
export PYTHON=/usr/bin/python
@ -88,7 +88,7 @@ elif [ "$PLATFORM"x = "emscripten"x ]; then
EMCC_DEBUG=1 make PLATFORM=emscripten -j 8
elif [ "$PLATFORM"x = "ios"x ]; then
cd $COCOS2DX_ROOT/tools/travis-scripts
# ./generate-cocosfiles.sh
./generate-cocosfiles.sh
cd $COCOS2DX_ROOT
xctool/xctool.sh -project samples/Cpp/HelloCpp/proj.ios/HelloCpp.xcodeproj -scheme HelloCpp test