From 0942c35c0adc74c043a84f687c535caf63f959be Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Mon, 6 May 2024 11:40:39 +0200 Subject: [PATCH] Add cura_resources as dependency and update resource directories A new dependency 'cura_resources' has been added to the conandata.yml. The handling of 'cura_resources' has been updated, now including specific sections for definitions, extruders, intent, meshes, quality and variants. GitHub Actions workflows and conan scripts have been adjusted accordingly to include these changes. Contribute to NP-186 --- .github/workflows/conan-package-resources.yml | 2 +- .github/workflows/conan-package.yml | 9 ++++++ conandata.yml | 29 ++++++++++++++++--- conanfile.py | 12 ++++++++ resources/conanfile.py | 6 ++-- 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.github/workflows/conan-package-resources.yml b/.github/workflows/conan-package-resources.yml index d180e25ded..b1ab500432 100644 --- a/.github/workflows/conan-package-resources.yml +++ b/.github/workflows/conan-package-resources.yml @@ -6,12 +6,12 @@ on: - '.github/workflows/conan-package-resources.yml' - 'resources/definitions/**' - 'resources/extruders/**' + - 'resources/images/**' - 'resources/intent/**' - 'resources/meshes/**' - 'resources/quality/**' - 'resources/variants/**' - 'resources/conanfile.py' - - 'resources/conandata.yml' branches: - 'main' - 'CURA-*' diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index ed1ac63a70..27935b3c3e 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -5,6 +5,15 @@ on: paths: - 'plugins/**' - 'cura/**' + - 'resources/bundled_packages/**' + - 'resources/i18n/**' + - 'resources/qml/**' + - 'resources/setting_visibility/**' + - 'resources/shaders/**' + - 'resources/texts/**' + - 'resources/themes/**' + - 'resources/public_key.pem' + - 'resources/README_resources.txt' - 'icons/**' - 'tests/**' - 'packaging/**' diff --git a/conandata.yml b/conandata.yml index e56cc554d7..c7f0459c07 100644 --- a/conandata.yml +++ b/conandata.yml @@ -1,5 +1,6 @@ version: "5.8.0-alpha.0" requirements: + - "cura_resources/(latest)@ultimaker/np_186" - "uranium/(latest)@ultimaker/testing" - "curaengine/(latest)@ultimaker/testing" - "cura_binary_data/(latest)@ultimaker/testing" @@ -50,10 +51,30 @@ pyinstaller: package: "native_cad_plugin" src: "res/bundled_packages" dst: "share/cura/resources/bundled_packages" - cura_resources: - package: "cura" - src: "resources" - dst: "share/cura/resources" + cura_resources_definitions: + package: "cura_resources" + src: "definitions" + dst: "share/cura/resources/definitions" + cura_resources_extruders: + package: "cura_resources" + src: "extruders" + dst: "share/cura/resources/extruders" + cura_resources_intent: + package: "cura_resources" + src: "intent" + dst: "share/cura/resources/intent" + cura_resources_meshes: + package: "cura_resources" + src: "meshes" + dst: "share/cura/resources/meshes" + cura_resources_quality: + package: "cura_resources" + src: "quality" + dst: "share/cura/resources/quality" + cura_resources_variants: + package: "cura_resources" + src: "variants" + dst: "share/cura/resources/variants" cura_private_data: package: "cura_private_data" src: "res" diff --git a/conanfile.py b/conanfile.py index 2eebeee991..d42e63ac6d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -468,6 +468,12 @@ class CuraConan(ConanFile): copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[0]), str(self._share_dir.joinpath("cura", "resources")), keep_path = True) copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[1]), str(self._share_dir.joinpath("cura", "plugins")), keep_path = True) + # Copy the cura_resources resources from the package + rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0])) + cura_resources = self.dependencies["cura_resources"].cpp_info + for res_dir in cura_resources.resdirs: + copy(self, "*", res_dir, str(self._share_dir.joinpath("cura", "resources", res_dir))) + # Copy resources of Uranium (keep folder structure) uranium = self.dependencies["uranium"].cpp_info copy(self, "*", uranium.resdirs[0], str(self._share_dir.joinpath("uranium", "resources")), keep_path = True) @@ -519,6 +525,12 @@ echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV # Remove the fdm_materials from the package rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], "materials")) + # Remove the cura_resources resources from the package + rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0])) + cura_resources = self.dependencies["cura_resources"].cpp_info + for res_dir in cura_resources.resdirs: + rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], res_dir)) + def package_info(self): self.user_info.pip_requirements = "requirements.txt" self.user_info.pip_requirements_git = "requirements-ultimaker.txt" diff --git a/resources/conanfile.py b/resources/conanfile.py index 21b4a8c40f..c33465045e 100644 --- a/resources/conanfile.py +++ b/resources/conanfile.py @@ -1,6 +1,4 @@ import os -from pathlib import Path -from jinja2 import Template from conan import ConanFile from conan.tools.files import copy, update_conandata @@ -35,6 +33,8 @@ class CuraResource(ConanFile): dst=os.path.join(self.export_sources_folder, "definitions")) copy(self, pattern="*", src=os.path.join(self.recipe_folder, "extruders"), dst=os.path.join(self.export_sources_folder, "extruders")) + copy(self, pattern="*", src=os.path.join(self.recipe_folder, "images"), + dst=os.path.join(self.export_sources_folder, "images")) copy(self, pattern="*", src=os.path.join(self.recipe_folder, "intent"), dst=os.path.join(self.export_sources_folder, "intent")) copy(self, pattern="*", src=os.path.join(self.recipe_folder, "meshes"), @@ -49,7 +49,7 @@ class CuraResource(ConanFile): raise ConanInvalidConfiguration("Only versions 5+ are support") def layout(self): - self.cpp.source.resdirs = ["definitions", "extruders", "intent", "meshes", "quality", "variants"] + self.cpp.source.resdirs = ["definitions", "extruders", "images", "intent", "meshes", "quality", "variants"] def package(self): copy(self, "*", os.path.join(self.export_sources_folder),