From e170bb5bbb87212eaeab986e62b9459531396a78 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Mon, 9 Dec 2024 09:42:21 +0100 Subject: [PATCH 01/12] Add npm generator for Emscripten and WebAssembly builds Introduce a new npm generator in the Conan extensions for deploying to NPM when building for Emscripten and WebAssembly architectures. This generator copies JavaScript and TypeScript declaration files to a distribution directory and creates a package.json file using configuration information from the root package. Contribute to NP-637 --- extensions/generators/npm.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 extensions/generators/npm.py diff --git a/extensions/generators/npm.py b/extensions/generators/npm.py new file mode 100644 index 0000000..dfcb5cb --- /dev/null +++ b/extensions/generators/npm.py @@ -0,0 +1,27 @@ +import json + +from conan import ConanFile +from conan.tools.files import copy, mkdir, save +from pathlib import Path + + +class npm: + def __init__(self, conanfile: ConanFile): + self._conanfile = conanfile + + def generate(self): + if self._conanfile.settings.os != "Emscripten": + self._conanfile.output.error("Can only deploy to NPM when build for Emscripten") + return + + root_package = [dep for dep in self._conanfile.dependencies.direct_host.values()][0] + dist_path = Path(self._conanfile.generators_folder, "dist") + mkdir(self._conanfile, str(dist_path)) + + # Copy the *.js and *.d.ts + copy(self._conanfile, "*.js", src=root_package.package_folder, dst=str(dist_path)) + copy(self._conanfile, "*.d.ts", src=root_package.package_folder, dst=str(dist_path)) + + # Create the package.json + save(self._conanfile, str(Path(dist_path.parent, "package.json")), + json.dumps(root_package.conf_info.get(f"user.{root_package.ref.name.lower()}:package_json"))) From a40168da072f834e370bf619e6d6897c8ab35235 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Mon, 9 Dec 2024 14:36:39 +0100 Subject: [PATCH 02/12] Simplify package artifact paths in npm generator Remove unnecessary 'dist' directory and streamline file copying process by directly placing JavaScript and TypeScript files in the generators directory. The package.json file creation path is also updated to reflect these changes, reducing path complexity and improving script efficiency. Contribute to NP-637 --- extensions/generators/npm.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/extensions/generators/npm.py b/extensions/generators/npm.py index dfcb5cb..ed55b01 100644 --- a/extensions/generators/npm.py +++ b/extensions/generators/npm.py @@ -15,13 +15,11 @@ class npm: return root_package = [dep for dep in self._conanfile.dependencies.direct_host.values()][0] - dist_path = Path(self._conanfile.generators_folder, "dist") - mkdir(self._conanfile, str(dist_path)) # Copy the *.js and *.d.ts - copy(self._conanfile, "*.js", src=root_package.package_folder, dst=str(dist_path)) - copy(self._conanfile, "*.d.ts", src=root_package.package_folder, dst=str(dist_path)) + copy(self._conanfile, "*.js", src=root_package.package_folder, dst=self._conanfile.generators_folder) + copy(self._conanfile, "*.d.ts", src=root_package.package_folder, dst=self._conanfile.generators_folder) # Create the package.json - save(self._conanfile, str(Path(dist_path.parent, "package.json")), + save(self._conanfile, str(Path(self._conanfile.generators_folder, "package.json")), json.dumps(root_package.conf_info.get(f"user.{root_package.ref.name.lower()}:package_json"))) From 22d0789d8b14fe7d1ce4536e35a1ace39881bb9a Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Mon, 9 Dec 2024 16:38:45 +0100 Subject: [PATCH 03/12] Generate the .npmrc Needed for publishing Contribute to NP-637 --- extensions/generators/npm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/generators/npm.py b/extensions/generators/npm.py index ed55b01..5c0d52e 100644 --- a/extensions/generators/npm.py +++ b/extensions/generators/npm.py @@ -23,3 +23,7 @@ class npm: # Create the package.json save(self._conanfile, str(Path(self._conanfile.generators_folder, "package.json")), json.dumps(root_package.conf_info.get(f"user.{root_package.ref.name.lower()}:package_json"))) + + # Create the .npmrc file + save(self._conanfile, str(Path(self._conanfile.generators_folder, ".npmrc")), + "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}\n@ultimaker:registry=https://npm.pkg.github.com\nalways-auth=true") From 1c071d1c591dfe64d9afbae24e99ea647ad88041 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 11:08:12 +0100 Subject: [PATCH 04/12] Raise exception for non-Emscripten deployments in npm.py Replace error logging with an exception to ensure that the code explicitly fails when attempting to deploy to NPM without Emscripten. This change enhances error handling by providing a clearer indication of incorrect deployment conditions. Contribute to NP-637 --- extensions/generators/npm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/generators/npm.py b/extensions/generators/npm.py index 5c0d52e..24b9844 100644 --- a/extensions/generators/npm.py +++ b/extensions/generators/npm.py @@ -1,7 +1,8 @@ import json from conan import ConanFile -from conan.tools.files import copy, mkdir, save +from conan.errors import ConanException +from conan.tools.files import copy, save from pathlib import Path @@ -12,7 +13,7 @@ class npm: def generate(self): if self._conanfile.settings.os != "Emscripten": self._conanfile.output.error("Can only deploy to NPM when build for Emscripten") - return + raise ConanException("Can only deploy to NPM when build for Emscripten") root_package = [dep for dep in self._conanfile.dependencies.direct_host.values()][0] From 11b98fc61dbab9371f25ae147a86292d871a9bc8 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 11:30:06 +0100 Subject: [PATCH 05/12] Update cura.jinja to replace libsystemd on Linux Added a conditional section in the profile to replace the libsystemd version with 255.10 or higher for Linux. This change addresses a temporary compatibility issue with grpc versions below 1.67.0. The modification ensures smooth integration until the grpc update is completed. Contribute to NP-637 --- profiles/cura.jinja | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/profiles/cura.jinja b/profiles/cura.jinja index bc2c743..f7ff863 100644 --- a/profiles/cura.jinja +++ b/profiles/cura.jinja @@ -1,5 +1,13 @@ include(default) +[replace_requires] +{% if platform.system() == 'Linux' %} +# FIXME: once gRPC is updated to 1.67.0 or higher +# Using 255.10 or higher https://github.com/conan-io/conan-center-index/issues/24889 +# https://github.com/conan-io/conan-center-index/blob/879e140d9438ab491aceea766d0cf0ae3595dae8/recipes/grpc/all/conanfile.py#L122 +libsystemd/*: libsystemd/[>=255.10] +{% endif %} + [settings] compiler.cppstd=17 curaengine*:compiler.cppstd=20 From ca8f19baeabdbe640dc49204653aa41c7ff29b80 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 11:39:56 +0100 Subject: [PATCH 06/12] Update Clang profile to use dynamic version detection Replaced static clang compiler configuration with dynamic detection using the `detect_api` functionality. This change ensures that the compiler and its version are automatically identified, improving flexibility and compatibility with different environments. The executable paths for C and C++ compilers are now dynamically set, enhancing build robustness. Contribute to NP-637 --- profiles/cura_clang.jinja | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/profiles/cura_clang.jinja b/profiles/cura_clang.jinja index fc7eaaa..60ace18 100644 --- a/profiles/cura_clang.jinja +++ b/profiles/cura_clang.jinja @@ -1,13 +1,10 @@ include(cura.jinja) - -[tool_requires] +{% set compiler, version, compiler_exe = detect_api.detect_clang_compiler(compiler_exe="clang") %} [settings] -compiler=clang -compiler.version=18 +compiler={{ compiler }} +compiler.version={{ version.major }} compiler.libcxx=libstdc++11 -[options] - [conf] -tools.build:compiler_executables={"c":"clang", "cpp":"clang++"} +tools.build:compiler_executables={"c":"{{ compiler_exe }}", "cpp":"{{ compiler_exe }}++"} From 6cc9ea84e29cf3f03d7073058da92f76dbf7176d Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 13:10:47 +0100 Subject: [PATCH 07/12] Update Conan profile for curator to match all versions Modify the Conan profile by changing `curator*` to `curator/*`, ensuring that the `cppstd=20` setting applies to all versions of the curator package. This change helps maintain consistency across package versions and prevents potential configuration mismatches. Contribute to NP-637 --- profiles/cura.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/cura.jinja b/profiles/cura.jinja index f7ff863..310c950 100644 --- a/profiles/cura.jinja +++ b/profiles/cura.jinja @@ -17,7 +17,7 @@ curaengine_grpc_definitions*:compiler.cppstd=20 scripta*:compiler.cppstd=20 umspatial*:compiler.cppstd=20 dulcificum*:compiler.cppstd=20 -curator*:compiler.cppstd=20 +curator/*:compiler.cppstd=20 [options] asio-grpc/*:local_allocator=recycling_allocator From 6442b6c869026c806b07e67c91ebaeeb96a41c03 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 13:20:19 +0100 Subject: [PATCH 08/12] Add build folder variable to cura_wasm profile Integrate `tools.cmake.cmake_layout:build_folder_vars` with `['settings.os']` into the `cura_wasm` profile. This change enhances the build configuration by setting up OS-specific build folders, improving the organization and potential debugging process. Contribute to NP-637 --- profiles/cura_wasm.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/cura_wasm.jinja b/profiles/cura_wasm.jinja index 372fc79..96a9e2f 100644 --- a/profiles/cura_wasm.jinja +++ b/profiles/cura_wasm.jinja @@ -10,6 +10,7 @@ arch=wasm [conf] tools.build:skip_test=True +tools.cmake.cmake_layout:build_folder_vars=['settings.os'] [options] curaengine/*:enable_plugins=False From 75f5bfe970c053496f48bb278a7a8c1b7f2150c5 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 13:40:53 +0100 Subject: [PATCH 09/12] Add CI-specific resource paths in cura_wasm profile Include conditional environment-specific paths for resource and materials directories used by the curator. These paths are set when the CI (Continuous Integration) environment variable is detected, ensuring proper resource handling during automated builds. Contribute to NP-637 --- profiles/cura_wasm.jinja | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/profiles/cura_wasm.jinja b/profiles/cura_wasm.jinja index 96a9e2f..0e9a76b 100644 --- a/profiles/cura_wasm.jinja +++ b/profiles/cura_wasm.jinja @@ -11,6 +11,10 @@ arch=wasm [conf] tools.build:skip_test=True tools.cmake.cmake_layout:build_folder_vars=['settings.os'] +{% if os.getenv('CI') == 'true' %} +user.curator:resource_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources" +user.curator:fdm_materials_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources" +{% endif %} [options] curaengine/*:enable_plugins=False From 3048b86c99f4e7c4551fd01a7018f8a123131d93 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 10 Dec 2024 17:43:43 +0100 Subject: [PATCH 10/12] Use curator to build curator Contribute to NP-637 --- profiles/cura_build.jinja | 5 +++++ profiles/cura_wasm.jinja | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/profiles/cura_build.jinja b/profiles/cura_build.jinja index de80517..d5afb9a 100644 --- a/profiles/cura_build.jinja +++ b/profiles/cura_build.jinja @@ -2,3 +2,8 @@ include(default) [settings] compiler.cppstd=17 +curator/*:compiler.cppstd=20 + +[options] +curator/*:with_cura_resources=True +curator/*:with_cura_ted_resources=True diff --git a/profiles/cura_wasm.jinja b/profiles/cura_wasm.jinja index 0e9a76b..cebe419 100644 --- a/profiles/cura_wasm.jinja +++ b/profiles/cura_wasm.jinja @@ -3,6 +3,7 @@ include(cura.jinja) [tool_requires] emsdk/3.1.65@ultimaker/stable nodejs/20.16.0@ultimaker/stable +curator/[>=0.5.0-beta.1]@ultimaker/np_637 [settings] os=Emscripten @@ -11,10 +12,10 @@ arch=wasm [conf] tools.build:skip_test=True tools.cmake.cmake_layout:build_folder_vars=['settings.os'] -{% if os.getenv('CI') == 'true' %} -user.curator:resource_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources" -user.curator:fdm_materials_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources" -{% endif %} +{#{% if os.getenv('CI') == 'true' %}#} +{#user.curator:resource_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources"#} +{#user.curator:fdm_materials_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources"#} +{#{% endif %}#} [options] curaengine/*:enable_plugins=False From 173c718f77f3c78882c85cce1393a3553930ca35 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 11 Dec 2024 14:18:44 +0100 Subject: [PATCH 11/12] Remove unused curator configurations from Conan profiles This commit removes references to unused curator dependencies and options in the `cura_wasm` and `cura_build` profiles. Additionally, it adds specific curator printer settings to `cura_wasm` and replaces options with corresponding `tools.build` configuration in `cura_build` for cleaner and updated profile management. Contribute to NP-637 --- profiles/cura_build.jinja | 5 ++--- profiles/cura_wasm.jinja | 6 +----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/profiles/cura_build.jinja b/profiles/cura_build.jinja index d5afb9a..031c77d 100644 --- a/profiles/cura_build.jinja +++ b/profiles/cura_build.jinja @@ -4,6 +4,5 @@ include(default) compiler.cppstd=17 curator/*:compiler.cppstd=20 -[options] -curator/*:with_cura_resources=True -curator/*:with_cura_ted_resources=True +[conf] +tools.build:skip_test=True diff --git a/profiles/cura_wasm.jinja b/profiles/cura_wasm.jinja index cebe419..43b179a 100644 --- a/profiles/cura_wasm.jinja +++ b/profiles/cura_wasm.jinja @@ -3,7 +3,6 @@ include(cura.jinja) [tool_requires] emsdk/3.1.65@ultimaker/stable nodejs/20.16.0@ultimaker/stable -curator/[>=0.5.0-beta.1]@ultimaker/np_637 [settings] os=Emscripten @@ -12,10 +11,7 @@ arch=wasm [conf] tools.build:skip_test=True tools.cmake.cmake_layout:build_folder_vars=['settings.os'] -{#{% if os.getenv('CI') == 'true' %}#} -{#user.curator:resource_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources"#} -{#user.curator:fdm_materials_path="{% os.getenv('GITHUB_WORKSPACE') %}/resources"#} -{#{% endif %}#} +user.curator:printers=['ultimaker_sketch','ultimaker_sketch_large','ultimaker_sketch_sprint','ultimaker_method'] [options] curaengine/*:enable_plugins=False From 21e88468f769032e8a2019fe77d93e93bdaa7df2 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Thu, 12 Dec 2024 09:46:55 +0100 Subject: [PATCH 12/12] Don't build dulcificum with pybind11 when compiling for wasm Contribute to NP-637 --- profiles/cura_wasm.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/cura_wasm.jinja b/profiles/cura_wasm.jinja index 43b179a..f46195d 100644 --- a/profiles/cura_wasm.jinja +++ b/profiles/cura_wasm.jinja @@ -18,4 +18,5 @@ curaengine/*:enable_plugins=False curaengine/*:enable_arcus=False curator/*:with_cura_resources=True curator/*:disable_logging=True +dulcificum/*:with_python_bindings=False libzip/*:crypto=False