conanfile.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. settings = "os", "compiler", "build_type", "arch"
  15. no_copy_source = True
  16. package_type = "header-library"
  17. @property
  18. def _shared_resources(self):
  19. return ["definitions", "extruders", "images", "intent", "meshes", "quality", "variants"]
  20. def set_version(self):
  21. if not self.version:
  22. self.version = self.conan_data["version"]
  23. def export(self):
  24. copy(self, pattern="LICENSE*", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder,
  25. keep_path=False)
  26. update_conandata(self, {"version": self.version})
  27. def export_sources(self):
  28. for shared_resources in self._shared_resources:
  29. copy(self, pattern="*", src=os.path.join(self.recipe_folder, shared_resources),
  30. dst=os.path.join(self.export_sources_folder, shared_resources))
  31. def validate(self):
  32. if Version(self.version) <= Version("4"):
  33. raise ConanInvalidConfiguration("Only versions 5+ are support")
  34. def layout(self):
  35. self.cpp.source.resdirs = self._shared_resources
  36. self.cpp.package.resdirs = [f"res/{res}" for res in self._shared_resources]
  37. def package(self):
  38. copy(self, "*", os.path.join(self.export_sources_folder),
  39. os.path.join(self.package_folder, "res"))
  40. def package_info(self):
  41. self.cpp_info.includedirs = []
  42. self.runenv_info.append_path("CURA_RESOURCES", os.path.join(self.package_folder, "res"))
  43. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "definitions"))
  44. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "extruders"))
  45. def package_id(self):
  46. self.info.clear()