conanfile.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import os
  2. from conan import ConanFile
  3. from conan.tools.files import copy, update_conandata
  4. from conan.tools.scm import Version
  5. from conan.errors import ConanInvalidConfiguration
  6. required_conan_version = ">=1.58.0 <2.0.0"
  7. class CuraResource(ConanFile):
  8. name = "cura_resources"
  9. license = ""
  10. author = "UltiMaker"
  11. url = "https://github.com/Ultimaker/cura"
  12. description = "Cura Resources"
  13. topics = ("conan", "cura")
  14. settings = "os", "compiler", "build_type", "arch"
  15. no_copy_source = True
  16. @property
  17. def _shared_resources(self):
  18. return ["definitions", "extruders", "images", "intent", "meshes", "quality", "variants"]
  19. def set_version(self):
  20. if not self.version:
  21. self.version = self.conan_data["version"]
  22. def export(self):
  23. copy(self, pattern="conandata.yml", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder,
  24. keep_path=False)
  25. copy(self, pattern="LICENSE*", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder,
  26. keep_path=False)
  27. update_conandata(self, {"version": self.version})
  28. def export_sources(self):
  29. for shared_resources in self._shared_resources:
  30. copy(self, pattern="*", src=os.path.join(self.recipe_folder, shared_resources),
  31. dst=os.path.join(self.export_sources_folder, shared_resources))
  32. def validate(self):
  33. if Version(self.version) <= Version("4"):
  34. raise ConanInvalidConfiguration("Only versions 5+ are support")
  35. def layout(self):
  36. self.cpp.source.resdirs = self._shared_resources
  37. self.cpp.package.resdirs = [f"res/{res}" for res in self._shared_resources]
  38. def package(self):
  39. copy(self, "*", os.path.join(self.export_sources_folder),
  40. os.path.join(self.package_folder, "res"))
  41. def package_info(self):
  42. self.cpp_info.includedirs = []
  43. self.runenv_info.append_path("CURA_RESOURCES", os.path.join(self.package_folder, "res"))
  44. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "definitions"))
  45. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "extruders"))
  46. self.env_info.CURA_RESOURCES.append(os.path.join(self.package_folder, "res"))
  47. self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions"))
  48. self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions"))
  49. def package_id(self):
  50. self.info.clear()