From 3624cb8da144c3603d1ffd6b18f11a3ec6400467 Mon Sep 17 00:00:00 2001 From: Bryan Berns Date: Mon, 14 Oct 2024 20:25:21 -0400 Subject: [PATCH] Modify Build To Support Production Release - Update batch files and WiX to dynamically query build version from version.h. - Update batch files and WiX to differentiate production versus beta versions. - Removed build number from About box. --- build.cmd | 12 +++++++++++- setup/Defines.wxi | 10 ++++++++-- setup/build.cmd | 14 ++++++++++++-- windirstat/Dialogs/AboutDlg.cpp | 3 +-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/build.cmd b/build.cmd index 4767a0cf..aa826325 100644 --- a/build.cmd +++ b/build.cmd @@ -2,6 +2,16 @@ TITLE Building WinDirStat SETLOCAL +:: solicit whether this is production or beta build +ECHO Please choose a release type: +ECHO 1. Beta +ECHO 2. Production +SET /p CHOICE=Enter Choice (1 or 2): +SET RELTYPE= +IF "%CHOICE%" EQU "1" SET RELTYPE=PRODUCTION +IF "%CHOICE%" EQU "2" SET RELTYPE=BETA +IF "%RELTYPE%" EQU "" EXIT /B 1 + :: setup environment variables based on location of this script SET THISDIR=%~dp0 SET THISDIR=%THISDIR:~0,-1% @@ -47,7 +57,7 @@ IF %ERRORLEVEL% EQU 0 FOR %%A IN (arm arm64 x86 x64) DO ( signtool sign /fd sha256 /tr %TSAURL% /td sha256 /d %LIBNAME% /du %LIBURL% "%BLDDIR%\*.exe" :: build the msi -CALL "%THISDIR%\setup\build.cmd" +CALL "%THISDIR%\setup\build.cmd" "%RELTYPE%" :: sign the msi signtool sign /fd sha256 /tr %TSAURL% /td sha256 /d %LIBNAME% /du %LIBURL% "%BLDDIR%\*.msi" diff --git a/setup/Defines.wxi b/setup/Defines.wxi index 2686a6d1..3ee48481 100644 --- a/setup/Defines.wxi +++ b/setup/Defines.wxi @@ -1,9 +1,15 @@ - - + + + + + + + + diff --git a/setup/build.cmd b/setup/build.cmd index 97ab9a33..1a3bef86 100644 --- a/setup/build.cmd +++ b/setup/build.cmd @@ -2,6 +2,10 @@ TITLE Building WinDirStat Installer SETLOCAL +:: setup release type +SET RELTYPE=BETA +IF "%~1" EQU "PRODUCTION" SET RELTYPE=PRODUCTION + :: setup environment variables based on location of this script CD /D "%~dp0" SET PX86=%PROGRAMFILES(X86)% @@ -15,12 +19,18 @@ IF %ERRORLEVEL% NEQ 0 ( EXIT /B 0 ) +:: grab current version information from source +FOR /F "TOKENS=2,3 DELIMS= " %%A IN ('FINDSTR "#define.PRD_" ..\windirstat\version.h') DO SET %%A=%%B + :: grab current data for installer build version -FOR /F %%X in ('git -C .. rev-list --count --all') DO SET BUILD=%%X +FOR /F %%X in ('git -C .. rev-list --count --all') DO SET PRD_BUILD=%%X + +:: create version string based on git and source +SET VERSTRING=-dMAJVER=%PRD_MAJVER% -dMINVER=%PRD_MINVER% -dPATCH=%PRD_PATCH% -dBUILD=%PRD_BUILD% :: create the installers FOR %%A IN (arm arm64 x86 x64) DO ( - candle -arch %%A "WinDirStat.wxs" -o "WinDirStat-%%A.wixobj" -dBUILD=%BUILD% + candle -arch %%A "WinDirStat.wxs" -o "WinDirStat-%%A.wixobj" -dRELTYPE=%RELTYPE% %VERSTRING% light -ext WixUIExtension -ext WixUtilExtension -sval "WinDirStat-%%A.wixobj" -o "%BLDDIR%\WinDirStat-%%A.msi" ) DEL /F "*.wixobj" diff --git a/windirstat/Dialogs/AboutDlg.cpp b/windirstat/Dialogs/AboutDlg.cpp index 1e7790ea..ef5dc5be 100644 --- a/windirstat/Dialogs/AboutDlg.cpp +++ b/windirstat/Dialogs/AboutDlg.cpp @@ -261,11 +261,10 @@ std::wstring CAboutDlg::GetAppVersion() if (GetFileVersionInfo(file.c_str(), 0, iVersionSize, tVersionInfo.data()) != 0 && VerQueryValue(tVersionInfo.data(), L"\\", reinterpret_cast(&pVersion), &iQueriedSize) != 0) { - return std::format(L"WinDirStat {}.{}.{}.{} ({})\nGit Commit: {}", + return std::format(L"WinDirStat {}.{}.{} ({})\nGit Commit: {}", std::to_wstring(HIWORD(pVersion->dwFileVersionMS)), std::to_wstring(LOWORD(pVersion->dwFileVersionMS)), std::to_wstring(HIWORD(pVersion->dwFileVersionLS)), - std::to_wstring(LOWORD(pVersion->dwFileVersionLS)), _CRT_WIDE(GIT_DATE), _CRT_WIDE(GIT_COMMIT)); }