-
-
Notifications
You must be signed in to change notification settings - Fork 200
feat: Add SENTRY_SDK_VERSION CMake override for downstream SDKs #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <noreply@anthropic.com>
…_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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Cleaner and more readable conditional structure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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 <noreply@anthropic.com>
Aligns with the pattern used for SENTRY_SDK_NAME check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
…of SENTRY_VERSION_FULL
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Contributor
Author
|
the failing test is unrelated to the changes in this PR. see #1418 |
…le to clarify build ID extraction
…erride-for-downstream
supervacuus
approved these changes
Oct 20, 2025
Collaborator
supervacuus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very sensible.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SENTRY_SDK_VERSIONCMake cache variable to allow downstream SDKs to override the SDK version at configuration time without modifyingsentry.h.Problem
The previous PR (#1416) attempted to solve the build ID extraction by parsing
sentry.hafter it was modified by downstream SDKs. However, this approach only worked on the second CMake configuration run, aftersentry.hhad been patched. This is not ideal for downstream SDK workflows.Solution
Instead of modifying and re-reading
sentry.h, downstream SDKs can now set the SDK version directly via CMake:cmake -DSENTRY_SDK_VERSION="0.11.3+20251016-9e31c9f-dirty" ...How it works:
SENTRY_SDK_VERSIONis set, it takes precedence over the version insentry.h+)sentry.hchecks ifSENTRY_SDK_VERSIONis already defined (similar to howSENTRY_SDK_NAMEworks)Result
Embedded library info correctly separates version and build ID on the first CMake configuration:
Changes
SENTRY_SDK_VERSIONcache variable and logic to use it instead of readingsentry.hSENTRY_SDK_VERSIONis already defined before setting default valueTesting
Verified three scenarios:
SENTRY_VERSION:0.11.3;BUILD:20251016-9e31c9f-dirtySENTRY_VERSION:0.11.3;BUILD:20251017-132848(timestamp in YYYYMMDD-HHMMSS format)SENTRY_VERSION:0.11.3;BUILD:custom-idAll embedded info tests pass ✓
Python integration tests added:
test_sdk_version_override: Verifies build ID extraction from version stringtest_sdk_version_override_with_explicit_build_id: Verifies explicit build ID takes precedence🤖 Generated with Claude Code