From 789df68582e7e1189526604c070671e4bed897a5 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 4 Aug 2015 14:07:52 +0200 Subject: [PATCH 1/2] - Added update of version information for Windows build - Added template file version.html.in - Removed RS_BUILD_NUMBER from Windows executable FileVersion --- libretroshare/src/libretroshare.pro | 13 +++- libretroshare/src/retroshare/rsversion.h | 1 + libretroshare/src/retroshare/rsversion.in | 9 ++- libretroshare/src/svn_revision.bat | 2 - libretroshare/src/version_detail.bat | 48 +++++++++++++++ retroshare-gui/src/gui/help/version.html.in | 4 ++ .../src/gui/images/retroshare_win.rc | 10 ++-- retroshare-gui/src/retroshare-gui.pro | 15 +++-- retroshare-gui/src/svn_revision.bat | 2 - retroshare-gui/src/version_detail.bat | 59 +++++++++++++++++++ 10 files changed, 146 insertions(+), 17 deletions(-) delete mode 100644 libretroshare/src/svn_revision.bat create mode 100644 libretroshare/src/version_detail.bat create mode 100644 retroshare-gui/src/gui/help/version.html.in delete mode 100644 retroshare-gui/src/svn_revision.bat create mode 100644 retroshare-gui/src/version_detail.bat diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 14833d4cd..af6f27fc7 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -189,9 +189,16 @@ linux-g++-64 { } version_detail_bash_script { - QMAKE_EXTRA_TARGETS += write_version_detail - PRE_TARGETDEPS = write_version_detail - write_version_detail.commands = ./version_detail.sh + linux-* { + QMAKE_EXTRA_TARGETS += write_version_detail + PRE_TARGETDEPS = write_version_detail + write_version_detail.commands = ./version_detail.sh + } + win32 { + QMAKE_EXTRA_TARGETS += write_version_detail + PRE_TARGETDEPS = write_version_detail + write_version_detail.commands = $$PWD/version_detail.bat + } } #################### Cross compilation for windows under Linux #################### diff --git a/libretroshare/src/retroshare/rsversion.h b/libretroshare/src/retroshare/rsversion.h index 3685a569f..26cf284a6 100644 --- a/libretroshare/src/retroshare/rsversion.h +++ b/libretroshare/src/retroshare/rsversion.h @@ -8,4 +8,5 @@ // // Do not forget the 0x, since the RS_REVISION_NUMBER should be an integer. // +#define RS_REVISION_STRING "01234567" #define RS_REVISION_NUMBER 0x01234567 diff --git a/libretroshare/src/retroshare/rsversion.in b/libretroshare/src/retroshare/rsversion.in index d405810f7..cf3521ed2 100644 --- a/libretroshare/src/retroshare/rsversion.in +++ b/libretroshare/src/retroshare/rsversion.in @@ -2,4 +2,11 @@ #define RS_MINOR_VERSION 6 #define RS_BUILD_NUMBER 0 #define RS_BUILD_NUMBER_ADD "x" // <-- do we need this? -#define RS_REVISION_NUMBER $WCREV$ + +// The revision number should be the 4 first bytes of the git revision hash, which is obtained using: +// git log --pretty="%H" | head -1 | cut -c1-8 +// +// Do not forget the 0x, since the RS_REVISION_NUMBER should be an integer. +// +#define RS_REVISION_STRING "$REV$" +#define RS_REVISION_NUMBER 0x$REV$ diff --git a/libretroshare/src/svn_revision.bat b/libretroshare/src/svn_revision.bat deleted file mode 100644 index d828ece90..000000000 --- a/libretroshare/src/svn_revision.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -"D:\Programme\TortoiseSVN\bin\SubWCRev" . util\rsversion.in util\rsversion.h \ No newline at end of file diff --git a/libretroshare/src/version_detail.bat b/libretroshare/src/version_detail.bat new file mode 100644 index 000000000..ffb523a96 --- /dev/null +++ b/libretroshare/src/version_detail.bat @@ -0,0 +1,48 @@ +@echo off + +setlocal enabledelayedexpansion + +:: Search git in PATH +set GitPath= +for %%P in ("%PATH:;=" "%") do ( + if exist "%%~P.\git.exe" ( + set GitPath=%%~P + goto found_git + ) +) + +:found_git +if "%GitPath%"=="" ( + echo git not found in PATH. Version update cancelled. + endlocal + exit /B 0 +) + +echo Update version + +:: Retrieve git information +set RsHash= + +pushd "%~dp0" +for /f "tokens=1*" %%A in ('"git log --pretty=format:"%%H" --max-count=1"') do set RsHash=%%A +popd + +if "%RsHash%"=="" ( + echo Git hash not found. + endlocal + exit /B 1 +) + +:: Create file +set InFile=%~dp0retroshare\rsversion.in +set OutFile=%~dp0retroshare\rsversion.h +if exist "%OutFile%" del /Q "%OutFile%" + +for /f "tokens=* delims= " %%a in (%InFile%) do ( + set line=%%a + set line=!line:$REV$=%RsHash:~0,8%! + echo !line!>>"%OutFile%" +) + +endlocal +exit /B 0 diff --git a/retroshare-gui/src/gui/help/version.html.in b/retroshare-gui/src/gui/help/version.html.in new file mode 100644 index 000000000..189d71df2 --- /dev/null +++ b/retroshare-gui/src/gui/help/version.html.in @@ -0,0 +1,4 @@ +Retroshare Gui version : +Git version : $Branch$ +$Hash$ +$Date$ \ No newline at end of file diff --git a/retroshare-gui/src/gui/images/retroshare_win.rc b/retroshare-gui/src/gui/images/retroshare_win.rc index 404d6ecd2..76840ad79 100644 --- a/retroshare-gui/src/gui/images/retroshare_win.rc +++ b/retroshare-gui/src/gui/images/retroshare_win.rc @@ -5,11 +5,11 @@ IDI_ICON1 ICON "logo/logo_64.ico" #define STRINGIZER(version) #version -#define VERSION_STRING(major,minor,build,buildadd,revision) STRINGIZER(major) "." STRINGIZER(minor) "." STRINGIZER(build) buildadd "." STRINGIZER(revision) +#define VERSION_STRING(major,minor,build,buildadd,revision) STRINGIZER(major) "." STRINGIZER(minor) "." STRINGIZER(build) buildadd "." revision VS_VERSION_INFO VERSIONINFO -FILEVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_BUILD_NUMBER,RS_REVISION_NUMBER -PRODUCTVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_BUILD_NUMBER,RS_REVISION_NUMBER +FILEVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_BUILD_NUMBER,0 +PRODUCTVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_BUILD_NUMBER,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_NT_WINDOWS32 @@ -22,11 +22,11 @@ BEGIN BEGIN VALUE "CompanyName", "" VALUE "FileDescription", "RetroShare" - VALUE "FileVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_NUMBER) + VALUE "FileVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_STRING) VALUE "InternalName", "RetroShare" VALUE "OriginalFilename", "RetroShare.exe" VALUE "ProductName", "RetroShare" - VALUE "ProductVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_NUMBER) + VALUE "ProductVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_STRING) VALUE "LegalCopyright", "" END END diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index ec9517108..79988dce8 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -118,10 +118,17 @@ linux-g++-64 { } version_detail_bash_script { - DEFINES += ADD_LIBRETROSHARE_VERSION_INFO - QMAKE_EXTRA_TARGETS += write_version_detail - PRE_TARGETDEPS = write_version_detail - write_version_detail.commands = ./version_detail.sh + linux-* { + DEFINES += ADD_LIBRETROSHARE_VERSION_INFO + QMAKE_EXTRA_TARGETS += write_version_detail + PRE_TARGETDEPS = write_version_detail + write_version_detail.commands = ./version_detail.sh + } + win32 { + QMAKE_EXTRA_TARGETS += write_version_detail + PRE_TARGETDEPS = write_version_detail + write_version_detail.commands = $$PWD/version_detail.bat + } } install_rs { diff --git a/retroshare-gui/src/svn_revision.bat b/retroshare-gui/src/svn_revision.bat deleted file mode 100644 index c32e950fc..000000000 --- a/retroshare-gui/src/svn_revision.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -"D:\Programme\TortoiseSVN\bin\SubWCRev" . util\rsguiversion.in util\rsguiversion.cpp \ No newline at end of file diff --git a/retroshare-gui/src/version_detail.bat b/retroshare-gui/src/version_detail.bat new file mode 100644 index 000000000..e413fc70e --- /dev/null +++ b/retroshare-gui/src/version_detail.bat @@ -0,0 +1,59 @@ +@echo off + +setlocal enabledelayedexpansion + +:: Search git in PATH +set GitPath= +for %%P in ("%PATH:;=" "%") do ( + if exist "%%~P.\git.exe" ( + set GitPath=%%~P + goto found_git + ) +) + +:found_git +if "%GitPath%"=="" ( + echo git not found in PATH. Version update cancelled. + endlocal + exit /B 0 +) + +echo Update version + +:: Retrieve git information +set RsBranch= +set RsHash= + +pushd "%~dp0" +for /f "tokens=1*" %%A in ('"git log --pretty=format:"%%H" --max-count=1"') do set RsHash=%%A +for /f "tokens=*" %%A in ('git rev-parse --abbrev-ref HEAD') do set RsBranch=%%A +popd + +if "%RsBranch%"=="" ( + echo Git branch not found. + endlocal + exit /B 1 +) +if "%RsHash%"=="" ( + echo Git hash not found. + endlocal + exit /B 1 +) + +set RsDate=%date% %TIME% + +:: Create file +set InFile=%~dp0gui\help\version.html.in +set OutFile=%~dp0gui\help\version.html +if exist "%OutFile%" del /Q "%OutFile%" + +for /f "tokens=* delims= " %%a in (%InFile%) do ( + set line=%%a + set line=!line:$Hash$=%RsHash%! + set line=!line:$Branch$=%RsBranch%! + set line=!line:$Date$=%RsDate%! + echo !line!>>"%OutFile%" +) + +endlocal +exit /B 0 From 43db562c2a171e2b735886fa8a33b0cd9e7aef4b Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 4 Aug 2015 19:02:13 +0200 Subject: [PATCH 2/2] Fixed build script for Windows installer --- build_scripts/Windows/GetRsVersion.bat | 43 ++++++++++++++++++++++++ build_scripts/Windows/make_installer.bat | 25 ++++++-------- build_scripts/Windows/retroshare.nsi | 7 ++-- 3 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 build_scripts/Windows/GetRsVersion.bat diff --git a/build_scripts/Windows/GetRsVersion.bat b/build_scripts/Windows/GetRsVersion.bat new file mode 100644 index 000000000..153b5969d --- /dev/null +++ b/build_scripts/Windows/GetRsVersion.bat @@ -0,0 +1,43 @@ +@:: Usage: +@:: call GetRsVersion.bat Define Variable + +@setlocal +@echo off + +set Define=%~1 +if "%Define%"=="" ( + echo. + echo Parameter error + endlocal + exit /B1 +) + +set Variable=%~2 +if "%Variable%"=="" ( + echo. + echo Parameter error + endlocal + exit /B1 +) + +set Result= +set VersionFile="%~dp0..\..\libretroshare\src\retroshare\rsversion.h" + +if not exist "%VersionFile%" ( + echo. + echo Version file doesn't exist. + echo %VersionFile% + endlocal + exit /B1 +) + +for /F "usebackq tokens=1,2,3" %%A in (%VersionFile%) do ( + if "%%A"=="#define" ( + if "%%B"=="%Define%" ( + set Result=%%~C + ) + ) +) + +endlocal & set %Variable%=%Result% +exit /B 0 \ No newline at end of file diff --git a/build_scripts/Windows/make_installer.bat b/build_scripts/Windows/make_installer.bat index e2f8cfc14..42b3776e9 100644 --- a/build_scripts/Windows/make_installer.bat +++ b/build_scripts/Windows/make_installer.bat @@ -24,32 +24,27 @@ if "%MinGWDir%" NEQ "" set NSIS_PARAM=%NSIS_PARAM% /DMINGWDIR="%MinGWDir%" if "%OutDir%" NEQ "" set NSIS_PARAM=%NSIS_PARAM% /DOUTDIR="%OutDir%" :: Scan version from source +set Revision= set BuildAdd= -set VersionFile="%SourceDir%\libretroshare\src\retroshare\rsversion.h" +call "%~dp0GetRsVersion.bat" RS_REVISION_STRING Revision +if errorlevel 1 goto exit +call "%~dp0GetRsVersion.bat" RS_BUILD_NUMBER_ADD BuildAdd +if errorlevel 1 goto exit -if not exist "%VersionFile%" ( +if "%Revision%"=="" ( echo. - echo Version file doesn't exist. + echo Version not found in echo %VersionFile% - goto :exit + goto exit ) - -for /F "usebackq tokens=1,2,3" %%A in (%VersionFile%) do ( - if "%%A"=="#define" ( - if "%%B"=="RS_BUILD_NUMBER_ADD" ( - set BuildAdd=%%~C - ) - ) -) - if "%BuildAdd%"=="" ( echo. echo Version not found in echo %VersionFile% - goto :exit + goto exit ) -set NSIS_PARAM=%NSIS_PARAM% /DBUILDADD=%BuildAdd% +set NSIS_PARAM=%NSIS_PARAM% /DREVISION=%Revision% /DBUILDADD=%BuildAdd% :: Create installer "%NSIS_EXE%" %NSIS_PARAM% "%~dp0retroshare.nsi" diff --git a/build_scripts/Windows/retroshare.nsi b/build_scripts/Windows/retroshare.nsi index d6f6f9f9c..01b381657 100644 --- a/build_scripts/Windows/retroshare.nsi +++ b/build_scripts/Windows/retroshare.nsi @@ -42,7 +42,7 @@ !GetDllVersion "${RELEASEDIR}\retroshare-gui\src\release\RetroShare.exe" VERSION_ !define VERSION ${VERSION_1}.${VERSION_2}.${VERSION_3}${BUILDADD} -!define REVISION ${VERSION_4} +;!define REVISION ${VERSION_4} # Check version !ifndef REVISION @@ -53,6 +53,9 @@ !error "REVISION is not defined" !endif +# Date +!define /date Date "%Y%m%d" + # Application name and version !define APPNAME "RetroShare" !define APPNAMEANDVERSION "${APPNAME} ${VERSION}" @@ -68,7 +71,7 @@ # Main Install settings Name "${APPNAMEANDVERSION}" InstallDirRegKey HKLM "Software\${APPNAME}" "" -OutFile "${OUTDIR_}RetroShare_${VERSION}_${REVISION}_setup.exe" +OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-setup.exe" BrandingText "${APPNAMEANDVERSION}" RequestExecutionlevel highest # Use compression