Remove pthread dependency by default, adds ability to turn off angelscript debugger
This commit is contained in:
parent
b438e36a63
commit
c960f3fa0b
|
@ -52,8 +52,10 @@ export uint8_t PkmnLib_AngelScriptResolver_RegisterGlobalMethod(AngelScriptResol
|
||||||
}
|
}
|
||||||
export void PkmnLib_AngelScriptResolver_DefineWord(AngelScriptResolver* p, const char* word) { p->DefineWord(word); }
|
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) {
|
export void PkmnLib_AngelScriptResolver_AddDebugger(AngelScriptResolver* p, u16 port) {
|
||||||
auto* d = new AngelscriptDebugger();
|
auto* d = new AngelscriptDebugger();
|
||||||
d->Run(port);
|
d->Run(port);
|
||||||
p->SetDebugger(d);
|
p->SetDebugger(d);
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -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(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(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(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(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")
|
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"
|
"extern/angelscript_addons/*.h"
|
||||||
"CInterface/AngelScript/*.cpp"
|
"CInterface/AngelScript/*.cpp"
|
||||||
"CInterface/AngelScript/*.hpp"
|
"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)
|
ADD_DEFINITIONS(-D AS_USE_ACCESSORS=1)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -173,6 +176,9 @@ if (SCRIPT_PROVIDER STREQUAL "angelscript")
|
||||||
ADD_DEFINITIONS(-D ANGELSCRIPT=1)
|
ADD_DEFINITIONS(-D ANGELSCRIPT=1)
|
||||||
SET(_LINKS ${_LINKS} angelscript)
|
SET(_LINKS ${_LINKS} angelscript)
|
||||||
SET(_TESTLINKS ${_TESTLINKS} angelscript)
|
SET(_TESTLINKS ${_TESTLINKS} angelscript)
|
||||||
|
if (ANGELSCRIPT_DEBUGGER)
|
||||||
|
ADD_DEFINITIONS(-D ANGELSCRIPT_DEBUGGER=1)
|
||||||
|
endif()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# If we are building for Windows we need to set some specific variables.
|
# If we are building for Windows we need to set some specific variables.
|
||||||
|
@ -186,8 +192,8 @@ if (WINDOWS)
|
||||||
if (SHARED)
|
if (SHARED)
|
||||||
set_target_properties(pkmnLib PROPERTIES SUFFIX ".dll")
|
set_target_properties(pkmnLib PROPERTIES SUFFIX ".dll")
|
||||||
endif (SHARED)
|
endif (SHARED)
|
||||||
set(_LINKS ${_LINKS} -Wl,-Bstatic -lws2_32 -lpthread -Wl,-Bdynamic)
|
set(_LINKS ${_LINKS} -Wl,-Bstatic -lws2_32 -Wl,-Bdynamic)
|
||||||
set(_TESTLINKS ${_TESTLINKS} -Wl,-Bstatic -lws2_32 -lpthread -Wl,-Bdynamic)
|
set(_TESTLINKS ${_TESTLINKS} -Wl,-Bstatic -lws2_32 -Wl,-Bdynamic)
|
||||||
endif (WINDOWS)
|
endif (WINDOWS)
|
||||||
|
|
||||||
if (NOT WINDOWS)
|
if (NOT WINDOWS)
|
||||||
|
@ -199,8 +205,6 @@ if (STATICC)
|
||||||
message(STATUS "Linking C library statically")
|
message(STATUS "Linking C library statically")
|
||||||
set(_LINKS ${_LINKS} -static-libstdc++ -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic)
|
set(_LINKS ${_LINKS} -static-libstdc++ -Wl,-Bstatic -lm -lgcc -lstdc++ -Wl,-Bdynamic)
|
||||||
SET(_TESTLINKS ${_TESTLINKS} -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 ()
|
endif ()
|
||||||
|
|
||||||
target_link_libraries(pkmnLib PRIVATE ${_LINKS})
|
target_link_libraries(pkmnLib PRIVATE ${_LINKS})
|
||||||
|
@ -219,4 +223,6 @@ if (PKMNLIB_TESTS)
|
||||||
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
|
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (ANGELSCRIPT_DEBUGGER)
|
||||||
include_directories(extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include)
|
include_directories(extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include)
|
||||||
|
endif()
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
#include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp>
|
#include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#ifdef ANGELSCRIPT_DEBUGGER
|
||||||
#include "../../../extern/AngelscriptDebuggerServer/src/AngelscriptDebugger.hpp"
|
#include "../../../extern/AngelscriptDebuggerServer/src/AngelscriptDebugger.hpp"
|
||||||
|
#endif
|
||||||
#include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h"
|
#include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h"
|
||||||
#include "../../Battling/Library/BattleLibrary.hpp"
|
#include "../../Battling/Library/BattleLibrary.hpp"
|
||||||
#include "AngelScriptEvolutionScript.hpp"
|
#include "AngelScriptEvolutionScript.hpp"
|
||||||
|
@ -26,7 +28,9 @@ private:
|
||||||
CScriptBuilder _builder = {};
|
CScriptBuilder _builder = {};
|
||||||
std::string _sourceDirectory = {};
|
std::string _sourceDirectory = {};
|
||||||
AngelscriptUserdata* _userData;
|
AngelscriptUserdata* _userData;
|
||||||
|
#ifdef ANGELSCRIPT_DEBUGGER
|
||||||
ArbUt::OptionalUniquePtr<AngelscriptDebugger> _debugger;
|
ArbUt::OptionalUniquePtr<AngelscriptDebugger> _debugger;
|
||||||
|
#endif
|
||||||
|
|
||||||
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> _typeDatabase;
|
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> _typeDatabase;
|
||||||
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _baseTypes;
|
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _baseTypes;
|
||||||
|
@ -113,8 +117,10 @@ public:
|
||||||
|
|
||||||
inline asIScriptEngine* GetEngine() const noexcept { return _engine; }
|
inline asIScriptEngine* GetEngine() const noexcept { return _engine; }
|
||||||
inline AngelscriptUserdata* GetUserdata() const noexcept { return _userData; }
|
inline AngelscriptUserdata* GetUserdata() const noexcept { return _userData; }
|
||||||
|
#ifdef ANGELSCRIPT_DEBUGGER
|
||||||
inline ArbUt::OptionalBorrowedPtr<AngelscriptDebugger> GetDebugger() const noexcept { return _debugger.GetValue(); }
|
inline ArbUt::OptionalBorrowedPtr<AngelscriptDebugger> GetDebugger() const noexcept { return _debugger.GetValue(); }
|
||||||
inline void SetDebugger(AngelscriptDebugger* debugger) noexcept { _debugger = debugger; }
|
inline void SetDebugger(AngelscriptDebugger* debugger) noexcept { _debugger = debugger; }
|
||||||
|
#endif
|
||||||
|
|
||||||
asITypeInfo* GetScriptOwnerType(ScriptCategory category) {
|
asITypeInfo* GetScriptOwnerType(ScriptCategory category) {
|
||||||
auto tryget = _scriptOwnerTypes.TryGet(category);
|
auto tryget = _scriptOwnerTypes.TryGet(category);
|
||||||
|
|
|
@ -53,9 +53,11 @@ public:
|
||||||
ctx = _resolver->GetEngine()->CreateContext();
|
ctx = _resolver->GetEngine()->CreateContext();
|
||||||
ctx->SetUserData(_userData);
|
ctx->SetUserData(_userData);
|
||||||
}
|
}
|
||||||
|
#ifdef ANGELSCRIPT_DEBUGGER
|
||||||
if (_resolver->GetDebugger().HasValue()) {
|
if (_resolver->GetDebugger().HasValue()) {
|
||||||
_resolver->GetDebugger().GetValue()->RegisterContext(ctx);
|
_resolver->GetDebugger().GetValue()->RegisterContext(ctx);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue