Add version system
This commit is contained in:
parent
4ae052ee18
commit
0f83170c43
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.vs/
|
||||
build/
|
||||
version.h
|
||||
|
48
WinChat/PreBuild.bat
Normal file
48
WinChat/PreBuild.bat
Normal file
@ -0,0 +1,48 @@
|
||||
@echo off
|
||||
|
||||
echo [Pre Build] Startup
|
||||
|
||||
::Set Version
|
||||
echo [Pre Build] Setting version...
|
||||
|
||||
::First make sure git is in the path
|
||||
where git >nul 2>&1
|
||||
if %errorlevel% neq 0 goto noGit
|
||||
goto yesGit
|
||||
|
||||
:noGit
|
||||
echo [Pre Build] Error: git not found on PATH!
|
||||
exit 1
|
||||
|
||||
::We have git on the command line, so set the version string
|
||||
:yesGit
|
||||
git describe HEAD > temp1
|
||||
git branch --show-current > temp2
|
||||
set /p commit= < temp1
|
||||
set /p branch= < temp2
|
||||
del temp1
|
||||
del temp2
|
||||
|
||||
::If the current branch is stable, don't include it in the version string
|
||||
if "%branch%" == "stable" goto noBranch
|
||||
|
||||
set version=%commit%+%branch%
|
||||
goto testOutput
|
||||
|
||||
:noBranch
|
||||
set version=%commit%
|
||||
|
||||
::Don't touch the version file if it's already up to date
|
||||
:testOutput
|
||||
set /p oldVersion= < src\version.h
|
||||
if "%oldVersion%" == "#define APPVERSION "%version%"" goto sameVersion
|
||||
|
||||
echo #define APPVERSION "%version%"> src\version.h
|
||||
goto continue
|
||||
|
||||
:sameVersion
|
||||
echo [Pre Build] Same version
|
||||
|
||||
:continue
|
||||
echo [Pre Build] Exit
|
||||
exit
|
@ -64,6 +64,9 @@
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>PreBuild.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
@ -82,6 +85,9 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>PreBuild.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
|
@ -1,7 +1,11 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#define APPNAME "WinChat"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::printf("WinChat\n");
|
||||
std::printf(APPNAME " " APPVERSION "\n");
|
||||
|
||||
std::cin.get();
|
||||
return EXIT_SUCCESS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user