Skip to content

Commit

Permalink
Add executable version information (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
vktr committed Mar 2, 2018
1 parent f03e655 commit 658371a
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ project("PicoTorrent")
# Generate version information file
file (STRINGS "${CMAKE_SOURCE_DIR}/VERSION" VERSION)

# Build version parts
set(VERSION_TMP "${VERSION}")
string(REPLACE "." ";" VERSION_LIST ${VERSION_TMP})
list(GET VERSION_LIST 0 VERSION_MAJOR)
list(GET VERSION_LIST 1 VERSION_MINOR)
list(GET VERSION_LIST 2 VERSION_REVISION)

# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
Expand Down Expand Up @@ -60,6 +67,11 @@ add_definitions(
-DUNICODE
-DWIN32
-DWIN32_LEAN_AND_MEAN

-DPICO_GIT_COMMITISH=${GIT_COMMITISH}
-DPICO_VERSION_MAJOR=${VERSION_MAJOR}
-DPICO_VERSION_MINOR=${VERSION_MINOR}
-DPICO_VERSION_REVISION=${VERSION_REVISION}
)

include_directories(
Expand Down
30 changes: 30 additions & 0 deletions src/picotorrent/resources.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "wx/msw/wx.rc"
#include "version.h"

AppIcon ICON "..\\..\\res\\app.ico"

1027 LANGFILE "..\\..\\lang\\1027.json"
Expand All @@ -19,3 +21,31 @@ AppIcon ICON "..\\..\\res\\app.ico"
1057 LANGFILE "..\\..\\lang\\1057.json"
1062 LANGFILE "..\\..\\lang\\1062.json"
1079 LANGFILE "..\\..\\lang\\1079.json"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILE_VERSION
PRODUCTVERSION VER_PRODUCT_VERSION
FILEFLAGSMASK 0x3fL
FILEFLAGS VER_FILEFLAGS
FILEOS VER_FILEOS
FILETYPE VER_FILETYPE
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", VER_FILE_DESCRIPTION_STR "\0"
VALUE "FileVersion", VER_FILE_VERSION_STR "\0"
VALUE "InternalName", VER_INTERNAL_NAME_STR "\0"
VALUE "LegalCopyright", VER_COPYRIGHT_STR "\0"
VALUE "OriginalFilename", VER_ORIGINAL_FILENAME_STR "\0"
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "ProductVersion", VER_PRODUCT_VERSION_STR "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
26 changes: 26 additions & 0 deletions src/picotorrent/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)

#define VER_FILE_DESCRIPTION_STR "PicoTorrent"
#define VER_FILE_VERSION PICO_VERSION_MAJOR, PICO_VERSION_MINOR, PICO_VERSION_REVISION
#define VER_FILE_VERSION_STR STRINGIZE(PICO_VERSION_MAJOR) \
"." STRINGIZE(PICO_VERSION_MINOR) \
"." STRINGIZE(PICO_VERSION_REVISION) \
" (" STRINGIZE(PICO_GIT_COMMITISH) ")" \

#define VER_PRODUCTNAME_STR "PicoTorrent"
#define VER_PRODUCT_VERSION VER_FILE_VERSION
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".exe"
#define VER_INTERNAL_NAME_STR VER_ORIGINAL_FILENAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2018, Viktor Elofsson and contributors"

#ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG
#else
#define VER_VER_DEBUG 0
#endif

#define VER_FILEOS 0x00040004
#define VER_FILEFLAGS VER_VER_DEBUG
#define VER_FILETYPE 0x00000001

0 comments on commit 658371a

Please sign in to comment.