From 905087f7b96a84ba0a3e53ac268b9a816d3909e5 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 8 Feb 2020 10:22:18 +0100 Subject: [PATCH] Support for deploying to Conan. --- .drone.yml | 16 ++++++++++ conanfile.py | 20 +++++++----- .../AngelScript/AngelScriptScript.hpp | 32 +++++++++---------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.drone.yml b/.drone.yml index cc21d9d..047b88a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -69,3 +69,19 @@ steps: - cp /drone/src/build-release-windows/lib/libpkmnLib.so /drone/src/build-release-windows/bin/ - export WINEARCH=win64 - wine build-release-windows/bin/pkmnLibTests.exe -s + - name: conan-deploy + image: deukhoofd/linux64builder + environment: + CONAN_LOGIN_USERNAME: + from_secret: conan_username + CONAN_PASSWORD: + from_secret: conan_password + commands: + - rm -rf build-debug + - rm -rf build-release-windows + - cmake -DCMAKE_BUILD_TYPE=Release . -B build-conan -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=clang++ -DWINDOWS=0 + - conan export-pkg . $DRONE_COMMIT@pkmnlib/$DRONE_BRANCH --build-folder build-conan -s compiler='clang' -s compiler.version=8 -s compiler.libcxx='libstdc++11' + - conan remote add epsilon-public https://packages.p-epsilon.com/artifactory/api/conan/epsilon-public + - conan user -p -r=epsilon-public + - conan upload PkmnLib/$DRONE_COMMIT@pkmnlib/$DRONE_BRANCH --all -r=epsilon-public + - conan user --clean \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 39e5191..e298c41 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,8 +5,8 @@ from conans.errors import ConanInvalidConfiguration class PkmnLibConan(ConanFile): name = "PkmnLib" license = "TODO" - url = "https://git.p-epsilon.com/Deukhoofd/CreatureLib" - description = "The core implementation for turn based battling using creatures." + url = "https://git.p-epsilon.com/Deukhoofd/PkmnLib" + description = "An implementation of CreatureLib to handle Pokemon battling." settings = "os", "compiler", "build_type" options = {"shared": [True, False], "script_handler": ["angelscript"]} default_options = {"shared": True, "script_handler": "angelscript"} @@ -16,21 +16,25 @@ class PkmnLibConan(ConanFile): def build(self): cmake = CMake(self) + self.output.info("Target OS: %s." % self.settings.os) + if self.settings.os == "Windows": + self.output.warn("Noticed Windows target, setting Cmake WINDOWS=On.") + cmake.definitions["WINDOWS"] = "On" cmake.configure() cmake.build() def package(self): self.copy("*.hpp", dst="include", src="src") - self.copy("*.h", dst="include", src="src") - self.copy("*.lib", dst="lib", keep_path=False) self.copy("*.dll", dst="bin", keep_path=False) - self.copy("*.dylib*", dst="lib", keep_path=False) self.copy("*.so", dst="lib", keep_path=False) - self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["libpkmnLib"] + def imports(self): - if self.settings.os == "Windows": - self.copy("*.dll", "bin", "bin") + if self.settings.os == "Windows": + self.copy("*.dll", "bin", "bin") def configure(self): diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 7e01a2c..cd9c817 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -29,7 +29,7 @@ public: ContextPool* GetContextPool() { return _ctxPool; } -#define CALLHOOK(name, setup) \ +#define CALL_HOOK(name, setup) \ auto s = _type->Get##name(); \ if (!s.Exists) \ return; \ @@ -54,9 +54,9 @@ public: ctx->PopState(); \ } - void Stack() override { CALLHOOK(Stack, ); } + void Stack() override { CALL_HOOK(Stack, ); } - void OnRemove() override { CALLHOOK(OnRemove, ); } + void OnRemove() override { CALL_HOOK(OnRemove, ); } void OnBeforeTurn(const CreatureLib::Battling::BaseTurnChoice* choice) override { throw NotImplementedException(); // TODO @@ -67,33 +67,33 @@ public: } void PreventAttack(CreatureLib::Battling::ExecutingAttack* attack, bool* outResult) override { - CALLHOOK(PreventAttack, { + CALL_HOOK(PreventAttack, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgAddress(1, outResult); }) } void FailAttack(CreatureLib::Battling::ExecutingAttack* attack, bool* outFailed) override { - CALLHOOK(FailAttack, { + CALL_HOOK(FailAttack, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgAddress(1, outFailed); }) } void StopBeforeAttack(CreatureLib::Battling::ExecutingAttack* attack, bool* outResult) override { - CALLHOOK(StopBeforeAttack, { + CALL_HOOK(StopBeforeAttack, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgAddress(1, outResult); }) } void OnBeforeAttack(CreatureLib::Battling::ExecutingAttack* attack) override { - CALLHOOK(OnBeforeAttack, { ctx->SetArgObject(0, (void*)attack); }) + CALL_HOOK(OnBeforeAttack, { ctx->SetArgObject(0, (void*)attack); }) } void FailIncomingAttack(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, bool* outResult) override { - CALLHOOK(FailIncomingAttack, { + CALL_HOOK(FailIncomingAttack, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); ctx->SetArgAddress(2, outResult); @@ -101,7 +101,7 @@ public: } void IsInvulnerable(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, bool* outResult) override { - CALLHOOK(IsInvulnerable, { + CALL_HOOK(IsInvulnerable, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); ctx->SetArgAddress(2, outResult); @@ -109,7 +109,7 @@ public: } void OnAttackMiss(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target) override { - CALLHOOK(OnAttackMiss, { + CALL_HOOK(OnAttackMiss, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); }) @@ -117,7 +117,7 @@ public: void ChangeAttackType(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitNumber, uint8_t* outType) override { - CALLHOOK(ChangeAttackType, { + CALL_HOOK(ChangeAttackType, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); ctx->SetArgByte(2, hitNumber); @@ -127,7 +127,7 @@ public: void OnStatusMove(const CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitNumber) override { - CALLHOOK(OnStatusMove, { + CALL_HOOK(OnStatusMove, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); ctx->SetArgByte(2, hitNumber); @@ -136,7 +136,7 @@ public: void PreventSecondaryEffects(const CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitNumber, bool* outResult) override { - CALLHOOK(PreventSecondaryEffects, { + CALL_HOOK(PreventSecondaryEffects, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); ctx->SetArgByte(2, hitNumber); @@ -146,7 +146,7 @@ public: void OnSecondaryEffect(const CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitNumber) override { - CALLHOOK(OnSecondaryEffect, { + CALL_HOOK(OnSecondaryEffect, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); ctx->SetArgByte(2, hitNumber); @@ -155,7 +155,7 @@ public: void OnAfterHits(const CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target) override { - CALLHOOK(OnAfterHits, { + CALL_HOOK(OnAfterHits, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); }) @@ -166,5 +166,5 @@ public: } }; -#undef CALLHOOK +#undef CALL_HOOK #endif // PKMNLIB_ANGELSCRIPTSCRIPT_HPP