conanfile.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 layout(self):
  31. self.cpp.source.resdirs = self._shared_resources
  32. self.cpp.package.resdirs = [f"res/{res}" for res in self._shared_resources]
  33. def package(self):
  34. copy(self, "*", os.path.join(self.export_sources_folder),
  35. os.path.join(self.package_folder, "res"))
  36. def package_info(self):
  37. self.cpp_info.includedirs = []
  38. self.runenv_info.append_path("CURA_RESOURCES", os.path.join(self.package_folder, "res"))
  39. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "definitions"))
  40. self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "extruders"))
  41. def package_id(self):
  42. self.info.clear()