From 0c3209f7c7351cb687864e195278ec2eaddddfcc Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 11:53:05 +0100 Subject: [PATCH 1/5] Integrate npm package publish Use the new workflows for Conan v2 to build and publish and npm package Contribute to NP-637 --- .../{conan-package.yml => package.yml} | 16 ++++++-- CuraEngineJS/.npmrc | 3 -- CuraEngineJS/package-lock.json | 13 ------- CuraEngineJS/package.json | 38 ------------------- conanfile.py | 35 +++++++++++++---- 5 files changed, 40 insertions(+), 65 deletions(-) rename .github/workflows/{conan-package.yml => package.yml} (59%) delete mode 100644 CuraEngineJS/.npmrc delete mode 100644 CuraEngineJS/package-lock.json delete mode 100644 CuraEngineJS/package.json diff --git a/.github/workflows/conan-package.yml b/.github/workflows/package.yml similarity index 59% rename from .github/workflows/conan-package.yml rename to .github/workflows/package.yml index d0f493dd16..a20e3710b8 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/package.yml @@ -1,4 +1,4 @@ -name: conan-package +name: package on: push: @@ -9,7 +9,7 @@ on: - 'conanfile.py' - 'conandata.yml' - 'CMakeLists.txt' - - '.github/workflows/conan-package.yml' + - '.github/workflows/package.yml' branches: - main - 'CURA-*' @@ -29,7 +29,7 @@ on: - 'conanfile.py' - 'conandata.yml' - 'CMakeLists.txt' - - '.github/workflows/conan-package.yml' + - '.github/workflows/package.yml' branches: - main - 'CURA-*' @@ -40,7 +40,15 @@ on: jobs: conan-package: - uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@main + uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@NP-637_conan_v2_wasm with: platform_wasm: true secrets: inherit + + npm-package: + needs: [ conan-package ] + if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || contains(github.ref_name, 'NP-') || github.ref_name == '5.10') }} # FIXME: have a more generic way to determine release branches + uses: ultimaker/cura-workflows/.github/workflows/npm-package.yml@NP-637_conan_v2_wasm + with: + package_version_full: ${{ needs.conan-package.outputs.package_version_full }} + secrets: inherit diff --git a/CuraEngineJS/.npmrc b/CuraEngineJS/.npmrc deleted file mode 100644 index 858f5af943..0000000000 --- a/CuraEngineJS/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} -@ultimaker:registry=https://npm.pkg.github.com -always-auth=true diff --git a/CuraEngineJS/package-lock.json b/CuraEngineJS/package-lock.json deleted file mode 100644 index 40e4254ba7..0000000000 --- a/CuraEngineJS/package-lock.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@ultimaker/curaenginejs", - "version": "0.2.3", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "@ultimaker/curaenginejs", - "version": "0.2.1", - "devDependencies": {} - } - } -} diff --git a/CuraEngineJS/package.json b/CuraEngineJS/package.json deleted file mode 100644 index 9ccdc78abd..0000000000 --- a/CuraEngineJS/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "@ultimaker/curaenginejs", - "version": "0.2.3", - "description": "CuraEngineJS a TS component to run CuraEngine in a browser", - "main": "dist/CuraEngine.js", - "scripts": { - "install_curaengine": "conan install ${npm_package_config_conan_package} -s build_type=Release --build=missing --update -c tools.build:skip_test=True -pr:h cura_wasm.jinja -if dist && rm -f dist/*conan*", - "build": "npm run install_curaengine", - "prepublishOnly": "npm run build" - }, - "config": { - "conan_package": "curaengine/5.9.0@_/_" - }, - "repository": { - "type": "git", - "url": "https://github.com/Ultimaker/CuraEngine.git" - }, - "keywords": [ - "Cura", - "CuraEngine", - "Slicer" - ], - "author": "UltiMaker", - "license": "", - "bugs": { - "url": "https://github.com/Ultimaker/CuraEngine/issues" - }, - "homepage": "https://github.com/Ultimaker/CuraEngine#readme", - "dependencies": { - }, - "devDependencies": { - }, - "files": [ - "dist", - "package.json", - "README.md" - ] -} \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 8a3c74258b..e3af37d7df 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,10 +3,9 @@ import os from conan import ConanFile -from conan.errors import ConanInvalidConfiguration -from conan.tools.files import copy, mkdir, update_conandata -from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.tools.files import copy, mkdir, update_conandata from conan.tools.scm import Version, Git required_conan_version = ">=2.7.0" @@ -61,8 +60,10 @@ def export_sources(self): copy(self, "CuraEngine.rc", self.recipe_folder, self.export_sources_folder) copy(self, "LICENSE", self.recipe_folder, self.export_sources_folder) copy(self, "*", os.path.join(self.recipe_folder, "src"), os.path.join(self.export_sources_folder, "src")) - copy(self, "*", os.path.join(self.recipe_folder, "include"), os.path.join(self.export_sources_folder, "include")) - copy(self, "*", os.path.join(self.recipe_folder, "benchmark"), os.path.join(self.export_sources_folder, "benchmark")) + copy(self, "*", os.path.join(self.recipe_folder, "include"), + os.path.join(self.export_sources_folder, "include")) + copy(self, "*", os.path.join(self.recipe_folder, "benchmark"), + os.path.join(self.export_sources_folder, "benchmark")) copy(self, "*", os.path.join(self.recipe_folder, "stress_benchmark"), os.path.join(self.export_sources_folder, "stress_benchmark")) copy(self, "*", os.path.join(self.recipe_folder, "tests"), os.path.join(self.export_sources_folder, "tests")) @@ -136,7 +137,8 @@ def generate(self): tc.variables["ENABLE_TESTING"] = not self.conf.get("tools.build:skip_test", False, check_type=bool) tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings - tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "14" + tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version( + self.settings.compiler.version) < "14" tc.variables["ENABLE_THREADING"] = not (self.settings.arch == "wasm" and self.settings.os == "Emscripten") if self.options.enable_plugins: tc.variables["ENABLE_PLUGINS"] = True @@ -180,7 +182,7 @@ def build(self): cmake.configure() cmake.build() - self.send_sentry_debug_files(binary_basename = "CuraEngine") + self.send_sentry_debug_files(binary_basename="CuraEngine") def deploy(self): copy(self, "CuraEngine*", src=os.path.join(self.package_folder, "bin"), dst=self.deploy_folder) @@ -202,3 +204,22 @@ def package_info(self): ext = ".exe" if self.settings.os == "Windows" else "" self.conf_info.define_path("user.curaengine:curaengine", os.path.join(self.package_folder, "bin", f"CuraEngine{ext}")) + if self.settings.os == "Emscripten": + package_json = { + "name": f"@ultimaker/{self.name.lower()}js", + "version": f"{str(self.version).replace('+', '-')}", # npm will otherwise 'sanitize' the version number + "description": f"JavaScript / TypeScript bindings for {self.name}, a {self.description}", + "main": "bin/CuraEngine.js", + "repository": { + "type": "git", + "url": self.url + }, + "author": self.author, + "license": self.license, + "keywords": self.topics, + "files": [ + "bin", + "package.json" + ] + } + self.conf_info.define(f"user.{self.name.lower()}:package_json", package_json) From 8930838cd1035afb634a643e36e88599fac3a970 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 11 Dec 2024 16:16:15 +0100 Subject: [PATCH 2/5] Add npmpackage dependency and delegate package.json setup The npmpackage Python requirement was introduced to handle package.json configuration for Emscripten builds. This simplifies the code by delegating the package.json setup to the npmpackage module, reducing redundancy and maintaining cleaner logic. Contribute to NP-637 --- conanfile.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/conanfile.py b/conanfile.py index e3af37d7df..db466d48db 100644 --- a/conanfile.py +++ b/conanfile.py @@ -21,7 +21,7 @@ class CuraEngineConan(ConanFile): exports = "LICENSE*" settings = "os", "compiler", "build_type", "arch" package_type = "application" - python_requires = "sentrylibrary/1.0.0@ultimaker/stable" + python_requires = "sentrylibrary/1.0.0@ultimaker/stable", "npmpackage/[>=1.0.0]@ultimaker/np_637" python_requires_extend = "sentrylibrary.SentryLibrary" options = { @@ -205,21 +205,4 @@ def package_info(self): self.conf_info.define_path("user.curaengine:curaengine", os.path.join(self.package_folder, "bin", f"CuraEngine{ext}")) if self.settings.os == "Emscripten": - package_json = { - "name": f"@ultimaker/{self.name.lower()}js", - "version": f"{str(self.version).replace('+', '-')}", # npm will otherwise 'sanitize' the version number - "description": f"JavaScript / TypeScript bindings for {self.name}, a {self.description}", - "main": "bin/CuraEngine.js", - "repository": { - "type": "git", - "url": self.url - }, - "author": self.author, - "license": self.license, - "keywords": self.topics, - "files": [ - "bin", - "package.json" - ] - } - self.conf_info.define(f"user.{self.name.lower()}:package_json", package_json) + self.python_requires["npmpackage"].module.conf_package_json(self) From 6de3ca44b99aa8e7b1126af9c05b7071e4753c48 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 11 Dec 2024 17:03:02 +0100 Subject: [PATCH 3/5] Enforce minimum compiler versions and C++20 support Added checks to validate minimum compiler versions and enforce C++20 compatibility for the package. These include GCC 12, Clang 14, Apple Clang 13, MSVC 191, and Visual Studio 17. This ensures compatibility with the required C++ features, preventing builds with unsupported compilers. Contribute to NP-637 --- conanfile.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/conanfile.py b/conanfile.py index db466d48db..e4e08ec806 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,9 +3,11 @@ import os from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout from conan.tools.files import copy, mkdir, update_conandata +from conan.tools.microsoft import check_min_vs, is_msvc from conan.tools.scm import Version, Git required_conan_version = ">=2.7.0" @@ -41,6 +43,16 @@ class CuraEngineConan(ConanFile): "with_cura_resources": False, } + @property + def _compilers_minimum_version(self): + return { + "gcc": "12", + "clang": "14", + "apple-clang": "13", + "msvc": "191", + "visual_studio": "17", + } + def init(self): base = self.python_requires["sentrylibrary"].module.SentryLibrary self.options.update(base.options, base.default_options) @@ -87,6 +99,12 @@ def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, 20) + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.") def build_requirements(self): self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/stable") From 1462bcbe5d8be77581e732a35488bac2f969a870 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 11 Dec 2024 17:35:50 +0100 Subject: [PATCH 4/5] bogus commit Contribute to NP-637 --- conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conanfile.py b/conanfile.py index e4e08ec806..0146155226 100644 --- a/conanfile.py +++ b/conanfile.py @@ -222,5 +222,6 @@ def package_info(self): ext = ".exe" if self.settings.os == "Windows" else "" self.conf_info.define_path("user.curaengine:curaengine", os.path.join(self.package_folder, "bin", f"CuraEngine{ext}")) + if self.settings.os == "Emscripten": self.python_requires["npmpackage"].module.conf_package_json(self) From 2095fcc5059b4c7c2eab5594cf097d97b8a90224 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Thu, 12 Dec 2024 08:04:39 +0100 Subject: [PATCH 5/5] implement review comments Contribute to NP-637 --- .github/workflows/package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a20e3710b8..6b38400ddf 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,15 +40,15 @@ on: jobs: conan-package: - uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@NP-637_conan_v2_wasm + uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@NP-637_conan_v2_wasm # FIXME: Use `main` branch with: platform_wasm: true secrets: inherit npm-package: needs: [ conan-package ] - if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || contains(github.ref_name, 'NP-') || github.ref_name == '5.10') }} # FIXME: have a more generic way to determine release branches - uses: ultimaker/cura-workflows/.github/workflows/npm-package.yml@NP-637_conan_v2_wasm + if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'NP-') || startsWith(github.ref_name, '5.')) }} # FIXME: have a more generic way to determine release branches + uses: ultimaker/cura-workflows/.github/workflows/npm-package.yml@NP-637_conan_v2_wasm # FIXME: Use `main` branch with: package_version_full: ${{ needs.conan-package.outputs.package_version_full }} secrets: inherit