1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

add option to compile AI code into libvcmi directly

- used on Android by default
- AI sources and libs are propagated to upper level with set(... PARENT_SCOPE)
This commit is contained in:
Andrey Filipenkov
2023-02-26 10:39:36 +03:00
parent 8d2064cbfe
commit 4c19d8794d
12 changed files with 71 additions and 53 deletions

View File

@@ -13,29 +13,27 @@
#include "CStack.h"
#include "VCMIDirs.h"
#ifdef VCMI_WINDOWS
#include <windows.h> //for .dll libs
#elif !defined VCMI_ANDROID
#include <dlfcn.h>
#endif
#include "serializer/BinaryDeserializer.h"
#include "serializer/BinarySerializer.h"
#ifdef VCMI_ANDROID
#include "AI/VCAI/VCAI.h"
#include "AI/Nullkiller/AIGateway.h"
#include "AI/BattleAI/BattleAI.h"
#endif
#ifdef STATIC_AI
# include "AI/VCAI/VCAI.h"
# include "AI/Nullkiller/AIGateway.h"
# include "AI/BattleAI/BattleAI.h"
#else
# ifdef VCMI_WINDOWS
# include <windows.h> //for .dll libs
# else
# include <dlfcn.h>
# endif // VCMI_WINDOWS
#endif // STATIC_AI
VCMI_LIB_NAMESPACE_BEGIN
template<typename rett>
std::shared_ptr<rett> createAny(const boost::filesystem::path & libpath, const std::string & methodName)
{
#ifdef VCMI_ANDROID
#ifdef STATIC_AI
// android currently doesn't support loading libs dynamically, so the access to the known libraries
// is possible only via specializations of this template
throw std::runtime_error("Could not resolve ai library " + libpath.generic_string());
@@ -96,10 +94,10 @@ std::shared_ptr<rett> createAny(const boost::filesystem::path & libpath, const s
logGlobal->error("Cannot get AI!");
return ret;
#endif //!VCMI_ANDROID
#endif // STATIC_AI
}
#ifdef VCMI_ANDROID
#ifdef STATIC_AI
template<>
std::shared_ptr<CGlobalAI> createAny(const boost::filesystem::path & libpath, const std::string & methodName)
@@ -118,7 +116,7 @@ std::shared_ptr<CBattleGameInterface> createAny(const boost::filesystem::path &
return std::make_shared<CBattleAI>();
}
#endif
#endif // STATIC_AI
template<typename rett>
std::shared_ptr<rett> createAnyAI(std::string dllname, const std::string & methodName)