int usage(int);\r
\r
#define NSSM _T("nssm")\r
-#define NSSM_VERSION _T("2.21")\r
-#define NSSM_VERSIONINFO 2,21,0,0\r
-#define NSSM_DATE _T("2013-11-24")\r
+#include "version.h"\r
\r
/*\r
Throttle the restart of the service if it stops before this many\r
>\r
<Tool\r
Name="VCPreBuildEventTool"\r
+ Description="Setting version information"\r
+ CommandLine="version.cmd"\r
/>\r
<Tool\r
Name="VCCustomBuildTool"\r
>\r
<Tool\r
Name="VCPreBuildEventTool"\r
+ Description="Setting version information"\r
+ CommandLine="version.cmd"\r
/>\r
<Tool\r
Name="VCCustomBuildTool"\r
>\r
<Tool\r
Name="VCPreBuildEventTool"\r
+ Description="Setting version information"\r
+ CommandLine="version.cmd"\r
/>\r
<Tool\r
Name="VCCustomBuildTool"\r
>\r
<Tool\r
Name="VCPreBuildEventTool"\r
+ Description="Setting version information"\r
+ CommandLine="version.cmd"\r
/>\r
<Tool\r
Name="VCCustomBuildTool"\r
--- /dev/null
+@rem Set default version in case git isn't available.\r
+set description=0.0-0-prerelease\r
+@rem Get canonical version from git tags, eg v2.21-24-g2c60e53.\r
+for /f %%v in ('git describe --tags --long') do set description=%%v\r
+\r
+@rem Strip leading v if present, eg 2.21-24-g2c60e53.\r
+set description=%description:v=%\r
+set version=%description%\r
+\r
+@rem Get the number of commits and commit hash, eg 24-g2c60e53.\r
+set n=%version:*-=%\r
+set commit=%n:*-=%\r
+call set n=%%n:%commit%=%%\r
+set n=%n:~0,-1%\r
+\r
+@rem Strip n and commit, eg 2.21.\r
+call set version=%%version:%n%-%commit%=%%\r
+set version=%version:~0,-1%\r
+\r
+@rem Find major and minor.\r
+set minor=%version:*.=%\r
+call set major=%%version:.%minor%=%%\r
+\r
+@rem Don't include n and commit if we match a tag exactly.\r
+if "%n%" == "0" set description=%major%.%minor%\r
+\r
+@rem Ignore the build number if this isn't Jenkins.\r
+if "%BUILD_NUMBER%" == "" set BUILD_NUMBER=0\r
+\r
+@rem Create version.h.\r
+@echo>version.h #define NSSM_VERSION _T("%description%")\r
+@echo>>version.h #define NSSM_VERSIONINFO %major%,%minor%,%n%,%BUILD_NUMBER%\r
+@echo>>version.h #define NSSM_DATE _T("%DATE%")\r