1- from io import StringIO
21import os
3- from os import path
2+ from shutil import which
43
54from conan import ConanFile
65from conan .errors import ConanInvalidConfiguration
109from conan .tools .files import copy , AutoPackager , update_conandata
1110from conan .tools .microsoft import check_min_vs , is_msvc , is_msvc_static_runtime
1211from 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
1817class 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 )
0 commit comments