From 9e6b360437826688847f5e64b0f752f47e713f79 Mon Sep 17 00:00:00 2001 From: halx99 Date: Mon, 19 Oct 2020 23:21:40 +0800 Subject: [PATCH] fix lua build link on android --- .../WidgetCallBackHandlerProtocol.cpp | 9 +++++++++ .../libeditor/WidgetCallBackHandlerProtocol.h | 3 +-- .../WidgetReader/NodeReaderProtocol.cpp | 8 ++++++++ .../WidgetReader/NodeReaderProtocol.h | 6 +++--- .../WidgetReader/WidgetReaderProtocol.cpp | 8 ++++++++ .../WidgetReader/WidgetReaderProtocol.h | 6 +++--- .../scripting/lua-bindings/CMakeLists.txt | 20 +++++++++---------- .../lua-bindings/proj.android/CMakeLists.txt | 2 +- templates/cpp-template-default/CMakeLists.txt | 1 + templates/lua-template-default/CMakeLists.txt | 1 + .../runtime-src/Classes/AppDelegate.cpp | 3 +-- tests/cpp-tests/CMakeLists.txt | 1 + tests/fairygui-tests/CMakeLists.txt | 1 + tests/lua-tests/project/CMakeLists.txt | 1 + 14 files changed, 49 insertions(+), 21 deletions(-) create mode 100644 extensions/libeditor/WidgetCallBackHandlerProtocol.cpp create mode 100644 extensions/libeditor/WidgetReader/WidgetReaderProtocol.cpp diff --git a/extensions/libeditor/WidgetCallBackHandlerProtocol.cpp b/extensions/libeditor/WidgetCallBackHandlerProtocol.cpp new file mode 100644 index 0000000000..c9f24cf52f --- /dev/null +++ b/extensions/libeditor/WidgetCallBackHandlerProtocol.cpp @@ -0,0 +1,9 @@ + +#include "libeditor/WidgetCallBackHandlerProtocol.h" + +namespace cocostudio { + WidgetCallBackHandlerProtocol::~WidgetCallBackHandlerProtocol(){} + cocos2d::ui::Widget::ccWidgetTouchCallback WidgetCallBackHandlerProtocol::onLocateTouchCallback(const std::string& callBackName){} + cocos2d::ui::Widget::ccWidgetClickCallback WidgetCallBackHandlerProtocol::onLocateClickCallback(const std::string& callBackName){} + cocos2d::ui::Widget::ccWidgetEventCallback WidgetCallBackHandlerProtocol::onLocateEventCallback(const std::string& callBackName){} +} diff --git a/extensions/libeditor/WidgetCallBackHandlerProtocol.h b/extensions/libeditor/WidgetCallBackHandlerProtocol.h index 53471eaf66..e8717be774 100644 --- a/extensions/libeditor/WidgetCallBackHandlerProtocol.h +++ b/extensions/libeditor/WidgetCallBackHandlerProtocol.h @@ -34,8 +34,7 @@ namespace cocostudio { class CCS_DLL WidgetCallBackHandlerProtocol { public: - WidgetCallBackHandlerProtocol() {}; - virtual ~WidgetCallBackHandlerProtocol() {}; + virtual ~WidgetCallBackHandlerProtocol(); virtual cocos2d::ui::Widget::ccWidgetTouchCallback onLocateTouchCallback(const std::string& callBackName); virtual cocos2d::ui::Widget::ccWidgetClickCallback onLocateClickCallback(const std::string& callBackName); diff --git a/extensions/libeditor/WidgetReader/NodeReaderProtocol.cpp b/extensions/libeditor/WidgetReader/NodeReaderProtocol.cpp index 4faee52add..03fbfebff3 100644 --- a/extensions/libeditor/WidgetReader/NodeReaderProtocol.cpp +++ b/extensions/libeditor/WidgetReader/NodeReaderProtocol.cpp @@ -42,6 +42,14 @@ static void onLoadSpriteFramesWithFileDummy(std::string&) { } +namespace cocostudio +{ + NodeReaderProtocol::NodeReaderProtocol() {}; + NodeReaderProtocol::~NodeReaderProtocol() {}; + + void NodeReaderProtocol::setCurrentCustomClassName(const char* className) {}; +} + namespace cocos2d { namespace wext { bool(*onBeforeLoadObjectAsset)(cocos2d::Node*, cocos2d::ResourceData& assets, int index/*= 0*/) = &onLoadObjectAssetDummy; diff --git a/extensions/libeditor/WidgetReader/NodeReaderProtocol.h b/extensions/libeditor/WidgetReader/NodeReaderProtocol.h index 7b340b69e4..0e97e3654f 100644 --- a/extensions/libeditor/WidgetReader/NodeReaderProtocol.h +++ b/extensions/libeditor/WidgetReader/NodeReaderProtocol.h @@ -75,10 +75,10 @@ namespace cocostudio class CCS_DLL NodeReaderProtocol { public: - NodeReaderProtocol() {}; - virtual ~NodeReaderProtocol() {}; + NodeReaderProtocol(); + virtual ~NodeReaderProtocol(); - virtual void setCurrentCustomClassName(const char* className) {}; + virtual void setCurrentCustomClassName(const char* className); virtual flatbuffers::Offset createOptionsWithFlatBuffers(pugi::xml_node objectData, flatbuffers::FlatBufferBuilder* builder) = 0; virtual void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* nodeOptions) = 0; diff --git a/extensions/libeditor/WidgetReader/WidgetReaderProtocol.cpp b/extensions/libeditor/WidgetReader/WidgetReaderProtocol.cpp new file mode 100644 index 0000000000..48c5bf3a49 --- /dev/null +++ b/extensions/libeditor/WidgetReader/WidgetReaderProtocol.cpp @@ -0,0 +1,8 @@ +#include "libeditor/WidgetReader/WidgetReaderProtocol.h" + +namespace cocostudio +{ + WidgetReaderProtocol::~WidgetReaderProtocol(){} + void WidgetReaderProtocol::setPropsFromProtocolBuffers(cocos2d::ui::Widget* widget, const protocolbuffers::NodeTree& nodeTree){} + void WidgetReaderProtocol::setPropsFromXML(cocos2d::ui::Widget* widget, pugi::xml_node objectData){} +} diff --git a/extensions/libeditor/WidgetReader/WidgetReaderProtocol.h b/extensions/libeditor/WidgetReader/WidgetReaderProtocol.h index 877f844d87..b05ec7f736 100644 --- a/extensions/libeditor/WidgetReader/WidgetReaderProtocol.h +++ b/extensions/libeditor/WidgetReader/WidgetReaderProtocol.h @@ -55,11 +55,11 @@ namespace cocostudio class CCS_DLL WidgetReaderProtocol { public: - virtual ~WidgetReaderProtocol() {}; + virtual ~WidgetReaderProtocol(); virtual void setPropsFromJsonDictionary(cocos2d::ui::Widget* widget, const rapidjson::Value& options) = 0; virtual void setPropsFromBinary(cocos2d::ui::Widget* widget, CocoLoader* cocoLoader, stExpCocoNode* pCocoNode) = 0; - virtual void setPropsFromProtocolBuffers(cocos2d::ui::Widget* widget, const protocolbuffers::NodeTree& nodeTree){}; // cocos2d-x-3.3rc1@libccs19 spec - virtual void setPropsFromXML(cocos2d::ui::Widget* widget, pugi::xml_node objectData){}; // cocos2d-x-3.3rc1@libccs19 spec + virtual void setPropsFromProtocolBuffers(cocos2d::ui::Widget* widget, const protocolbuffers::NodeTree& nodeTree); // cocos2d-x-3.3rc1@libccs19 spec + virtual void setPropsFromXML(cocos2d::ui::Widget* widget, pugi::xml_node objectData); // cocos2d-x-3.3rc1@libccs19 spec }; } diff --git a/extensions/scripting/lua-bindings/CMakeLists.txt b/extensions/scripting/lua-bindings/CMakeLists.txt index 421bbb8534..86eb1af970 100644 --- a/extensions/scripting/lua-bindings/CMakeLists.txt +++ b/extensions/scripting/lua-bindings/CMakeLists.txt @@ -137,16 +137,6 @@ elseif(ANDROID) ) endif() -option(BUILD_YASIO_LUA "Build yasio with cclua support" ON) - -if(BUILD_YASIO_LUA) - set(lua_bindings_files - ${lua_bindings_files} - ${cocos_root}/external/yasio/bindings/lyasio.cpp - ${cocos_root}/external/yasio/bindings/yasio_cclua.cpp) - -endif() - set(lua_bindings_files ${lua_bindings_manual_files} ${lua_bindings_auto_files} @@ -158,6 +148,16 @@ set(lua_bindings_headers ${COCOS_DEPRECATED_HEADER} ) +option(BUILD_YASIO_LUA "Build yasio with cclua support" ON) + +if(BUILD_YASIO_LUA) + message(STATUS "BUILD_YASIO_LUA=${BUILD_YASIO_LUA}") + set(lua_bindings_files + ${lua_bindings_files} + "${cocos_root}/external/yasio/bindings/lyasio.cpp" + "${cocos_root}/external/yasio/bindings/yasio_cclua.cpp") +endif() + list(APPEND lua_bindings_files ${lua_bindings_headers}) set(EGNX_LUA_LIB luacocos2d CACHE INTERNAL "The EGNX lua bindings lib name" ) diff --git a/extensions/scripting/lua-bindings/proj.android/CMakeLists.txt b/extensions/scripting/lua-bindings/proj.android/CMakeLists.txt index e8884f0abd..3556f5388f 100644 --- a/extensions/scripting/lua-bindings/proj.android/CMakeLists.txt +++ b/extensions/scripting/lua-bindings/proj.android/CMakeLists.txt @@ -14,7 +14,7 @@ add_library(${target_name} STATIC ${${target_name}_src} ) -get_target_property(lua_header ext_luajit INTERFACE_INCLUDE_DIRECTORIES) +get_target_property(lua_header ${LUA_ENGINE} INTERFACE_INCLUDE_DIRECTORIES) get_target_property(tolua_header tolua INTERFACE_INCLUDE_DIRECTORIES) target_include_directories(${target_name} PRIVATE ../../.. diff --git a/templates/cpp-template-default/CMakeLists.txt b/templates/cpp-template-default/CMakeLists.txt index 5cfee02e45..bef3abf9b1 100644 --- a/templates/cpp-template-default/CMakeLists.txt +++ b/templates/cpp-template-default/CMakeLists.txt @@ -39,6 +39,7 @@ if(NOT DEFINED BUILD_ENGINE_DONE) # to test HelloCpp into root project if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + string(REPLACE "\\" "/" COCOS2DX_ROOT_PATH ${COCOS2DX_ROOT_PATH}) else() message(FATAL_ERROR "Please add system env var 'COCOS2DX_ROOT' to specific the engine root") endif() diff --git a/templates/lua-template-default/CMakeLists.txt b/templates/lua-template-default/CMakeLists.txt index c3e12978de..70abc2fe9c 100644 --- a/templates/lua-template-default/CMakeLists.txt +++ b/templates/lua-template-default/CMakeLists.txt @@ -36,6 +36,7 @@ endif() if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + string(REPLACE "\\" "/" COCOS2DX_ROOT_PATH ${COCOS2DX_ROOT_PATH}) else() message(FATAL_ERROR "Please add system env var 'COCOS2DX_ROOT' to specific the engine root") endif() diff --git a/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index c2ef1a2a5f..8065744396 100644 --- a/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -85,8 +85,7 @@ bool AppDelegate::applicationDidFinishLaunching() register_all_packages(); LuaStack* stack = engine->getLuaStack(); - stack->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA")); - + //register custom function //LuaStack* stack = engine->getLuaStack(); //register_custom_function(stack->getLuaState()); diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index b337cef18b..c2ee92c50a 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -14,6 +14,7 @@ if(NOT DEFINED BUILD_ENGINE_DONE) if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + string(REPLACE "\\" "/" COCOS2DX_ROOT_PATH ${COCOS2DX_ROOT_PATH}) else() set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) endif() diff --git a/tests/fairygui-tests/CMakeLists.txt b/tests/fairygui-tests/CMakeLists.txt index bb843b28d9..a4b80313bc 100644 --- a/tests/fairygui-tests/CMakeLists.txt +++ b/tests/fairygui-tests/CMakeLists.txt @@ -37,6 +37,7 @@ if(NOT DEFINED BUILD_ENGINE_DONE) if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + string(REPLACE "\\" "/" COCOS2DX_ROOT_PATH ${COCOS2DX_ROOT_PATH}) else() set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) endif() diff --git a/tests/lua-tests/project/CMakeLists.txt b/tests/lua-tests/project/CMakeLists.txt index d918cbf67b..39e4603669 100644 --- a/tests/lua-tests/project/CMakeLists.txt +++ b/tests/lua-tests/project/CMakeLists.txt @@ -14,6 +14,7 @@ if(NOT DEFINED BUILD_ENGINE_DONE) if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + string(REPLACE "\\" "/" COCOS2DX_ROOT_PATH ${COCOS2DX_ROOT_PATH}) else() set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../..) endif()