From 0a30a9a6047a8b16cd66ec1211afebca2aa4f9d4 Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 16:10:15 +0900 Subject: [PATCH 1/4] spine simple JS binding supported --- .../project.pbxproj.REMOVED.git-id | 2 +- .../scripting/javascript/bindings/Android.mk | 8 +++- .../bindings/proj.win32/libJSBinding.vcxproj | 2 + .../proj.win32/libJSBinding.vcxproj.filters | 6 +++ .../multi-platform-js/Classes/AppDelegate.cpp | 2 + .../proj.android/jni/Android.mk | 2 + tools/tojs/cocos2dx_spine.ini | 40 +++++++++++++++++++ tools/tojs/genbindings.sh | 5 ++- 8 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 tools/tojs/cocos2dx_spine.ini diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index c4362e57ff..1db1126f95 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -4cd02813dfcd14b7de3ccb157cd0f25b0bce9f37 \ No newline at end of file +1458a8d0a6bab41613b44cd39a46beabb6db78a6 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/Android.mk b/cocos/scripting/javascript/bindings/Android.mk index f6e3f684a6..287a9a469b 100644 --- a/cocos/scripting/javascript/bindings/Android.mk +++ b/cocos/scripting/javascript/bindings/Android.mk @@ -14,7 +14,8 @@ LOCAL_SRC_FILES := ScriptingCore.cpp \ jsb_opengl_functions.cpp \ jsb_opengl_manual.cpp \ jsb_opengl_registration.cpp \ - ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp + ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp \ + ../../auto-generated/js-bindings/jsb_cocos2dx_spine_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT @@ -24,7 +25,10 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../audio/include \ $(LOCAL_PATH)/../../../storage \ $(LOCAL_PATH)/../../auto-generated/js-bindings \ - $(LOCAL_PATH)/../../../../extensions + $(LOCAL_PATH)/../../../../extensions \ + $(LOCAL_PATH)/../../../editor-support/spine \ + $(LOCAL_PATH)/../../../editor-support + LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../auto-generated/js-bindings \ diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index a4cbbd4d50..e959aa34a6 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -12,6 +12,7 @@ + @@ -23,6 +24,7 @@ + diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters index 85bb2eccd3..13bcceb35b 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters @@ -41,6 +41,9 @@ generated + + generated + @@ -79,6 +82,9 @@ generated + + generated + diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index e409b974b5..0794c10c9a 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -5,6 +5,7 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_spine_auto.hpp" #include "cocos2d_specifics.hpp" #include "extension/jsb_cocos2dx_extension_manual.h" #include "chipmunk/js_bindings_chipmunk_registration.h" @@ -40,6 +41,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + sc->addRegisterCallback(register_all_cocos2dx_spine); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(JSB_register_opengl); sc->addRegisterCallback(jsb_register_system); diff --git a/template/multi-platform-js/proj.android/jni/Android.mk b/template/multi-platform-js/proj.android/jni/Android.mk index 08a89b6f22..ae780817f9 100644 --- a/template/multi-platform-js/proj.android/jni/Android.mk +++ b/template/multi-platform-js/proj.android/jni/Android.mk @@ -15,6 +15,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_localstorage_static +LOCAL_WHOLE_STATIC_LIBRARIES += spine_static LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT @@ -25,3 +26,4 @@ $(call import-module,scripting/javascript/bindings) $(call import-module,scripting/javascript/bindings/extension) $(call import-module,scripting/javascript/bindings/chipmunk) $(call import-module,scripting/javascript/bindings/localstorage) +$(call import-module,editor-support/spine) diff --git a/tools/tojs/cocos2dx_spine.ini b/tools/tojs/cocos2dx_spine.ini new file mode 100644 index 0000000000..62f4ba8f6a --- /dev/null +++ b/tools/tojs/cocos2dx_spine.ini @@ -0,0 +1,40 @@ +[cocos2dx_spine] +prefix = cocos2dx_spine + +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/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/include -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 + +headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h + +skip = CCSkeleton::[createWithData], + CCSkeletonAnimation::[createWithData] + +classes = CCSkeleton CCSkeletonAnimation + +remove_prefix = CC + +classes_have_no_parents = + +base_classes_to_skip = + +abstract_classes = + +script_control_cpp = + +rename_functions = + +rename_classes = \ No newline at end of file diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index fedf3cacd5..00d2d7a8c5 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -92,4 +92,7 @@ echo "Generating bindings for cocos2dx_gui..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_gui.ini -s cocos2dx_gui -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_gui_auto echo "Generating bindings for cocos2dx_studio..." -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto \ No newline at end of file +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto + +echo "Generating bindings for cocos2dx_spine..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_spine.ini -s cocos2dx_spine -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_spine_auto \ No newline at end of file From f3e4d9277e477255004d9041969f3957930a6d53 Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 19:16:16 +0900 Subject: [PATCH 2/4] spine android build phase moved --- cocos/2d/Android.mk | 2 ++ template/multi-platform-js/proj.android/jni/Android.mk | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 9f5eba4108..cd4ec4c772 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -210,6 +210,7 @@ LOCAL_EXPORT_LDLIBS := -lGLESv2 \ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static +LOCAL_WHOLE_STATIC_LIBRARIES += spine_static # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API @@ -222,3 +223,4 @@ include $(BUILD_STATIC_LIBRARY) $(call import-module,freetype2/prebuilt/android) $(call import-module,chipmunk) $(call import-module,2d/platform/android) +$(call import-module,editor-support/spine) \ No newline at end of file diff --git a/template/multi-platform-js/proj.android/jni/Android.mk b/template/multi-platform-js/proj.android/jni/Android.mk index ae780817f9..48746a0ffc 100644 --- a/template/multi-platform-js/proj.android/jni/Android.mk +++ b/template/multi-platform-js/proj.android/jni/Android.mk @@ -15,7 +15,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_localstorage_static -LOCAL_WHOLE_STATIC_LIBRARIES += spine_static LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT @@ -25,5 +24,4 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,scripting/javascript/bindings) $(call import-module,scripting/javascript/bindings/extension) $(call import-module,scripting/javascript/bindings/chipmunk) -$(call import-module,scripting/javascript/bindings/localstorage) -$(call import-module,editor-support/spine) +$(call import-module,scripting/javascript/bindings/localstorage) \ No newline at end of file From ef1709bc3ddee443310ccaa26a0e149c337bd7df Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 19:20:13 +0900 Subject: [PATCH 3/4] Add SpineTest to TestJavascript 1 --- build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- samples/Javascript/TestJavascript/Classes/AppDelegate.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index e83c9c8ec4..fe8529d970 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -52a991e88e049cd371a153ee168260276a7ac664 \ No newline at end of file +4b95c782427340850fcd34136156544774b2effd \ No newline at end of file diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index a85f0939c7..0da7de9714 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -8,6 +8,7 @@ #include "jsb_cocos2dx_builder_auto.hpp" #include "jsb_cocos2dx_studio_auto.hpp" #include "jsb_cocos2dx_gui_auto.hpp" +#include "jsb_cocos2dx_spine_auto.hpp" #include "extension/jsb_cocos2dx_extension_manual.h" #include "cocostudio/jsb_cocos2dx_studio_manual.h" #include "gui/jsb_cocos2dx_gui_manual.h" @@ -70,6 +71,8 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_studio); sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + sc->addRegisterCallback(register_all_cocos2dx_spine); + sc->start(); #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) From d5ea2d22a5980373bba249c8b28121623f43d821 Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 19:45:50 +0900 Subject: [PATCH 4/4] undo my mistake --- build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index fe8529d970..e83c9c8ec4 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -4b95c782427340850fcd34136156544774b2effd \ No newline at end of file +52a991e88e049cd371a153ee168260276a7ac664 \ No newline at end of file