-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide version information in DLL (#1076)
* Provide version information in DLL * Update changelog * only include rc file when building dll * move rc code gen, change product name, make FileVersion the same as ProductVersion * Further clean-ups and reuse for crashpad * moved code to utility function * that function uses the target argument to generate all required files (only manual parameter is the file description) * switched from manual string replacement to `configure_file()` which creates another intermediate file * to generate the final *.rc file we use file(GENERATE) together with `TARGET_FILE_NAME` generator expression to retrieve "OriginFilename" during the generate-time (between configure and build phase). * ensure that unit-tests don't pick up unnecessary resource-sources * update changelog * update changelog * replace `TARGET` parameter with `TGT` for good measure * add test-fixture checks for binaries * conditionally include windows-specific module * don't include utils.cmake only for shared-libs build... ...because even if we generate static client libraries crashpad_handler.exe and crashpad_wer.dll should still be versioned. * update crashpad submodule to getsentry ref --------- Co-authored-by: Mischan Toosarani-Hausberger <mischan@abovevacant.com>
- Loading branch information
1 parent
d241dbc
commit 7a882d3
Showing
10 changed files
with
100 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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 `TGT` argument and adds it as a source. | ||
function(sentry_add_version_resource TGT FILE_DESCRIPTION) | ||
# generate a resource output-path from the target name | ||
set(RESOURCE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${TGT}.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("${TGT}" PRIVATE "${RESOURCE_PATH}") | ||
endfunction() |
This file contains 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
This file contains 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
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:@TGT@>" | ||
VALUE "ProductName", "Sentry Native SDK" | ||
VALUE "ProductVersion", "@SENTRY_VERSION@" | ||
END | ||
END | ||
BLOCK "VarFileInfo" | ||
BEGIN | ||
VALUE "Translation", 0x409, 1252 | ||
END | ||
END |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pathlib | ||
import win32api | ||
|
||
sentry_version = "0.7.12" | ||
|
||
|
||
def check_binary_version(binary_path: pathlib.Path): | ||
if not binary_path.exists(): | ||
return | ||
|
||
info = win32api.GetFileVersionInfo(str(binary_path), "\\") | ||
ms = info["FileVersionMS"] | ||
ls = info["FileVersionLS"] | ||
file_version = (ms >> 16, ms & 0xFFFF, ls >> 16, ls & 0xFFFF) | ||
file_version = f"{file_version[0]}.{file_version[1]}.{file_version[2]}" | ||
if sentry_version != file_version: | ||
raise RuntimeError( | ||
f"Binary {binary_path.parts[-1]} has a different version ({file_version}) than expected ({sentry_version})." | ||
) |