Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate npm package publish #2184

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: conan-package
name: package

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- '.github/workflows/conan-package.yml'
- '.github/workflows/package.yml'
branches:
- main
- 'CURA-*'
Expand All @@ -29,7 +29,7 @@ on:
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- '.github/workflows/conan-package.yml'
- '.github/workflows/package.yml'
branches:
- main
- 'CURA-*'
Expand All @@ -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 # FIXME: Use `main` branch
with:
platform_wasm: true
secrets: inherit

npm-package:
needs: [ conan-package ]
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
3 changes: 0 additions & 3 deletions CuraEngineJS/.npmrc

This file was deleted.

13 changes: 0 additions & 13 deletions CuraEngineJS/package-lock.json

This file was deleted.

38 changes: 0 additions & 38 deletions CuraEngineJS/package.json

This file was deleted.

37 changes: 30 additions & 7 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

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.microsoft import check_min_vs, is_msvc
from conan.tools.scm import Version, Git

required_conan_version = ">=2.7.0"
Expand All @@ -22,7 +23,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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there is no way to have this dependend on settings.os ?

python_requires_extend = "sentrylibrary.SentryLibrary"

options = {
Expand All @@ -42,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)
Expand All @@ -61,8 +72,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"))
Expand All @@ -86,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")
Expand Down Expand Up @@ -136,7 +155,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
Expand Down Expand Up @@ -180,7 +200,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)
Expand All @@ -202,3 +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)
Loading