from conan import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps import shutil import os class LsStdConan(ConanFile): name = "ls-std" version = "2024.1.0.1" license = "LGPL" url = "" description = "This library complements the C++ standard library by offering functionalities for game design - e.g. simple file handling, serialization, reflection and many more. This library is cross-platform and works on MacOS, Windows, Linux, Android & iOS." topics = ("boxing", "core", "encoding", "event", "io", "logic", "time") settings = "os", "compiler", "build_type", "arch" options = {"shared": [True, False]} default_options = {"shared": False} def source(self): self.run("git clone https://vcs.lynarstudios.de/public/ls-standard-library.git --branch v" + self.version + " --single-branch .") def layout(self): self.folders.source = "ls-standard-library" self.folders.build = "build" self.folders.generators = "build/generators" def build(self): cmake = CMake(self) cmake.configure() cmake.build() def package(self): include_src = os.path.join(self.source_folder, "include") include_dst = os.path.join(self.package_folder, "include") shutil.copytree(include_src, include_dst, dirs_exist_ok=True) build_lib_src = os.path.join(self.build_folder) if self.settings.compiler == "msvc": build_lib_src = build_lib_src + "\\" + str(self.settings.build_type) print("Build binary source: " + build_lib_src) lib_dst = os.path.join(self.package_folder, "lib") os.makedirs(lib_dst, exist_ok=True) print("build binary destination: " + lib_dst) for file in os.listdir(build_lib_src): if file.endswith((".a", ".so", ".dll", ".lib", ".dylib")) and not file.startswith("cli"): shutil.copy(os.path.join(build_lib_src, file), lib_dst) def package_info(self): if self.settings.build_type == "Release": self.cpp_info.libs = ["ls-std-boxing", "ls-std-core", "ls-std-encoding", "ls-std-event", "ls-std-io", "ls-std-time"] if self.settings.build_type == "Debug": self.cpp_info.libs = ["ls-std-boxing-d", "ls-std-core-d", "ls-std-encoding-d", "ls-std-event-d", "ls-std-io-d", "ls-std-time-d"] self.cpp_info.set_property("cmake_file_name", "ls-std") self.cpp_info.set_property("cmake_target_name", "ls-std") for lib in self.cpp_info.libs: component = self.cpp_info.components[lib] component.libs = [lib] component.set_property("cmake_target_name", f"ls-std::{lib}") def generate(self): tool_chain = CMakeToolchain(self) tool_chain.variables["CMAKE_BUILD_TYPE"] = "Release" if self.options.shared: tool_chain.variables['LS_STD_BUILD_STATIC'] = "OFF" tool_chain.variables['LS_STD_BUILD_SHARED'] = "ON" tool_chain.generate() deps = CMakeDeps(self) deps.generate()