Remove pthread dependency by default, adds ability to turn off angelscript debugger
continuous-integration/drone/push Build is failing Details
continuous-integration/drone Build is failing Details

This commit is contained in:
Deukhoofd 2022-02-05 17:48:47 +01:00
parent b438e36a63
commit c960f3fa0b
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 23 additions and 7 deletions

View File

@ -52,8 +52,10 @@ export uint8_t PkmnLib_AngelScriptResolver_RegisterGlobalMethod(AngelScriptResol
}
export void PkmnLib_AngelScriptResolver_DefineWord(AngelScriptResolver* p, const char* word) { p->DefineWord(word); }
#ifdef ANGELSCRIPT_DEBUGGER
export void PkmnLib_AngelScriptResolver_AddDebugger(AngelScriptResolver* p, u16 port) {
auto* d = new AngelscriptDebugger();
d->Run(port);
p->SetDebugger(d);
}
}
#endif

View File

@ -12,6 +12,7 @@ option(WINDOWS "Whether the build target is Windows or not." OFF)
option(SHARED "Whether we should build a shared library, instead of a static one." ON)
option(PKMNLIB_TESTS "Whether the test executable should be build as well." OFF)
option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
option(ANGELSCRIPT_DEBUGGER "Include the angelscript debug server in the build." OFF)
set(SCRIPT_PROVIDER "angelscript" CACHE STRING "Which script provider to use.")
set(LEVEL_SIZE "8" CACHE STRING "Number of bits to store the level as. Can be 8")
@ -147,8 +148,10 @@ if (SCRIPT_PROVIDER STREQUAL "angelscript")
"extern/angelscript_addons/*.h"
"CInterface/AngelScript/*.cpp"
"CInterface/AngelScript/*.hpp"
"extern/AngelscriptDebuggerServer/src/*.cpp"
)
if (ANGELSCRIPT_DEBUGGER)
SET(FILE_SOURCE ${FILE_SOURCE} "extern/AngelscriptDebuggerServer/src/*.cpp")
endif()
ADD_DEFINITIONS(-D AS_USE_ACCESSORS=1)
endif ()
@ -173,6 +176,9 @@ if (SCRIPT_PROVIDER STREQUAL "angelscript")
ADD_DEFINITIONS(-D ANGELSCRIPT=1)
SET(_LINKS ${_LINKS} angelscript)
SET(_TESTLINKS ${_TESTLINKS} angelscript)
if (ANGELSCRIPT_DEBUGGER)
ADD_DEFINITIONS(-D ANGELSCRIPT_DEBUGGER=1)
endif()
endif ()
# If we are building for Windows we need to set some specific variables.
@ -186,8 +192,8 @@ if (WINDOWS)
if (SHARED)
set_target_properties(pkmnLib PROPERTIES SUFFIX ".dll")
endif (SHARED)
set(_LINKS ${_LINKS} -Wl,-Bstatic -lws2_32 -lpthread -Wl,-Bdynamic)
set(_TESTLINKS ${_TESTLINKS} -Wl,-Bstatic -lws2_32 -lpthread -Wl,-Bdynamic)
set(_LINKS ${_LINKS} -Wl,-Bstatic -lws2_32 -Wl,-Bdynamic)
set(_TESTLINKS ${_TESTLINKS} -Wl,-Bstatic -lws2_32 -Wl,-Bdynamic)
endif (WINDOWS)
if (NOT WINDOWS)
@ -199,8 +205,6 @@ if (STATICC)
message(STATUS "Linking C library statically")
set(_LINKS ${_LINKS} -static-libstdc++ -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic)
SET(_TESTLINKS ${_TESTLINKS} -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic)
else ()
SET(_LINKS ${_LINKS} -Wl,--whole-archive -Wl,--no-whole-archive)
endif ()
target_link_libraries(pkmnLib PRIVATE ${_LINKS})
@ -219,4 +223,6 @@ if (PKMNLIB_TESTS)
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
endif ()
include_directories(extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include)
if (ANGELSCRIPT_DEBUGGER)
include_directories(extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include)
endif()

View File

@ -3,7 +3,9 @@
#include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp>
#include <mutex>
#ifdef ANGELSCRIPT_DEBUGGER
#include "../../../extern/AngelscriptDebuggerServer/src/AngelscriptDebugger.hpp"
#endif
#include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h"
#include "../../Battling/Library/BattleLibrary.hpp"
#include "AngelScriptEvolutionScript.hpp"
@ -26,7 +28,9 @@ private:
CScriptBuilder _builder = {};
std::string _sourceDirectory = {};
AngelscriptUserdata* _userData;
#ifdef ANGELSCRIPT_DEBUGGER
ArbUt::OptionalUniquePtr<AngelscriptDebugger> _debugger;
#endif
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> _typeDatabase;
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _baseTypes;
@ -113,8 +117,10 @@ public:
inline asIScriptEngine* GetEngine() const noexcept { return _engine; }
inline AngelscriptUserdata* GetUserdata() const noexcept { return _userData; }
#ifdef ANGELSCRIPT_DEBUGGER
inline ArbUt::OptionalBorrowedPtr<AngelscriptDebugger> GetDebugger() const noexcept { return _debugger.GetValue(); }
inline void SetDebugger(AngelscriptDebugger* debugger) noexcept { _debugger = debugger; }
#endif
asITypeInfo* GetScriptOwnerType(ScriptCategory category) {
auto tryget = _scriptOwnerTypes.TryGet(category);

View File

@ -53,9 +53,11 @@ public:
ctx = _resolver->GetEngine()->CreateContext();
ctx->SetUserData(_userData);
}
#ifdef ANGELSCRIPT_DEBUGGER
if (_resolver->GetDebugger().HasValue()) {
_resolver->GetDebugger().GetValue()->RegisterContext(ctx);
}
#endif
return ctx;
}