RegisterPowerSettingNotification is unnecessary.
[nssm.git] / version.cmd
1 @rem Set default version in case git isn't available.\r
2 set description=0.0-0-prerelease\r
3 @rem Get canonical version from git tags, eg v2.21-24-g2c60e53.\r
4 for /f %%v in ('git describe --tags --long') do set description=%%v\r
5 \r
6 @rem Strip leading v if present, eg 2.21-24-g2c60e53.\r
7 set description=%description:v=%\r
8 set version=%description%\r
9 \r
10 @rem Get the number of commits and commit hash, eg 24-g2c60e53.\r
11 set n=%version:*-=%\r
12 set commit=%n:*-=%\r
13 call set n=%%n:%commit%=%%\r
14 set n=%n:~0,-1%\r
15 \r
16 @rem Strip n and commit, eg 2.21.\r
17 call set version=%%version:%n%-%commit%=%%\r
18 set version=%version:~0,-1%\r
19 \r
20 @rem Find major and minor.\r
21 set minor=%version:*.=%\r
22 call set major=%%version:.%minor%=%%\r
23 \r
24 @rem Build flags.\r
25 set flags=0L\r
26 \r
27 @rem Don't include n and commit if we match a tag exactly.\r
28 if "%n%" == "0" (set description=%major%.%minor%) else set flags=VS_FF_PRERELEASE\r
29 @rem Maybe we couldn't get the git tag.\r
30 if "%commit%" == "prerelease" set flags=VS_FF_PRERELEASE\r
31 \r
32 @rem Ignore the build number if this isn't Jenkins.\r
33 if "%BUILD_NUMBER%" == "" set BUILD_NUMBER=0\r
34 \r
35 @rem Copyright year provided by Jenkins.\r
36 set md=%BUILD_ID:*-=%\r
37 call set year=%%BUILD_ID:%md%=%%\r
38 set year=%year:~0,-1%\r
39 if "%BUILD_ID%" == "" set year=\r
40 \r
41 @rem Create version.h.\r
42 @echo>version.h.new #define NSSM_VERSION _T("%description%")\r
43 @echo>>version.h.new #define NSSM_VERSIONINFO %major%,%minor%,%n%,%BUILD_NUMBER%\r
44 @echo>>version.h.new #define NSSM_DATE _T("%DATE%")\r
45 @echo>>version.h.new #define NSSM_FILEFLAGS %flags%\r
46 @echo>>version.h.new #define NSSM_COPYRIGHT _T("Public Domain; Author Iain Patterson 2003-%year%")\r
47 \r
48 fc version.h version.h.new >NUL: 2>NUL:\r
49 if %ERRORLEVEL% == 0 (del version.h.new) else (move /y version.h.new version.h)\r