diff --git a/.drone.yml b/.drone.yml index c39be32..dd9c5a4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,6 +4,10 @@ name: default type: docker steps: + - name: submodules + image: alpine/git + commands: + - git submodule update --init --recursive - name: test-debug-linux image: deukhoofd/linux64builder environment: @@ -53,6 +57,6 @@ steps: - wine64 build-release-windows/pkmnLibTests.exe -s --duration=true --force-colors=true --- kind: signature -hmac: 72d8b9f3bc34aa773df18741607d197ffaff94e6692deb55cc139715e1726755 +hmac: b3b11a98050648beb846956c73c1fccb44395297c7bac25c7f26106d0af5b46f ... diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..02bcb2d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "extern/AngelscriptDebuggerServer"] + path = extern/AngelscriptDebuggerServer + url = https://git.p-epsilon.com/Deukhoofd/AngelscriptDebuggerServer.git diff --git a/CInterface/AngelScript/AngelScriptResolver.cpp b/CInterface/AngelScript/AngelScriptResolver.cpp index df6a742..562c000 100644 --- a/CInterface/AngelScript/AngelScriptResolver.cpp +++ b/CInterface/AngelScript/AngelScriptResolver.cpp @@ -50,4 +50,10 @@ export uint8_t PkmnLib_AngelScriptResolver_RegisterGlobalMethod(AngelScriptResol void*(func)(void*)) { Try(p->RegisterGlobalMethod(decl, func);) } -export void PkmnLib_AngelScriptResolve_DefineWord(AngelScriptResolver* p, const char* word) { p->DefineWord(word); } \ No newline at end of file +export void PkmnLib_AngelScriptResolver_DefineWord(AngelScriptResolver* p, const char* word) { p->DefineWord(word); } + +export void PkmnLib_AngelScriptResolver_AddDebugger(AngelScriptResolver* p, u16 port) { + auto* d = new AngelscriptDebugger(); + d->Run(port); + p->SetDebugger(d); +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e960de1..2fea198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,7 @@ if (SCRIPT_PROVIDER STREQUAL "angelscript") "extern/angelscript_addons/*.h" "CInterface/AngelScript/*.cpp" "CInterface/AngelScript/*.hpp" + "extern/AngelscriptDebuggerServer/src/*.cpp" ) ADD_DEFINITIONS(-D AS_USE_ACCESSORS=1) endif () @@ -130,7 +131,7 @@ if (WINDOWS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-allow-multiple-definition") if (SHARED) set_target_properties(pkmnLib PROPERTIES SUFFIX ".dll") - endif(SHARED) + endif (SHARED) endif (WINDOWS) if (NOT WINDOWS) @@ -138,15 +139,15 @@ if (NOT WINDOWS) endif () if (STATICC) - set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") message(STATUS "Linking C library statically") - set(_LINKS ${_LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lm -lstdc++ -lpthread -Wl,-Bdynamic) - SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic) -else() + set(_LINKS ${_LINKS} -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic) + SET(_TESTLINKS ${_TESTLINKS} -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic) +else () SET(_LINKS ${_LINKS} -Wl,--whole-archive -lpthread -Wl,--no-whole-archive) -endif() +endif () -target_link_libraries(pkmnLib PUBLIC ${_LINKS}) +target_link_libraries(pkmnLib PRIVATE ${_LINKS}) if (TESTS) # Create Test executable @@ -162,9 +163,4 @@ if (TESTS) target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD) endif () - - - - - - +include_directories(extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include) diff --git a/CMakeLists.txt.angelscript.in b/CMakeLists.txt.angelscript.in index c229e60..b870d66 100644 --- a/CMakeLists.txt.angelscript.in +++ b/CMakeLists.txt.angelscript.in @@ -14,6 +14,7 @@ ExternalProject_Add(AngelscriptProj TEST_COMMAND "" ) + function(include_angelscript) configure_file(CMakeLists.txt.angelscript.in Angelscript/download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . diff --git a/extern/AngelscriptDebuggerServer b/extern/AngelscriptDebuggerServer new file mode 160000 index 0000000..6e99c51 --- /dev/null +++ b/extern/AngelscriptDebuggerServer @@ -0,0 +1 @@ +Subproject commit 6e99c5183e04c614ed7c5638d13115c62c9bd667 diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp index e66313e..f934216 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp @@ -121,7 +121,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg, _engine->RegisterGlobalProperty("const StaticLibrary@ StaticLib", (void*)staticLib.get()); } - _contextPool = new ContextPool(_engine, _userData); + _contextPool = new ContextPool(this, _userData); asPrepareMultithread(); } diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp index 597328d..d0af323 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp @@ -3,6 +3,7 @@ #include #include +#include "../../../extern/AngelscriptDebuggerServer/src/AngelscriptDebugger.hpp" #include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h" #include "../../Battling/Library/BattleLibrary.hpp" #include "AngelScriptEvolutionScript.hpp" @@ -24,6 +25,7 @@ private: CScriptBuilder _builder = {}; std::string _sourceDirectory = {}; AngelscriptUserdata* _userData; + ArbUt::OptionalUniquePtr _debugger; ArbUt::Dictionary> _typeDatabase; ArbUt::Dictionary _baseTypes; @@ -106,6 +108,9 @@ public: inline ContextPool* GetContextPool() const noexcept { return _contextPool; } + inline asIScriptEngine* GetEngine() const noexcept { return _engine; } inline AngelscriptUserdata* GetUserdata() const noexcept { return _userData; } + inline ArbUt::OptionalBorrowedPtr GetDebugger() const noexcept { return _debugger.GetValue(); } + inline void SetDebugger(AngelscriptDebugger* debugger) noexcept { _debugger = debugger; } }; #endif // PKMNLIB_ANGELSCRIPRESOLVER_HPP diff --git a/src/ScriptResolving/AngelScript/ContextPool.hpp b/src/ScriptResolving/AngelScript/ContextPool.hpp index f21231e..5527915 100644 --- a/src/ScriptResolving/AngelScript/ContextPool.hpp +++ b/src/ScriptResolving/AngelScript/ContextPool.hpp @@ -19,7 +19,7 @@ class ContextPool { }; ArbUt::Dictionary _pool; - asIScriptEngine* _engine; + AngelScriptResolver* _resolver; AngelscriptUserdata* _userData; CtxThreadedPoolStorage* GetThreadPool() { @@ -32,7 +32,8 @@ class ContextPool { } public: - ContextPool(asIScriptEngine* engine, AngelscriptUserdata* userData) : _engine(engine), _userData(userData) {} + ContextPool(AngelScriptResolver* resolver, AngelscriptUserdata* userData) + : _resolver(resolver), _userData(userData) {} ~ContextPool() { for (const auto& kv : _pool) { @@ -49,9 +50,12 @@ public: ctx = *pool->Pool.rbegin(); pool->Pool.pop_back(); } else { - ctx = _engine->CreateContext(); + ctx = _resolver->GetEngine()->CreateContext(); ctx->SetUserData(_userData); } + if (_resolver->GetDebugger().HasValue()) { + _resolver->GetDebugger().GetValue()->RegisterContext(ctx); + } return ctx; }