conanfile.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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="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. self.env_info.CURA_RESOURCES.append(os.path.join(self.package_folder, "res"))
  45. self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions"))
  46. self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions"))
  47. def package_id(self):
  48. self.info.clear()