Skip to content
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

Provide version information in DLL #1076

Merged
merged 12 commits into from
Nov 12, 2024
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Features**:

- Provide version information in DLL ([#1076](https://github.com/getsentry/sentry-native/pull/1076))

## 0.7.12

**Features**:
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ if(WIN32)
endif()
endif()

if (WIN32 AND SENTRY_BUILD_SHARED_LIBS)
include(cmake/utils.cmake)
sentry_add_version_resource(sentry "Client Library")
endif()

# handle platform libraries
if(ANDROID)
set(_SENTRY_PLATFORM_LIBS "dl" "log")
Expand Down
21 changes: 21 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generates a version resource file from the `sentry.rc.in` template for the `TARGET` argument and adds it as a source.
function(sentry_add_version_resource TARGET FILE_DESCRIPTION)
# generate a resource output-path from the target name
set(RESOURCE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.rc")
set(RESOURCE_PATH_TMP "${RESOURCE_PATH}.in")

# Extract major, minor and patch version from SENTRY_VERSION
string(REPLACE "." ";" _SENTRY_VERSION_LIST "${SENTRY_VERSION}")
list(GET _SENTRY_VERSION_LIST 0 SENTRY_VERSION_MAJOR)
list(GET _SENTRY_VERSION_LIST 1 SENTRY_VERSION_MINOR)
list(GET _SENTRY_VERSION_LIST 2 SENTRY_VERSION_PATCH)

# Produce the resource file with configure-time replacements
configure_file("${CMAKE_SOURCE_DIR}/sentry.rc.in" "${RESOURCE_PATH_TMP}" @ONLY)

# Replace the `ORIGINAL_FILENAME` at generate-time using the generator expression `TARGET_FILE_NAME`
file(GENERATE OUTPUT ${RESOURCE_PATH} INPUT ${RESOURCE_PATH_TMP})

# Finally add the generated resource file to the target sources
target_sources("${TARGET}" PRIVATE "${RESOURCE_PATH}")
endfunction()
2 changes: 1 addition & 1 deletion external/crashpad
22 changes: 22 additions & 0 deletions sentry.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1 VERSIONINFO
FILEVERSION @SENTRY_VERSION_MAJOR@,@SENTRY_VERSION_MINOR@,@SENTRY_VERSION_PATCH@,0
PRODUCTVERSION @SENTRY_VERSION_MAJOR@,@SENTRY_VERSION_MINOR@,@SENTRY_VERSION_PATCH@,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "@FILE_DESCRIPTION@"
VALUE "FileVersion", "@SENTRY_VERSION@"
VALUE "InternalName", "sentry-native"
VALUE "LegalCopyright", "https://sentry.io"
VALUE "OriginalFilename", "$<TARGET_FILE_NAME:@TARGET@>"
VALUE "ProductName", "Sentry Native SDK"
VALUE "ProductVersion", "@SENTRY_VERSION@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
2 changes: 2 additions & 0 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ sentry_get_property(INCLUDE_DIRECTORIES)
sentry_get_property(LINK_LIBRARIES)
sentry_get_property(INTERFACE_LINK_LIBRARIES)

list(FILTER SENTRY_SOURCES EXCLUDE REGEX "\\.rc$")

add_executable(sentry_test_unit
${SENTRY_SOURCES}
main.c
Expand Down
Loading