diff --git a/.github/workflows/conan-package-resources.yml b/.github/workflows/conan-package-resources.yml new file mode 100644 index 0000000000..92a7e005fa --- /dev/null +++ b/.github/workflows/conan-package-resources.yml @@ -0,0 +1,40 @@ +name: conan-package-resources + +on: + push: + paths: + - '.github/workflows/conan-package-resources.yml' + - 'resources/definitions/**' + - 'resources/extruders/**' + - 'resources/images/**' + - 'resources/intent/**' + - 'resources/meshes/**' + - 'resources/quality/**' + - 'resources/variants/**' + - 'resources/conanfile.py' + branches: + - 'main' + - 'CURA-*' + - 'PP-*' + - 'NP-*' + - '[0-9].[0-9]*' + - '[0-9].[0-9][0-9]*' + +env: + CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }} + CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }} + +jobs: + conan-recipe-version: + uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-version.yml@main + with: + project_name: cura_resources + + conan-package-export: + needs: [ conan-recipe-version ] + uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@main + with: + recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} + recipe_id_latest: ${{ needs.conan-recipe-version.outputs.recipe_id_latest }} + conan_recipe_root: "./resources/" + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index 8faf1e27e1..42d03b5038 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -4,12 +4,20 @@ on: push: paths: - 'plugins/**' - - 'resources/**' - '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/**' - - '.github/workflows/conan-*.yml' + - '.github/workflows/conan-package.yml' - '.github/workflows/notify.yml' - '.github/workflows/requirements-runner.txt' - 'requirements*.txt' @@ -20,6 +28,7 @@ on: - 'main' - 'CURA-*' - 'PP-*' + - 'NP-*' - '[0-9].[0-9]*' - '[0-9].[0-9][0-9]*' diff --git a/conandata.yml b/conandata.yml index e56cc554d7..1829ce60d2 100644 --- a/conandata.yml +++ b/conandata.yml @@ -1,5 +1,6 @@ version: "5.8.0-alpha.0" requirements: + - "cura_resources/(latest)@ultimaker/latest" - "uranium/(latest)@ultimaker/testing" - "curaengine/(latest)@ultimaker/testing" - "cura_binary_data/(latest)@ultimaker/testing" @@ -51,8 +52,8 @@ pyinstaller: src: "res/bundled_packages" dst: "share/cura/resources/bundled_packages" cura_resources: - package: "cura" - src: "resources" + package: "cura_resources" + src: "res" dst: "share/cura/resources" cura_private_data: package: "cura_private_data" diff --git a/conanfile.py b/conanfile.py index 2eebeee991..221d4ea288 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", Path(res_dir).name)), keep_path = True) + # 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], Path(res_dir).name)) + 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 new file mode 100644 index 0000000000..b4cafc705e --- /dev/null +++ b/resources/conanfile.py @@ -0,0 +1,64 @@ +import os + +from conan import ConanFile +from conan.tools.files import copy, update_conandata +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.58.0 <2.0.0" + + +class CuraResource(ConanFile): + name = "cura_resources" + license = "" + author = "UltiMaker" + url = "https://github.com/Ultimaker/cura" + description = "Cura Resources" + topics = ("conan", "cura") + settings = "os", "compiler", "build_type", "arch" + no_copy_source = True + + + @property + def _shared_resources(self): + return ["definitions", "extruders", "images", "intent", "meshes", "quality", "variants"] + + def set_version(self): + if not self.version: + self.version = self.conan_data["version"] + + def export(self): + copy(self, pattern="conandata.yml", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder, + keep_path=False) + copy(self, pattern="LICENSE*", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder, + keep_path=False) + update_conandata(self, {"version": self.version}) + + def export_sources(self): + for shared_resources in self._shared_resources: + copy(self, pattern="*", src=os.path.join(self.recipe_folder, shared_resources), + dst=os.path.join(self.export_sources_folder, shared_resources)) + + def validate(self): + if Version(self.version) <= Version("4"): + raise ConanInvalidConfiguration("Only versions 5+ are support") + + def layout(self): + self.cpp.source.resdirs = self._shared_resources + self.cpp.package.resdirs = [f"res/{res}" for res in self._shared_resources] + + def package(self): + copy(self, "*", os.path.join(self.export_sources_folder), + os.path.join(self.package_folder, "res")) + + def package_info(self): + self.cpp_info.includedirs = [] + self.runenv_info.append_path("CURA_RESOURCES", os.path.join(self.package_folder, "res")) + self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "definitions")) + self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "extruders")) + self.env_info.CURA_RESOURCES.append(os.path.join(self.package_folder, "res")) + self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions")) + self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions")) + + def package_id(self): + self.info.clear()