conanfile.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. from conan import ConanFile
  2. from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
  3. import shutil
  4. import os
  5. class LsStdConan(ConanFile):
  6. name = "ls-std"
  7. version = "2024.1.0.1"
  8. license = "LGPL"
  9. url = "<Package recipe repository url here, for issues about the package>"
  10. 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."
  11. topics = ("boxing", "core", "encoding", "event", "io", "logic", "time")
  12. settings = "os", "compiler", "build_type", "arch"
  13. options = {"shared": [True, False]}
  14. default_options = {"shared": False}
  15. def source(self):
  16. self.run("git clone https://vcs.lynarstudios.de/public/ls-standard-library.git --branch v" + self.version +
  17. " --single-branch .")
  18. def layout(self):
  19. self.folders.source = "ls-standard-library"
  20. self.folders.build = "build"
  21. self.folders.generators = "build/generators"
  22. def build(self):
  23. cmake = CMake(self)
  24. cmake.configure()
  25. cmake.build()
  26. def package(self):
  27. include_src = os.path.join(self.source_folder, "include")
  28. include_dst = os.path.join(self.package_folder, "include")
  29. shutil.copytree(include_src, include_dst, dirs_exist_ok=True)
  30. build_lib_src = os.path.join(self.build_folder)
  31. if self.settings.compiler == "msvc":
  32. build_lib_src = build_lib_src + "\\" + str(self.settings.build_type)
  33. print("Build binary source: " + build_lib_src)
  34. lib_dst = os.path.join(self.package_folder, "lib")
  35. os.makedirs(lib_dst, exist_ok=True)
  36. print("build binary destination: " + lib_dst)
  37. for file in os.listdir(build_lib_src):
  38. if file.endswith((".a", ".so", ".dll", ".lib", ".dylib")) and not file.startswith("cli"):
  39. shutil.copy(os.path.join(build_lib_src, file), lib_dst)
  40. def package_info(self):
  41. if self.settings.build_type == "Release":
  42. self.cpp_info.libs = ["ls-std-boxing", "ls-std-core", "ls-std-encoding", "ls-std-event", "ls-std-io", "ls-std-time"]
  43. if self.settings.build_type == "Debug":
  44. 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"]
  45. self.cpp_info.set_property("cmake_file_name", "ls-std")
  46. self.cpp_info.set_property("cmake_target_name", "ls-std")
  47. for lib in self.cpp_info.libs:
  48. component = self.cpp_info.components[lib]
  49. component.libs = [lib]
  50. component.set_property("cmake_target_name", f"ls-std::{lib}")
  51. def generate(self):
  52. tool_chain = CMakeToolchain(self)
  53. tool_chain.variables["CMAKE_BUILD_TYPE"] = "Release"
  54. if self.options.shared:
  55. tool_chain.variables['LS_STD_BUILD_STATIC'] = "OFF"
  56. tool_chain.variables['LS_STD_BUILD_SHARED'] = "ON"
  57. tool_chain.generate()
  58. deps = CMakeDeps(self)
  59. deps.generate()