from conans import ConanFile, CMake from conans.errors import ConanInvalidConfiguration class PkmnLibConan(ConanFile): name = "PkmnLib" license = "TODO" 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"], "staticC": [True, False]} default_options = {"shared": True, "script_handler": "angelscript", "staticC": False} generators = "cmake" exports_sources = "*" compiler = "clang" 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" if self.options.staticC: cmake.definitions["STATICC"] = "On" cmake.configure() cmake.build() def package(self): self.copy("*.hpp", dst="include/PkmnLib", src="src") self.copy("*.h", dst="include/extern", src="extern") self.copy("*.dll", dst="bin", keep_path=False) self.copy("*.so", 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") def configure(self): if self.options.script_handler == "angelscript": self.options["AngelScript"].shared = True if self.options.staticC: self.options["AngelScript"].link_std_statically = True def requirements(self): self.requires("Arbutils/latest@epsilon/master") self.requires("CreatureLib/latest@epsilon/master") if self.options.script_handler == "angelscript": self.requires("AngelScript/2.34@AngelScript/Deukhoofd") else: raise ConanInvalidConfiguration("Invalid Script Handler was specified: " + self.options.script_handler)