Commit 516c150
feat: Add SENTRY_SDK_VERSION CMake override for downstream SDKs (#1417)
* feat: Auto-split build ID from version in sentry_library_info
When downstream SDKs modify sentry.h to include build metadata in the
version string (e.g., 0.11.3+20251016-9e31c9f-dirty), the embedded
library info now automatically extracts the build ID from the version.
Changes:
- Parse build metadata from SENTRY_VERSION_FULL if present
- Use base version (major.minor.patch) for SENTRY_VERSION field
- Use extracted build ID for BUILD field
- SENTRY_BUILD_ID cache variable still takes precedence
- Update template to use new SENTRY_EMBEDDED_VERSION and SENTRY_EMBEDDED_BUILD_ID
- Update tests to validate base version format
- Add test for build ID field
This ensures the embedded info format is:
SENTRY_VERSION:0.11.3;BUILD:20251016-9e31c9f-dirty
instead of:
SENTRY_VERSION:0.11.3+20251016-9e31c9f-dirty;BUILD:0.11.3+20251016-9e31c9f-dirty
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor: Use SENTRY_VERSION_BASE directly instead of SENTRY_EMBEDDED_VERSION
Simplifies the code by reusing the existing SENTRY_VERSION_BASE variable
which already contains the major.minor.patch format without build metadata.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor: Skip parsing if SENTRY_BUILD_ID is already set
Optimizes the logic to check SENTRY_BUILD_ID cache variable first.
Only attempts to extract build ID from version string if not explicitly provided.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor: Simplify build ID logic with if-elseif-else chain
Cleaner and more readable conditional structure.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Use semver-compliant format for default build ID timestamp
According to semver.org spec, build metadata must contain only ASCII
alphanumerics and hyphens [0-9A-Za-z-]. Spaces are not allowed.
Changed from: "2025-10-17 10:59:00 UTC"
Changed to: "20251017-105900"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* docs: Add changelog entry for automatic build ID extraction
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat: Add SENTRY_SDK_VERSION cache variable for downstream SDK override
Downstream SDKs can now override the SDK version at CMake configuration time
using -DSENTRY_SDK_VERSION="version+build-id". This allows setting the version
without modifying sentry.h.
When SENTRY_SDK_VERSION is set:
- The full version (with build metadata) is used for embedded library info
- Build ID is automatically extracted from the version string
- sentry.h uses the overridden version via compile definition
- Version parsing happens at CMake configuration time
Example usage:
cmake -DSENTRY_SDK_VERSION="0.11.3+20251016-9e31c9f-dirty" ...
Results in embedded info:
SENTRY_VERSION:0.11.3;BUILD:20251016-9e31c9f-dirty;...
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Check SENTRY_SDK_VERSION for empty string instead of truthiness
Aligns with the pattern used for SENTRY_SDK_NAME check.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Use SENTRY_SDK_VERSION directly for compile definitions instead of SENTRY_VERSION_FULL
* test: Add Python tests for SENTRY_SDK_VERSION override
Added two new integration tests:
1. test_sdk_version_override: Verifies that setting SENTRY_SDK_VERSION
correctly separates version and build ID in the embedded library info.
2. test_sdk_version_override_with_explicit_build_id: Verifies that
explicit SENTRY_BUILD_ID takes precedence over extracted build ID
from the version string.
Both tests inspect the actual binary using the strings command to
validate the embedded information.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Update regex to handle whitespace before SENTRY_SDK_VERSION define
The #ifndef guard adds leading whitespace to the #define line, so the
regex needs to handle optional leading whitespace and whitespace between
tokens.
This fixes the issue where CMake couldn't parse the version from sentry.h
when SENTRY_SDK_VERSION was not overridden.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Update changelog entry for SENTRY_SDK_VERSION CMake cache variable to clarify build ID extraction
---------
Co-authored-by: Claude <[email protected]>1 parent 781bfc3 commit 516c150
File tree
7 files changed
+179
-16
lines changed- include
- src
- tests
- unit
7 files changed
+179
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | | - | |
| 28 | + | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
23 | | - | |
| 33 | + | |
24 | 34 | | |
25 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
26 | 40 | | |
27 | 41 | | |
28 | 42 | | |
| |||
322 | 336 | | |
323 | 337 | | |
324 | 338 | | |
325 | | - | |
326 | | - | |
327 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
328 | 350 | | |
329 | 351 | | |
330 | 352 | | |
| |||
367 | 389 | | |
368 | 390 | | |
369 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
370 | 398 | | |
371 | 399 | | |
372 | 400 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
94 | 101 | | |
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
98 | 134 | | |
99 | 135 | | |
100 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
0 commit comments