Remove dynamic loading of AI and scripting modules

Now instead of having AI and scripting as separate .dll/.so that is
dynamically loaded on requests, these components are part of VCMI
library directly. This removes need of custom code for Android/iOS where
dynamic loading is blocked as well removes multiple issues on desktop
platforms

Changes:
- Added libFacade module that actually generates libvcmi.so and has all
librrary components as its dependencies to resolve circular dependencies
- All library components are now OBJECT libraries (and not dynamic or
static libraries). Reasoning: STATIC libraries don't work due to way
linker walks through compiled units, and DYNAMIC would work, but would
keep overhead from inability to inline functions from library.
- Removed no longer necessary RPATH handling since here are no more AI
and scripting libraries to load
- Replaced CDynLibHandler with scaled down AIFactory class
This commit is contained in:
Ivan Savenko
2026-06-12 17:46:39 +03:00
parent 1f22ba7bcc
commit 9b9a770327
48 changed files with 336 additions and 835 deletions
+3 -10
View File
@@ -145,20 +145,13 @@ set(Nullkiller2_HEADERS
AIGateway.h
)
if(NOT ENABLE_STATIC_LIBS)
list(APPEND Nullkiller2_SRCS main.cpp StdInc.cpp)
endif()
assign_source_group(${Nullkiller2_SRCS} ${Nullkiller2_HEADERS})
if(ENABLE_STATIC_LIBS)
add_library(Nullkiller2 STATIC ${Nullkiller2_SRCS} ${Nullkiller2_HEADERS})
else()
add_library(Nullkiller2 SHARED ${Nullkiller2_SRCS} ${Nullkiller2_HEADERS})
install(TARGETS Nullkiller2 RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})
endif()
add_library(Nullkiller2 OBJECT ${Nullkiller2_SRCS} ${Nullkiller2_HEADERS})
target_compile_definitions(Nullkiller2 PRIVATE VCMI_DLL=1)
target_include_directories(Nullkiller2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(Nullkiller2 PUBLIC vcmi TBB::tbb)
target_link_libraries(Nullkiller2 PUBLIC vcmiMain TBB::tbb)
vcmi_set_output_dir(Nullkiller2 "AI")
enable_pch(Nullkiller2)
-10
View File
@@ -1,10 +0,0 @@
/*
* StdInc.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
-32
View File
@@ -1,32 +0,0 @@
/*
* main.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "AIGateway.h"
#ifdef __GNUC__
#define strcpy_s(a, b, c) strncpy(a, c, b)
#endif
static const char * const g_cszAiName = "Nullkiller2";
extern "C" DLL_EXPORT int GetGlobalAiVersion()
{
return AI_INTERFACE_VER;
}
extern "C" DLL_EXPORT void GetAiName(char * name)
{
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
}
extern "C" DLL_EXPORT void GetNewAI(std::shared_ptr<CGlobalAI> & out)
{
out = std::make_shared<NK2AI::AIGateway>();
}