Skip to content

Commit e7860b7

Browse files
committed
Change the way of enabling sentry
1 parent 6135ed3 commit e7860b7

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

conanfile.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ class ArcusConan(ConanFile):
2929
"shared": [True, False],
3030
"fPIC": [True, False],
3131
"enable_sentry": [True, False],
32+
"sentry_project": ["ANY"],
3233
}
3334
default_options = {
3435
"shared": True,
3536
"fPIC": True,
3637
"enable_sentry": False,
38+
"sentry_project": name,
3739
}
3840

3941
def set_version(self):
@@ -66,8 +68,6 @@ def export_sources(self):
6668
def config_options(self):
6769
if self.settings.os == "Windows":
6870
del self.options.fPIC
69-
if self.conf.get("user.curaengine:sentry_url", "", check_type=str) == "":
70-
del self.options.enable_sentry
7171

7272
def configure(self):
7373
if self.options.shared:
@@ -98,13 +98,18 @@ def validate(self):
9898
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
9999
)
100100

101+
if self.options.enable_sentry:
102+
for sentry_setting in ["organization", "token"]:
103+
if self.conf.get(f"user.sentry:{sentry_setting}", "", check_type=str) == "":
104+
raise ConanInvalidConfiguration(f"Unable to enable Sentry because no {sentry_setting} was configured")
105+
101106
def build_requirements(self):
102107
self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/cura_11622") # FIXME: use stable after merge
103108
self.tool_requires("protobuf/3.21.12")
104109

105110
def generate(self):
106111
tc = CMakeToolchain(self)
107-
tc.variables["ENABLE_SENTRY"] = self.options.get_safe("enable_sentry", False)
112+
tc.variables["ENABLE_SENTRY"] = self.options.enable_sentry
108113
if is_msvc(self):
109114
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
110115
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
@@ -121,25 +126,24 @@ def build(self):
121126
cmake.configure()
122127
cmake.build()
123128

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-
129+
if self.options.enable_sentry:
130+
sentry_project = self.options.sentry_project
131+
sentry_organization = self.conf.get("user.sentry:organization", "", check_type=str)
132+
sentry_token = self.conf.get("user.sentry:token", "", check_type=str)
133+
130134
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}")
135+
raise ConanException("sentry-cli is not installed, unable to upload debug symbols")
136+
137+
if self.settings.os == "Linux":
138+
self.output.info("Stripping debug symbols from binary")
139+
ext = ".so" if self.options.shared else ".a"
140+
self.run(f"objcopy --only-keep-debug --compress-debug-sections=zlib libArcus{ext} libArcus.debug")
141+
self.run(f"objcopy --strip-debug --strip-unneeded libArcus{ext}")
142+
self.run(f"objcopy --add-gnu-debuglink=libArcus.debug libArcus{ext}")
143+
144+
build_source_dir = self.build_path.parent.parent.as_posix()
145+
self.output.info("Uploading debug symbols to sentry")
146+
self.run(f"sentry-cli --auth-token {sentry_token} debug-files upload --include-sources -o {sentry_organization} -p {sentry_project} {build_source_dir}")
143147

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

0 commit comments

Comments
 (0)