conanfile.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 = ">=2.7.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. no_copy_source = True
  15. package_type = "shared-library"
  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="LICENSE*", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder,
  24. keep_path=False)
  25. update_conandata(self, {"version": self.version})
  26. def export_sources(self):
  27. for shared_resources in self._shared_resources:
  28. copy(self, pattern="*", src=os.path.join(self.recipe_folder, shared_resources),
  29. dst=os.path.join(self.export_sources_folder, shared_resources))
  30. def validate(self):
  31. if Version(self.version) <= Version("4"):
  32. raise ConanInvalidConfiguration("Only versions 5+ are support")
  33. def layout(self):
  34. self.cpp.source.resdirs = self._shared_resources
  35. self.cpp.package.resdirs = [f"res/{res}" for res in self._shared_resources]
  36. def package(self):
  37. copy(self, "*", os.path.join(self.export_sources_folder),
  38. os.path.join(self.package_folder, "res"))
  39. def package_info(self):
  40. self.cpp_info.includedirs = []
  41. self.runenv_info.append_path("CURA_RESOURCES", os.path.join(self.package_folder, "res"))
  42. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "definitions"))
  43. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "extruders"))
  44. def package_id(self):
  45. self.info.clear()