Merge pull request #5653 from dumganhar/re-add-lua

Re-add CocosRobot send bindings glue codes to cocos2d-x repo.
This commit is contained in:
James Chen 2014-03-10 18:32:28 +08:00
Родитель 2fbdad0b7e 7d3a6c999d
Коммит 784a88dc0e
12 изменённых файлов: 885 добавлений и 2 удалений

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

@ -1,6 +1,7 @@
language: cpp language: cpp
env: env:
matrix: matrix:
- GEN_BINDING=YES
- GEN_COCOS_FILES=YES - GEN_COCOS_FILES=YES
- PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++ - PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++
- PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++ - PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++

57
tools/tolua/README.mdown Normal file
Просмотреть файл

@ -0,0 +1,57 @@
How to Use bindings-generator
==================
On Windows:
------------
* Make sure that you have installed `android-ndk-r9b`.
* Download python2.7.3 (32bit) from (http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi).
* Add the installed path of python (e.g. C:\Python27) to windows environment variable named 'PATH'.
* Download pyyaml from http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.7.exe and install it.
* Download pyCheetah from https://raw.github.com/dumganhar/cocos2d-x/download/downloads/Cheetah.zip, unzip it to "C:\Python27\Lib\site-packages"
* Set environment variables (`NDK_ROOT`)
* Go to "cocos2d-x/tools/tolua" folder, and run "genbindings.py". The generated codes will be under "cocos\scripting\auto-generated\js-bindings".
On MAC:
----------
* The OSX 10.9 has a built-in python2.7 and if your os don't have python2.7 then use [Homebrew](http://brew.sh/) to install the python and use pip install the python dependencies.
<pre>
brew install python
</pre>
* Install python dependices by pip.
<pre>
sudo easy_install pip
sudo pip install PyYAML
sudo pip install Cheetah
</pre>
* Download [64bit ndk-r9b-x86_64](http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86_64.tar.bz2) from [google](http://developer.android.com/tools/sdk/ndk/index.html)
* Run
<pre>
export NDK_ROOT=/path/to/android-ndk-r9b
./genbindings.py
</pre>
On Ubuntu Linux 12.04 64bit
------------
* Install python
<pre>
sudo apt-get install python2.7
</pre>
* Install python dependices by pip.
<pre>
sudo apt-get install python-pip
sudo pip install PyYAML
sudo pip install Cheetah
</pre>
* Download [64bit ndk-r9b-x86_64]( https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64.tar.bz2) from [google](http://developer.android.com/tools/sdk/ndk/index.html)
* Go to "cocos2d-x/tools/tolua", Run
<pre>
export NDK_ROOT=/path/to/android-ndk-r9b
./genbindings.py
</pre>

154
tools/tolua/cocos2dx.ini Normal file
Просмотреть файл

@ -0,0 +1,154 @@
[cocos2d-x]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = cc
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
# what headers to parse
headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewProtocol GLView Image Event(?!.*(Physics).*).* Component
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$ setContentSize setAnchorPoint],
Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants],
MotionStreak::[getBlendFunc setBlendFunc draw update],
AtlasNode::[getBlendFunc setBlendFunc],
ParticleBatchNode::[getBlendFunc setBlendFunc],
LayerColor::[getBlendFunc setBlendFunc],
ParticleSystem::[getBlendFunc setBlendFunc],
DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground],
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getFrustum getRenderer],
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
MenuItem.*::[create setCallback initWithCallback],
Label::[getLettersInfo createWithTTF setTTFConfig],
Copying::[*],
LabelProtocol::[*],
LabelTextFormatProtocol::[*],
.*Delegate::[*],
PoolManager::[*],
Texture2D::[initWithPVRTCData addPVRTCImage releaseData setTexParameters initWithData keepData getPixelFormatInfoMap],
Set::[begin end acceptVisitor],
IMEDispatcher::[*],
SAXParser::[*],
Thread::[*],
Profiler::[*],
ProfilingTimer::[*],
CallFunc::[create initWithFunction],
SAXDelegator::[*],
Color3bObject::[*],
TouchDispatcher::[*],
EGLTouchDelegate::[*],
ScriptEngineManager::[*],
KeypadHandler::[*],
Invocation::[*],
SchedulerScriptHandlerEntry::[*],
Size::[*],
Point::[*],
PointArray::[*],
Rect::[*],
String::[*],
Data::[*],
Dictionary::[*],
Array::[*],
Range::[*],
EventListenerVector::[*],
EventListener.*::[create],
EventTouch::[(s|g)etTouches],
NotificationObserver::[*],
Image::[initWithString initWithImageData initWithRawData],
Sequence::[create],
Spawn::[create],
GLProgram::[getProgram setUniformLocationWith2f.* setUniformLocationWith1f.* setUniformLocationWith3f.* setUniformLocationWith4f.*],
Grid3DAction::[create actionWith.* vertex originalVertex (g|s)etVertex getOriginalVertex],
Grid3D::[vertex originalVertex (g|s)etVertex getOriginalVertex],
TiledGrid3DAction::[create actionWith.* tile originalTile getOriginalTile (g|s)etTile],
TiledGrid3D::[tile originalTile getOriginalTile (g|s)etTile],
TMXLayer::[getTiles],
TMXMapInfo::[startElement endElement textHandler],
ParticleSystemQuad::[postStep setBatchNode draw setTexture$ setTotalParticles updateQuadWithParticle setupIndices listenBackToForeground initWithTotalParticles particleWithFile node],
LayerMultiplex::[create layerWith.* initWithLayers],
CatmullRom.*::[create actionWithDuration],
Bezier.*::[create actionWithDuration],
CardinalSpline.*::[create actionWithDuration setPoints],
Scheduler::[pause resume unschedule schedule update isTargetPaused isScheduled],
TextureCache::[addPVRTCImage addImageAsync],
Timer::[getSelector createWithScriptHandler],
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate onTouch.* onAcc.* onKey.* onRegisterTouchListener],
FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getFileData getDataFromFile getFullPathCache],
Application::[^application.* ^run$],
Camera::[getEyeXYZ getCenterXYZ getUpXYZ],
ccFontDefinition::[*],
Ref::[autorelease isEqual acceptVisitor update],
UserDefault::[getInstance (s|g)etDataForKey],
GLViewProtocol::[setTouchDelegate],
GLView::[end swapBuffers],
NewTextureAtlas::[*],
DisplayLinkDirector::[mainLoop setAnimationInterval startAnimation stopAnimation],
RenderTexture::[listenToBackground listenToForeground],
TMXTiledMap::[getPropertiesForGID],
EventDispatcher::[dispatchCustomEvent],
EventCustom::[getUserData setUserData],
Component::[serialize]
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
ProgressTimer::[setReverseProgress=setReverseDirection],
AnimationCache::[addAnimationsWithFile=addAnimations],
LayerGradient::[initWithColor=init],
LayerColor::[initWithColor=init],
GLProgram::[initWithVertexShaderByteArray=initWithString initWithVertexShaderFilename=init setUniformLocationWith1i=setUniformLocationI32],
Node::[removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren],
LabelAtlas::[create=_create],
Sprite::[initWithFile=init],
SpriteBatchNode::[initWithFile=init],
Touch::[getID=getId],
SimpleAudioEngine::[preloadBackgroundMusic=preloadMusic setBackgroundMusicVolume=setMusicVolume getBackgroundMusicVolume=getMusicVolume playBackgroundMusic=playMusic stopBackgroundMusic=stopMusic pauseBackgroundMusic=pauseMusic resumeBackgroundMusic=resumeMusic rewindBackgroundMusic=rewindMusic isBackgroundMusicPlaying=isMusicPlaying willPlayBackgroundMusic=willPlayMusic],
FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup],
Director::[end=endToLua]
rename_classes = ParticleSystemQuad::ParticleSystem,
SimpleAudioEngine::AudioEngine
# for all class names, should we remove something when registering in the target VM?
remove_prefix =
# classes for which there will be no "parent" lookup
classes_have_no_parents = Director SimpleAudioEngine FileUtils TMXMapInfo Application
# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip = Clonable
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label GLViewProtocol GLView EventAcceleration DisplayLinkDirector Component
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

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

@ -0,0 +1,74 @@
[cocos2dx_extension]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx_extension
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = cc
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
# what headers to parse
headers = %(cocosdir)s/extensions/cocos-ext.h %(cocosdir)s/cocos/editor-support/cocosbuilder/CocosBuilder.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* EditBox$ ScrollView$ TableView$ TableViewCell$
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers],
CCBAnimationManager::[setAnimationCompletedCallback setCallFunc addNode],
.*Delegate::[*],
.*Loader.*::[*],
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate .*HSV],
EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler],
AssetsManager::[(g|s)etDelegate],
AssetsManagerDelegateProtocol::[*],
Control::[removeHandleOfControlEvent addHandleOfControlEvent],
ControlUtils::[*],
ControlSwitchSprite::[*],
ScrollView::[(g|s)etDelegate$],
TableView::[create (g|s)etDataSource$ (g|s)etDelegate]
rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager]
rename_classes = CCBReader::_Reader,
CCBAnimationManager::AnimationManager
# for all class names, should we remove something when registering in the target VM?
remove_prefix =
# classes for which there will be no "parent" lookup
classes_have_no_parents =
# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip = Ref ProcessBase
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes = ArmatureDataManager
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

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

@ -0,0 +1,68 @@
[cocos2dx_gui]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx_ui
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = ccui
# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label".
cpp_namespace = cocos2d::ui
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
# what headers to parse
headers = %(cocosdir)s/cocos/gui/CocosGUI.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc ccTouch.*],
Widget::[(s|g)etUserObject],
Layer::[getInputManager],
LayoutParameter::[(s|g)etMargin],
Helper::[init],
ImageView::[doubleClickEvent checkDoubleClick]
rename_functions =
rename_classes =
# for all class names, should we remove something when registering in the target VM?
remove_prefix =
# classes for which there will be no "parent" lookup
classes_have_no_parents = Helper
# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip = Ref
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes = Helper
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

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

@ -0,0 +1,68 @@
[cocos2dx_physics]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx_physics
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = cc
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath -I%(cocosdir)s/cocos/physics
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT -DCC_USE_PHYSICS=1
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
# what headers to parse
headers = %(cocosdir)s/cocos/2d/cocos2d.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Event(.*(Physics).*) Physics.*
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = PhysicsBody::[getJoints createPolygon createEdgeChain createEdgePolygon],
PhysicsShape::[recenterPoints getPolyonCenter],
PhysicsShapeBox::[^getPoints$],
PhysicsShapeEdgeBox::[^getPoints$],
PhysicsShapePolygon::[create calculateArea calculateMoment ^getPoints$],
PhysicsShapeEdgePolygon::[create ^getPoints$],
PhysicsShapeEdgeChain::[create ^getPoints$],
PhysicsWorld::[getScene queryPoint queryRect rayCast],
PhysicsContact::[getData setData]
rename_functions =
rename_classes =
# for all class names, should we remove something when registering in the target VM?
remove_prefix =
# classes for which there will be no "parent" lookup
classes_have_no_parents = PhysicsWorld PhysicsJoint PhysicsContactPreSolve PhysicsContactPostSolve
# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip =
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes =
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

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

@ -0,0 +1,61 @@
[cocos2dx_spine]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx_spine
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = sp
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
# what headers to parse
headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Skeleton SkeletonAnimation
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = Skeleton::[findBone findSlot getAttachment setAttachment update draw createWith.*],
SkeletonAnimation::[addAnimationState setAnimationStateData update createWith.* (s|g)etBlendFunc]
rename_functions =
rename_classes =
# for all class names, should we remove something when registering in the target VM?
remove_prefix =
# classes for which there will be no "parent" lookup
classes_have_no_parents =
# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip = Ref ProcessBase
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes = Skeleton SkeletonAnimation
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

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

@ -0,0 +1,79 @@
[cocos2dx_studio]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx_studio
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = ccs
# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::gui::Label".
cpp_namespace = cocostudio
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
# what headers to parse
headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ ActionManagerEx ComAudio ComController ComAttribute ComRender BatchNode SceneReader GUIReader ActionObject Tween DisplayManager
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* (s|g)etBlendFunc (s|g)etUserObject add\w*EventListener],
ArmatureDataManager::[CCArmatureDataManager ~CCArmatureDataManager],
Armature::[createBone updateBlendType setBody getShapeList ^getBody$],
Skin::[(s|g)etSkinData],
ArmatureAnimation::[updateHandler updateFrameData frameEvent setMovementEventCallFunc setFrameEventCallFunc],
Bone::[(s|g)etIgnoreMovementBoneData],
ActionManagerEx::[initWithDictionary],
ActionObject::[initWithDictionary],
DisplayManager::[initDisplayList (s|g)etCurrentDecorativeDisplay getDecorativeDisplayByIndex],
Tween::[(s|g)etMovementBoneData],
GUIReader::[storeFileDesignSize getFileDesignSize getParseCallBackMap getParseObjectMap],
ActionNode::[initWithDictionary],
ActionObject::[initWithDictionary],
BaseData::[copy subtract]
rename_functions = GUIReader::[shareReader=getInstance purgeGUIReader=destroyInstance],
ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance],
SceneReader::[purgeSceneReader=destroyInstance]
rename_classes =
# for all class names, should we remove something when registering in the target VM?
remove_prefix =
# classes for which there will be no "parent" lookup
classes_have_no_parents =
# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip = Ref ProcessBase
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes = ArmatureDataManager ComAttribute ComRender ComAudio ActionManagerEx SceneReader GUIReader BatchNode
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

165
tools/tolua/genbindings.py Executable file
Просмотреть файл

@ -0,0 +1,165 @@
#!/usr/bin/python
# This script is used to generate luabinding glue codes.
# Android ndk version must be ndk-r9b.
import sys
import os, os.path
import shutil
import ConfigParser
import subprocess
import re
from contextlib import contextmanager
def _check_ndk_root_env():
''' Checking the environment NDK_ROOT, which will be used for building
'''
try:
NDK_ROOT = os.environ['NDK_ROOT']
except Exception:
print "NDK_ROOT not defined. Please define NDK_ROOT in your environment."
sys.exit(1)
return NDK_ROOT
def _check_python_bin_env():
''' Checking the environment PYTHON_BIN, which will be used for building
'''
try:
PYTHON_BIN = os.environ['PYTHON_BIN']
except Exception:
print "PYTHON_BIN not defined, use current python."
PYTHON_BIN = sys.executable
return PYTHON_BIN
class CmdError(Exception):
pass
@contextmanager
def _pushd(newDir):
previousDir = os.getcwd()
os.chdir(newDir)
yield
os.chdir(previousDir)
def _run_cmd(command):
ret = subprocess.call(command, shell=True)
if ret != 0:
message = "Error running command"
raise CmdError(message)
def main():
cur_platform= '??'
llvm_path = '??'
ndk_root = _check_ndk_root_env()
# del the " in the path
ndk_root = re.sub(r"\"", "", ndk_root)
python_bin = _check_python_bin_env()
platform = sys.platform
if platform == 'win32':
cur_platform = 'windows'
elif platform == 'darwin':
cur_platform = platform
elif 'linux' in platform:
cur_platform = 'linux'
else:
print 'Your platform is not supported!'
sys.exit(1)
if platform == 'win32':
x86_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.3/prebuilt', '%s' % cur_platform))
else:
x86_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.3/prebuilt', '%s-%s' % (cur_platform, 'x86')))
x64_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.3/prebuilt', '%s-%s' % (cur_platform, 'x86_64')))
if os.path.isdir(x86_llvm_path):
llvm_path = x86_llvm_path
elif os.path.isdir(x64_llvm_path):
llvm_path = x64_llvm_path
else:
print 'llvm toolchain not found!'
print 'path: %s or path: %s are not valid! ' % (x86_llvm_path, x64_llvm_path)
sys.exit(1)
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
cocos_root = os.path.abspath(os.path.join(project_root, ''))
cxx_generator_root = os.path.abspath(os.path.join(project_root, 'tools/bindings-generator'))
# save config to file
config = ConfigParser.ConfigParser()
config.set('DEFAULT', 'androidndkdir', ndk_root)
config.set('DEFAULT', 'clangllvmdir', llvm_path)
config.set('DEFAULT', 'cocosdir', cocos_root)
config.set('DEFAULT', 'cxxgeneratordir', cxx_generator_root)
config.set('DEFAULT', 'extra_flags', '')
# To fix parse error on windows, we must difine __WCHAR_MAX__ and undefine __MINGW32__ .
if platform == 'win32':
config.set('DEFAULT', 'extra_flags', '-D__WCHAR_MAX__=0x7fffffff -U__MINGW32__')
conf_ini_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'userconf.ini'))
print 'generating userconf.ini...'
with open(conf_ini_file, 'w') as configfile:
config.write(configfile)
# set proper environment variables
if 'linux' in platform or platform == 'darwin':
os.putenv('LD_LIBRARY_PATH', '%s/libclang' % cxx_generator_root)
if platform == 'win32':
path_env = os.environ['PATH']
os.putenv('PATH', r'%s;%s\libclang;%s\tools\win32;' % (path_env, cxx_generator_root, cxx_generator_root))
try:
tolua_root = '%s/tools/tolua' % project_root
output_dir = '%s/cocos/scripting/lua-bindings/auto' % project_root
cmd_args = {'cocos2dx.ini' : ('cocos2d-x', 'lua_cocos2dx_auto'), \
'cocos2dx_extension.ini' : ('cocos2dx_extension', 'lua_cocos2dx_extension_auto'), \
'cocos2dx_gui.ini' : ('cocos2dx_gui', 'lua_cocos2dx_gui_auto'), \
'cocos2dx_studio.ini' : ('cocos2dx_studio', 'lua_cocos2dx_studio_auto'), \
'cocos2dx_spine.ini' : ('cocos2dx_spine', 'lua_cocos2dx_spine_auto'), \
'cocos2dx_physics.ini' : ('cocos2dx_physics', 'lua_cocos2dx_physics_auto'), \
}
target = 'lua'
generator_py = '%s/generator.py' % cxx_generator_root
for key in cmd_args.keys():
args = cmd_args[key]
cfg = '%s/%s' % (tolua_root, key)
print 'Generating bindings for %s...' % (key[:-4])
command = '%s %s %s -s %s -t %s -o %s -n %s' % (python_bin, generator_py, cfg, args[0], target, output_dir, args[1])
_run_cmd(command)
if platform == 'win32':
with _pushd(output_dir):
_run_cmd('dos2unix *')
print '---------------------------------'
print 'Generating lua bindings succeeds.'
print '---------------------------------'
except Exception as e:
if e.__class__.__name__ == 'CmdError':
print '---------------------------------'
print 'Generating lua bindings fails.'
print '---------------------------------'
sys.exit(1)
else:
raise
# -------------- main --------------
if __name__ == '__main__':
main()

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

@ -45,7 +45,7 @@ install_nacl_sdk()
if [ "$GEN_COCOS_FILES"x = "YES"x ]; then if [ "$GEN_COCOS_FILES"x = "YES"x ]; then
exit 0 exit 0
elif [ "$GEN_JSB"x = "YES"x ]; then elif [ "$GEN_BINDING"x = "YES"x ]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
exit 0 exit 0
fi fi

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

@ -0,0 +1,129 @@
#!/bin/bash
# Generate Lua bindings for Cocos2D-X
# ... using Android NDK system headers
# ... and push these changes to remote repos
# Dependencies
#
# For bindings generator:
# (see tools/tolua/genbindings.py for the defaults used if the environment is not customized)
#
# * $PYTHON_BIN
# * $CLANG_ROOT
# * $NDK_ROOT
#
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$DIR/../.."
TOLUA_ROOT="$PROJECT_ROOT/tools/tolua"
AUTO_GENERATED_DIR="$PROJECT_ROOT/cocos/lua-bindings/auto"
COMMITTAG="[AUTO]: updating luabinding automatically"
ELAPSEDSECS=`date +%s`
COCOS_BRANCH="update_lua_bindings_$ELAPSEDSECS"
COCOS_ROBOT_REMOTE="https://${GH_USER}:${GH_PASSWORD}@github.com/${GH_USER}/cocos2d-x.git"
PULL_REQUEST_REPO="https://api.github.com/repos/cocos2d/cocos2d-x/pulls"
# Exit on error
set -e
if [ "$PLATFORM"x = "ios"x ]; then
mkdir -p $HOME/bin
pushd $HOME/bin
curl -O http://pyyaml.org/download/pyyaml/PyYAML-3.10.zip
unzip PyYAML-3.10.zip 2> /dev/null > /dev/null
cd PyYAML-3.10
sudo python setup.py install 2> /dev/null > /dev/null
cd ..
curl -O https://pypi.python.org/packages/source/C/Cheetah/Cheetah-2.4.4.tar.gz
tar xzf Cheetah-2.4.4.tar.gz
cd Cheetah-2.4.4
sudo python setup.py install 2> /dev/null > /dev/null
popd
elif [ $(command -v apt-get) ]; then
sudo apt-get --force-yes --yes install python-yaml python-cheetah
fi
generate_bindings_glue_codes()
{
echo "Create auto-generated luabinding glue codes."
pushd "$TOLUA_ROOT"
./genbindings.py
popd
}
if [ "$GEN_BINDING"x != "YES"x ]; then
generate_bindings_glue_codes
exit 0
fi
pushd "$PROJECT_ROOT"
#Set git user for cocos2d-lua repo
git config user.email ${GH_EMAIL}
git config user.name ${GH_USER}
popd
rm -rf "$AUTO_GENERATED_DIR"
mkdir "$AUTO_GENERATED_DIR"
# 1. Generate LUA bindings
generate_bindings_glue_codes
echo
echo Bindings generated successfully
echo
echo
echo Using "'$COMMITTAG'" in the commit messages
echo
echo Using "$ELAPSEDSECS" in the branch names for pseudo-uniqueness
# 2. In Bindings repo, Check if there are any files that are different from the index
pushd "$PROJECT_ROOT"
# Run status to record the output in the log
git status
echo
echo Comparing with HEAD ...
echo
# Don't exit on non-zero return value
set +e
git diff --stat --exit-code
DIFF_RETVAL=$?
if [ $DIFF_RETVAL -eq 0 ]
then
echo
echo "No differences in generated files"
echo "Exiting with success."
echo
exit 0
else
echo
echo "Generated files differ from HEAD. Continuing."
echo
fi
# Exit on error
set -e
git add -f --all "$AUTO_GENERATED_DIR"
git checkout -b "$COCOS_BRANCH"
git commit -m "$COMMITTAG"
#Set remotes
git remote add upstream "$COCOS_ROBOT_REMOTE" 2> /dev/null > /dev/null
echo "Pushing to Robot's repo ..."
git push -fq upstream "$COCOS_BRANCH" 2> /dev/null
# 7.
echo "Sending Pull Request to base repo ..."
curl --user "${GH_USER}:${GH_PASSWORD}" --request POST --data "{ \"title\": \"$COMMITTAG\", \"body\": \"\", \"head\": \"${GH_USER}:${COCOS_BRANCH}\", \"base\": \"${TRAVIS_BRANCH}\"}" "${PULL_REQUEST_REPO}" 2> /dev/null > /dev/null
popd

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

@ -13,8 +13,31 @@ if [ -z "$PYTHON_BIN" ]; then
export PYTHON_BIN=/usr/bin/python export PYTHON_BIN=/usr/bin/python
fi fi
if [ "$GEN_BINDING"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 1
fi
if [ -z "${GH_USER}" ]; then
echo "GH_USER not set"
exit 1
fi
if [ -z "${GH_PASSWORD}" ]; then
echo "GH_USER not set"
exit 1
fi
if [ "$GEN_COCOS_FILES"x = "YES"x ]; then cd $COCOS2DX_ROOT/tools/travis-scripts
./generate-bindings.sh
elif [ "$GEN_COCOS_FILES"x = "YES"x ]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
exit 0 exit 0
fi fi
@ -39,6 +62,7 @@ elif [ "$PLATFORM"x = "android"x ]; then
# Generate binding glue codes # Generate binding glue codes
echo "Generating bindings glue codes ..." echo "Generating bindings glue codes ..."
cd $COCOS2DX_ROOT/tools/travis-scripts cd $COCOS2DX_ROOT/tools/travis-scripts
./generate-bindings.sh
./generate-cocosfiles.sh ./generate-cocosfiles.sh
cd $COCOS2DX_ROOT cd $COCOS2DX_ROOT
@ -66,6 +90,7 @@ elif [ "$PLATFORM"x = "linux"x ]; then
# Generate binding glue codes # Generate binding glue codes
echo "Generating bindings glue codes ..." echo "Generating bindings glue codes ..."
cd $COCOS2DX_ROOT/tools/travis-scripts cd $COCOS2DX_ROOT/tools/travis-scripts
./generate-bindings.sh
./generate-cocosfiles.sh ./generate-cocosfiles.sh
echo "Building cocos2d-x" echo "Building cocos2d-x"
@ -79,6 +104,7 @@ elif [ "$PLATFORM"x = "emscripten"x ]; then
# Generate binding glue codes # Generate binding glue codes
echo "Generating bindings glue codes ..." echo "Generating bindings glue codes ..."
cd $COCOS2DX_ROOT/tools/travis-scripts cd $COCOS2DX_ROOT/tools/travis-scripts
./generate-bindings.sh
./generate-cocosfiles.sh ./generate-cocosfiles.sh
cd $COCOS2DX_ROOT/build cd $COCOS2DX_ROOT/build
@ -88,6 +114,7 @@ elif [ "$PLATFORM"x = "emscripten"x ]; then
EMCC_DEBUG=1 make PLATFORM=emscripten -j 8 EMCC_DEBUG=1 make PLATFORM=emscripten -j 8
elif [ "$PLATFORM"x = "ios"x ]; then elif [ "$PLATFORM"x = "ios"x ]; then
cd $COCOS2DX_ROOT/tools/travis-scripts cd $COCOS2DX_ROOT/tools/travis-scripts
./generate-bindings.sh
./generate-cocosfiles.sh ./generate-cocosfiles.sh
cd $COCOS2DX_ROOT cd $COCOS2DX_ROOT