Skip to content

Commit 4f5392d

Browse files
authored
Merge pull request #158 from Ultimaker/CURA-11622_conan_v2
Cura 11622 conan v2
2 parents 168725a + bc3e5c4 commit 4f5392d

File tree

5 files changed

+40
-74
lines changed

5 files changed

+40
-74
lines changed

.github/workflows/conan-package.yml

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ on:
88
- 'include/**'
99
- 'cmake/**'
1010
- 'conanfile.py'
11+
- 'conandata.yml'
1112
- 'CMakeLists.txt'
1213
- '.github/workflows/conan-package.yml'
1314
- '.github/workflows/requirements*'
14-
- 'conandata.yml'
1515
- '.gitattributes'
1616
branches:
1717
- main
@@ -21,39 +21,6 @@ on:
2121
- '[0-9].[0-9][0-9]*'
2222

2323
jobs:
24-
conan-recipe-version:
25-
uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-version.yml@main
26-
with:
27-
project_name: arcus
28-
29-
conan-package-export:
30-
needs: [ conan-recipe-version ]
31-
uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@main
32-
with:
33-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
34-
recipe_id_latest: ${{ needs.conan-recipe-version.outputs.recipe_id_latest }}
35-
secrets: inherit
36-
37-
conan-package-create-macos:
38-
needs: [ conan-recipe-version, conan-package-export ]
39-
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }}
40-
uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-macos.yml@main
41-
with:
42-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
43-
secrets: inherit
44-
45-
conan-package-create-windows:
46-
needs: [ conan-recipe-version, conan-package-export ]
47-
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }}
48-
uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-windows.yml@main
49-
with:
50-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
51-
secrets: inherit
52-
53-
conan-package-create-linux:
54-
needs: [ conan-recipe-version, conan-package-export ]
55-
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }}
56-
uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-linux.yml@main
57-
with:
58-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
59-
secrets: inherit
24+
conan-package:
25+
uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@main
26+
secrets: inherit

.github/workflows/process-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
add_label:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
- uses: actions-ecosystem/action-add-labels@v1
1313
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
1414
with:

.github/workflows/requirements-runner.txt

Whitespace-only changes.

conanfile.py

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from io import StringIO
21
import os
3-
from os import path
2+
from shutil import which
43

54
from conan import ConanFile
65
from conan.errors import ConanInvalidConfiguration
@@ -10,9 +9,9 @@
109
from conan.tools.files import copy, AutoPackager, update_conandata
1110
from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime
1211
from conan.tools.scm import Version, Git
13-
from conans.tools import which
1412

15-
required_conan_version = ">=1.55.0"
13+
14+
required_conan_version = ">=2.7.0"
1615

1716

1817
class ArcusConan(ConanFile):
@@ -24,22 +23,26 @@ class ArcusConan(ConanFile):
2423
topics = ("conan", "binding", "cura", "protobuf", "c++")
2524
settings = "os", "compiler", "build_type", "arch"
2625
exports = "LICENSE*"
26+
package_type = "library"
27+
python_requires = "sentrylibrary/1.0.0@ultimaker/stable"
28+
python_requires_extend = "sentrylibrary.SentryLibrary"
2729

2830
options = {
2931
"shared": [True, False],
3032
"fPIC": [True, False],
31-
"enable_sentry": [True, False],
3233
}
3334
default_options = {
3435
"shared": True,
3536
"fPIC": True,
36-
"enable_sentry": False,
3737
}
3838

39+
def init(self):
40+
base = self.python_requires["sentrylibrary"].module.SentryLibrary
41+
self.options.update(base.options, base.default_options)
42+
3943
def set_version(self):
4044
if not self.version:
41-
build_meta = "" if self.develop else "+source"
42-
self.version = self.conan_data["version"] + build_meta
45+
self.version = self.conan_data["version"]
4346

4447
def export(self):
4548
git = Git(self)
@@ -61,16 +64,18 @@ def _compilers_minimum_version(self):
6164

6265
def export_sources(self):
6366
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
64-
copy(self, "*", path.join(self.recipe_folder, "src"), path.join(self.export_sources_folder, "src"))
65-
copy(self, "*", path.join(self.recipe_folder, "include"), path.join(self.export_sources_folder, "include"))
67+
copy(self, "*", os.path.join(self.recipe_folder, "src"), os.path.join(self.export_sources_folder, "src"))
68+
copy(self, "*", os.path.join(self.recipe_folder, "include"), os.path.join(self.export_sources_folder, "include"))
6669

6770
def config_options(self):
71+
super().config_options()
72+
6873
if self.settings.os == "Windows":
6974
del self.options.fPIC
70-
if self.conf.get("user.curaengine:sentry_url", "", check_type=str) == "":
71-
del self.options.enable_sentry
7275

7376
def configure(self):
77+
super().configure()
78+
7479
if self.options.shared:
7580
self.options.rm_safe("fPIC")
7681

@@ -86,9 +91,13 @@ def layout(self):
8691
self.cpp.package.system_libs = ["ws2_32"]
8792

8893
def requirements(self):
89-
self.requires("protobuf/3.21.9", transitive_headers=True)
94+
super().requirements()
95+
96+
self.requires("protobuf/3.21.12", transitive_headers=True)
9097

9198
def validate(self):
99+
super().validate()
100+
92101
if self.settings.compiler.cppstd:
93102
check_min_cppstd(self, self._min_cppstd)
94103
check_min_vs(self, 192) # TODO: remove in Conan 2.0
@@ -99,15 +108,21 @@ def validate(self):
99108
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
100109
)
101110

111+
if self.options.enable_sentry:
112+
for sentry_setting in ["organization", "token"]:
113+
if self.conf.get(f"user.sentry:{sentry_setting}", "", check_type=str) == "":
114+
raise ConanInvalidConfiguration(f"Unable to enable Sentry because no {sentry_setting} was configured")
115+
102116
def build_requirements(self):
103-
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
117+
self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/stable")
118+
self.tool_requires("protobuf/3.21.12")
104119

105120
def generate(self):
106121
tc = CMakeToolchain(self)
107-
tc.variables["ENABLE_SENTRY"] = self.options.get_safe("enable_sentry", False)
108122
if is_msvc(self):
109123
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
110124
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
125+
self.setup_cmake_toolchain_sentry(tc)
111126
tc.generate()
112127

113128
tc = CMakeDeps(self)
@@ -121,25 +136,7 @@ def build(self):
121136
cmake.configure()
122137
cmake.build()
123138

124-
sentry_project = self.conf.get("user.curaengine:sentry_project", "", check_type=str)
125-
sentry_org = self.conf.get("user.curaengine:sentry_org", "", check_type=str)
126-
if self.options.get_safe("enable_sentry", False) and os.environ.get('SENTRY_TOKEN', None) and sentry_project != "" and sentry_org != "":
127-
if sentry_project == "" or sentry_org == "":
128-
raise ConanInvalidConfiguration("sentry_project or sentry_org is not set")
129-
130-
if which("sentry-cli") is None:
131-
self.output.warn("sentry-cli is not installed, skipping uploading debug symbols")
132-
else:
133-
if self.settings.os == "Linux":
134-
self.output.info("Stripping debug symbols from binary")
135-
ext = ".so" if self.options.shared else ".a"
136-
self.run(f"objcopy --only-keep-debug --compress-debug-sections=zlib libArcus{ext} libArcus.debug")
137-
self.run(f"objcopy --strip-debug --strip-unneeded libArcus{ext}")
138-
self.run(f"objcopy --add-gnu-debuglink=libArcus.debug libArcus{ext}")
139-
140-
build_source_dir = self.build_path.parent.parent.as_posix()
141-
self.output.info("Uploading debug symbols to sentry")
142-
self.run(f"sentry-cli --auth-token {os.environ['SENTRY_TOKEN']} debug-files upload --include-sources -o {sentry_org} -p {sentry_project} {build_source_dir}")
139+
self.send_sentry_debug_files(binary_basename = "libArcus")
143140

144141
def package(self):
145142
copy(self, pattern="LICENSE*", dst="licenses", src=self.source_folder)

test_package/conanfile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ class ArcusTestConan(ConanFile):
99
test_type = "explicit"
1010

1111
def build_requirements(self):
12-
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
12+
self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/stable")
13+
self.tool_requires("protobuf/3.21.12")
14+
1315
def requirements(self):
1416
self.requires(self.tested_reference_str)
15-
self.requires("protobuf/3.21.4")
17+
self.requires("protobuf/3.21.12")
1618

1719
def layout(self):
1820
cmake_layout(self)

0 commit comments

Comments
 (0)