1
- from io import StringIO
2
1
import os
3
- from os import path
2
+ from shutil import which
4
3
5
4
from conan import ConanFile
6
5
from conan .errors import ConanInvalidConfiguration
10
9
from conan .tools .files import copy , AutoPackager , update_conandata
11
10
from conan .tools .microsoft import check_min_vs , is_msvc , is_msvc_static_runtime
12
11
from conan .tools .scm import Version , Git
13
- from conans .tools import which
14
12
15
- required_conan_version = ">=1.55.0"
13
+
14
+ required_conan_version = ">=2.7.0"
16
15
17
16
18
17
class ArcusConan (ConanFile ):
@@ -24,22 +23,26 @@ class ArcusConan(ConanFile):
24
23
topics = ("conan" , "binding" , "cura" , "protobuf" , "c++" )
25
24
settings = "os" , "compiler" , "build_type" , "arch"
26
25
exports = "LICENSE*"
26
+ package_type = "library"
27
+ python_requires = "sentrylibrary/1.0.0@ultimaker/stable"
28
+ python_requires_extend = "sentrylibrary.SentryLibrary"
27
29
28
30
options = {
29
31
"shared" : [True , False ],
30
32
"fPIC" : [True , False ],
31
- "enable_sentry" : [True , False ],
32
33
}
33
34
default_options = {
34
35
"shared" : True ,
35
36
"fPIC" : True ,
36
- "enable_sentry" : False ,
37
37
}
38
38
39
+ def init (self ):
40
+ base = self .python_requires ["sentrylibrary" ].module .SentryLibrary
41
+ self .options .update (base .options , base .default_options )
42
+
39
43
def set_version (self ):
40
44
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" ]
43
46
44
47
def export (self ):
45
48
git = Git (self )
@@ -61,16 +64,18 @@ def _compilers_minimum_version(self):
61
64
62
65
def export_sources (self ):
63
66
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" ))
66
69
67
70
def config_options (self ):
71
+ super ().config_options ()
72
+
68
73
if self .settings .os == "Windows" :
69
74
del self .options .fPIC
70
- if self .conf .get ("user.curaengine:sentry_url" , "" , check_type = str ) == "" :
71
- del self .options .enable_sentry
72
75
73
76
def configure (self ):
77
+ super ().configure ()
78
+
74
79
if self .options .shared :
75
80
self .options .rm_safe ("fPIC" )
76
81
@@ -86,9 +91,13 @@ def layout(self):
86
91
self .cpp .package .system_libs = ["ws2_32" ]
87
92
88
93
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 )
90
97
91
98
def validate (self ):
99
+ super ().validate ()
100
+
92
101
if self .settings .compiler .cppstd :
93
102
check_min_cppstd (self , self ._min_cppstd )
94
103
check_min_vs (self , 192 ) # TODO: remove in Conan 2.0
@@ -99,15 +108,21 @@ def validate(self):
99
108
f"{ self .ref } requires C++{ self ._min_cppstd } , which your compiler does not support."
100
109
)
101
110
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
+
102
116
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" )
104
119
105
120
def generate (self ):
106
121
tc = CMakeToolchain (self )
107
- tc .variables ["ENABLE_SENTRY" ] = self .options .get_safe ("enable_sentry" , False )
108
122
if is_msvc (self ):
109
123
tc .variables ["USE_MSVC_RUNTIME_LIBRARY_DLL" ] = not is_msvc_static_runtime (self )
110
124
tc .cache_variables ["CMAKE_POLICY_DEFAULT_CMP0077" ] = "NEW"
125
+ self .setup_cmake_toolchain_sentry (tc )
111
126
tc .generate ()
112
127
113
128
tc = CMakeDeps (self )
@@ -121,25 +136,7 @@ def build(self):
121
136
cmake .configure ()
122
137
cmake .build ()
123
138
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" )
143
140
144
141
def package (self ):
145
142
copy (self , pattern = "LICENSE*" , dst = "licenses" , src = self .source_folder )
0 commit comments