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
6 @rem Strip leading v if present, eg 2.21-24-g2c60e53.
\r
7 set description=%description:v=%
\r
8 set version=%description%
\r
10 @rem Get the number of commits and commit hash, eg 24-g2c60e53.
\r
13 call set n=%%n:%commit%=%%
\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
20 @rem Find major and minor.
\r
21 set minor=%version:*.=%
\r
22 call set major=%%version:.%minor%=%%
\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
32 @rem Ignore the build number if this isn't Jenkins.
\r
33 if "%BUILD_NUMBER%" == "" set BUILD_NUMBER=0
\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
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
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