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
This commit is contained in:
anders_k 2020-06-06 14:14:02 +00:00
parent 7bad4de01a
commit 04541d1955
2 changed files with 20 additions and 2 deletions

View file

@ -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

View file

@ -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'])