From 04541d195562e893bda749a0c2f9d9d2d95f10cf Mon Sep 17 00:00:00 2001 From: anders_k Date: Sat, 6 Jun 2020 14:14:02 +0000 Subject: [PATCH] Try harder to generate a usable version string git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7186 212acab6-be3b-0410-9dea-997c60f758d6 --- Examples/NSISMenu.nsi | 20 +++++++++++++++++++- SConstruct | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Examples/NSISMenu.nsi b/Examples/NSISMenu.nsi index cf8d073c..9f5011f8 100644 --- a/Examples/NSISMenu.nsi +++ b/Examples/NSISMenu.nsi @@ -13,13 +13,31 @@ InstallButtonText " " CompletedText " " LangString ^ClickInstall 0 " " Caption "$(^Name)" -!ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD + +!macro UNPACKVERFIELD out in shr mask fmt +!define /redef /math ${out} ${in} >>> ${shr} +!define /redef /math ${out} ${${out}} & ${mask} +!define /redef /intfmt ${out} "${fmt}" ${${out}} +!macroend + +!ifndef VER_MAJOR & VER_MINOR +!ifdef NSIS_PACKEDVERSION +!insertmacro UNPACKVERFIELD VER_MAJOR ${NSIS_PACKEDVERSION} 24 0x0ff "%X" +!insertmacro UNPACKVERFIELD VER_MINOR ${NSIS_PACKEDVERSION} 12 0xfff "%X" +!insertmacro UNPACKVERFIELD VER_REVISION ${NSIS_PACKEDVERSION} 4 255 "%X" +!insertmacro UNPACKVERFIELD VER_BUILD ${NSIS_PACKEDVERSION} 00 0x00f "%X" +!endif +!endif +!ifdef VER_MAJOR & VER_MINOR +!define /ifndef VER_REVISION 0 +!define /ifndef VER_BUILD 0 !searchreplace VERSTR "${NSIS_VERSION}" "v" "" VIProductVersion ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD} VIAddVersionKey "ProductName" "NSIS" VIAddVersionKey "ProductVersion" "${VERSTR}" VIAddVersionKey "FileVersion" "${VERSTR}" VIAddVersionKey "FileDescription" "NSIS Menu" +VIAddVersionKey "LegalCopyright" "http://nsis.sf.net/License" !endif !include nsDialogs.nsh diff --git a/SConstruct b/SConstruct index 95a0deed..53c2c045 100644 --- a/SConstruct +++ b/SConstruct @@ -285,7 +285,7 @@ if defenv.get('VERSION','') == '' and 'VER_MAJOR' in defenv: if 'VER_REVISION' in defenv: defenv['VERSION'] += '.' + defenv['VER_REVISION'] if defenv.get('VERSION','') == '' and int(defenv['VER_PACKED'], 0) > int('0x02000000', 0): - defenv['VERSION'] = '%i' % int(defenv['VER_PACKED'][2:][:2]) # Default to major version + defenv['VERSION'] = '%i.%i.%i' % (int(defenv['VER_PACKED'][2:][:2]), int(defenv['VER_PACKED'][4:][:3]), int(defenv['VER_PACKED'][7:][:2])) print('WARNING: VERSION not set, defaulting to %s!' % defenv['VERSION']) f.write('#define NSIS_VERSION _T("v%s")\n' % defenv['VERSION'])