mirror of
https://github.com/rehlds/rehlds.git
synced 2024-12-27 23:25:45 +03:00
reworked windows appversion
This commit is contained in:
parent
41f635869a
commit
a0bdadd679
@ -7,6 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReHLDS", "..\rehlds\msvc\Re
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{792DF067-9904-4579-99B9-46C17277ADE3} = {792DF067-9904-4579-99B9-46C17277ADE3}
|
||||
{CEB94F7C-E459-4673-AABB-36E2074396C0} = {CEB94F7C-E459-4673-AABB-36E2074396C0}
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06} = {6973DCA5-253C-4D84-B51E-187E035EAE06}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cppunitlite", "..\dep\cppunitlite\msvc\cppunitlite.vcxproj", "{CEB94F7C-E459-4673-AABB-36E2074396C0}"
|
||||
@ -14,6 +15,9 @@ EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\dep\bzip2\msvc\bzip2.vcxproj", "{792DF067-9904-4579-99B9-46C17277ADE3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dedicated", "..\rehlds\dedicated\msvc\dedicated.vcxproj", "{D49883F3-5C5C-4B9F-B9C7-B31518F228D4}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06} = {6973DCA5-253C-4D84-B51E-187E035EAE06}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D2516ABB-21F2-4393-8CC9-2BD2D3316CD6}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
@ -21,6 +25,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Console", "..\rehlds\HLTV\Console\msvc\Console.vcxproj", "{D5CAB879-D54F-456F-8592-31D549CFD1D8}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06} = {6973DCA5-253C-4D84-B51E-187E035EAE06}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "..\rehlds\HLTV\Core\msvc\Core.vcxproj", "{52F752EA-73D1-422D-B805-17EF1FB20E09}"
|
||||
EndProject
|
||||
@ -32,6 +39,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proxy", "..\rehlds\HLTV\Pro
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filesystem_stdio", "..\rehlds\filesystem\FileSystem_Stdio\msvc\filesystem_stdio.vcxproj", "{A428392F-52FB-489E-87D8-623528C7F4F9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "version", "..\rehlds\version\msvc\version.vcxproj", "{6973DCA5-253C-4D84-B51E-187E035EAE06}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug Play|Win32 = Debug Play|Win32
|
||||
@ -134,8 +143,23 @@ Global
|
||||
{A428392F-52FB-489E-87D8-623528C7F4F9}.Release|Win32.Build.0 = Release|Win32
|
||||
{A428392F-52FB-489E-87D8-623528C7F4F9}.Test Fixes|Win32.ActiveCfg = Debug|Win32
|
||||
{A428392F-52FB-489E-87D8-623528C7F4F9}.Tests|Win32.ActiveCfg = Debug|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug Play|Win32.ActiveCfg = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug Play|Win32.Build.0 = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug|Win32.ActiveCfg = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Debug|Win32.Build.0 = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Release Play|Win32.ActiveCfg = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Release Play|Win32.Build.0 = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Release|Win32.Build.0 = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Test Fixes|Win32.ActiveCfg = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Test Fixes|Win32.Build.0 = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Tests|Win32.ActiveCfg = Release|Win32
|
||||
{6973DCA5-253C-4D84-B51E-187E035EAE06}.Tests|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3225EDB9-2B71-42E4-99DB-ED6E6E2A2EC6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -83,6 +83,11 @@
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="hltv.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\version\msvc\version.vcxproj">
|
||||
<Project>{6973dca5-253c-4d84-b51e-187e035eae06}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D5CAB879-D54F-456F-8592-31D549CFD1D8}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
@ -157,10 +162,6 @@
|
||||
<Outputs>build.always.run</Outputs>
|
||||
<Inputs>build.always.run</Inputs>
|
||||
</CustomBuildStep>
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\..\version\" "$(ProjectDir)..\..\..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
@ -193,12 +194,8 @@
|
||||
<Outputs>build.always.run</Outputs>
|
||||
<Inputs>build.always.run</Inputs>
|
||||
</CustomBuildStep>
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\..\version\" "$(ProjectDir)..\..\..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -1,206 +0,0 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo on
|
||||
::
|
||||
:: Pre-build auto-versioning script
|
||||
::
|
||||
|
||||
set srcdir=%~1
|
||||
set repodir=%~2
|
||||
|
||||
set old_version=
|
||||
set version_major=0
|
||||
set version_minor=0
|
||||
set version_maintenance=0
|
||||
set version_modifed=
|
||||
|
||||
set commitSHA=
|
||||
set commitURL=
|
||||
set commitCount=0
|
||||
set branch_name=master
|
||||
|
||||
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
|
||||
set "YYYY=%dt:~0,4%"
|
||||
set "MM=%dt:~4,2%"
|
||||
set "DD=%dt:~6,2%"
|
||||
set "hour=%dt:~8,2%"
|
||||
set "min=%dt:~10,2%"
|
||||
set "sec=%dt:~12,2%"
|
||||
|
||||
::
|
||||
:: Remove leading zero from MM (e.g 09 > 9)
|
||||
::
|
||||
for /f "tokens=* delims=0" %%I in ("%MM%") do set MM=%%I
|
||||
|
||||
::
|
||||
:: Index into array to get month name
|
||||
::
|
||||
for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I"
|
||||
|
||||
::
|
||||
:: Check for git.exe presence
|
||||
::
|
||||
CALL git.exe describe >NUL 2>&1
|
||||
set errlvl="%ERRORLEVEL%"
|
||||
|
||||
::
|
||||
:: Read old appversion.h, if present
|
||||
::
|
||||
IF EXIST "%srcdir%\appversion.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==APP_VERSION (
|
||||
:: Remove quotes
|
||||
set v=%%k
|
||||
set old_version=!v:"=!
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
IF %errlvl% == "1" (
|
||||
echo can't locate git.exe - auto-versioning step won't be performed
|
||||
|
||||
:: if we haven't appversion.h, we need to create it
|
||||
IF NOT "%old_version%" == "" (
|
||||
set commitCount=0
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read major, minor and maintenance version components from Version.h
|
||||
::
|
||||
IF EXIST "%srcdir%\version.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==VERSION_MAJOR set version_major=%%k
|
||||
IF %%j==VERSION_MINOR set version_minor=%%k
|
||||
IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read revision and release date from it
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
:: Get current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO (
|
||||
set branch_name=%%i
|
||||
)
|
||||
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO (
|
||||
IF NOT [%%i] == [] (
|
||||
set commitCount=%%i
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Get remote url repository
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
|
||||
set branch_remote=origin
|
||||
:: Get remote name by current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." config branch.!branch_name!.remote"') DO (
|
||||
set branch_remote=%%i
|
||||
)
|
||||
:: Get remote url
|
||||
FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
:: Get commit id
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO (
|
||||
set shafull=%%i
|
||||
set commitSHA=!shafull:~0,+7!
|
||||
)
|
||||
|
||||
IF [!commitURL!] == [] (
|
||||
|
||||
FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=!commitURL!/commit/
|
||||
)
|
||||
|
||||
) ELSE (
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
:: replace : to /
|
||||
set commitURL=!commitURL::=/!
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=https://!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=https://!commitURL!/commit/
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Detect local modifications
|
||||
::
|
||||
set localChanged=0
|
||||
IF NOT %errlvl% == "1" (
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO (
|
||||
set localChanged=1
|
||||
)
|
||||
)
|
||||
|
||||
IF [%localChanged%]==[1] (
|
||||
set version_modifed=+m
|
||||
)
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
::
|
||||
|
||||
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed%
|
||||
|
||||
::
|
||||
:: Update appversion.h if version has changed or modifications/mixed revisions detected
|
||||
::
|
||||
IF NOT "%new_version%"=="%old_version%" goto _update
|
||||
goto _exit
|
||||
|
||||
:_update
|
||||
echo Updating appversion.h, new version is "%new_version%", the old one was %old_version%
|
||||
|
||||
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
|
||||
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo // This file is generated automatically.>>"%srcdir%\appversion.h"
|
||||
echo // Don't edit it.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // Version defines>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_DATE "%month% %DD% %YYYY%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
:_exit
|
||||
exit /B 0
|
@ -70,12 +70,6 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\version\" "$(ProjectDir)..\..\")</Command>
|
||||
</PreBuildEvent>
|
||||
<PreBuildEvent>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)")</Command>
|
||||
</PostBuildEvent>
|
||||
@ -115,12 +109,6 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\version\" "$(ProjectDir)..\..\")</Command>
|
||||
</PreBuildEvent>
|
||||
<PreBuildEvent>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)")</Command>
|
||||
</PostBuildEvent>
|
||||
@ -184,7 +172,12 @@
|
||||
<ItemGroup>
|
||||
<Image Include="icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\version\msvc\version.vcxproj">
|
||||
<Project>{6973dca5-253c-4d84-b51e-187e035eae06}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -1,206 +0,0 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
::
|
||||
:: Pre-build auto-versioning script
|
||||
::
|
||||
|
||||
set srcdir=%~1
|
||||
set repodir=%~2
|
||||
|
||||
set old_version=
|
||||
set version_major=0
|
||||
set version_minor=0
|
||||
set version_maintenance=0
|
||||
set version_modifed=
|
||||
|
||||
set commitSHA=
|
||||
set commitURL=
|
||||
set commitCount=0
|
||||
set branch_name=master
|
||||
|
||||
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
|
||||
set "YYYY=%dt:~0,4%"
|
||||
set "MM=%dt:~4,2%"
|
||||
set "DD=%dt:~6,2%"
|
||||
set "hour=%dt:~8,2%"
|
||||
set "min=%dt:~10,2%"
|
||||
set "sec=%dt:~12,2%"
|
||||
|
||||
::
|
||||
:: Remove leading zero from MM (e.g 09 > 9)
|
||||
::
|
||||
for /f "tokens=* delims=0" %%I in ("%MM%") do set MM=%%I
|
||||
|
||||
::
|
||||
:: Index into array to get month name
|
||||
::
|
||||
for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I"
|
||||
|
||||
::
|
||||
:: Check for git.exe presence
|
||||
::
|
||||
CALL git.exe describe >NUL 2>&1
|
||||
set errlvl="%ERRORLEVEL%"
|
||||
|
||||
::
|
||||
:: Read old appversion.h, if present
|
||||
::
|
||||
IF EXIST "%srcdir%\appversion.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==APP_VERSION (
|
||||
:: Remove quotes
|
||||
set v=%%k
|
||||
set old_version=!v:"=!
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
IF %errlvl% == "1" (
|
||||
echo can't locate git.exe - auto-versioning step won't be performed
|
||||
|
||||
:: if we haven't appversion.h, we need to create it
|
||||
IF NOT "%old_version%" == "" (
|
||||
set commitCount=0
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read major, minor and maintenance version components from Version.h
|
||||
::
|
||||
IF EXIST "%srcdir%\version.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==VERSION_MAJOR set version_major=%%k
|
||||
IF %%j==VERSION_MINOR set version_minor=%%k
|
||||
IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read revision and release date from it
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
:: Get current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO (
|
||||
set branch_name=%%i
|
||||
)
|
||||
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO (
|
||||
IF NOT [%%i] == [] (
|
||||
set commitCount=%%i
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Get remote url repository
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
|
||||
set branch_remote=origin
|
||||
:: Get remote name by current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." config branch.!branch_name!.remote"') DO (
|
||||
set branch_remote=%%i
|
||||
)
|
||||
:: Get remote url
|
||||
FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
:: Get commit id
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO (
|
||||
set shafull=%%i
|
||||
set commitSHA=!shafull:~0,+7!
|
||||
)
|
||||
|
||||
IF [!commitURL!] == [] (
|
||||
|
||||
FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=!commitURL!/commit/
|
||||
)
|
||||
|
||||
) ELSE (
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
:: replace : to /
|
||||
set commitURL=!commitURL::=/!
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=https://!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=https://!commitURL!/commit/
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Detect local modifications
|
||||
::
|
||||
set localChanged=0
|
||||
IF NOT %errlvl% == "1" (
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO (
|
||||
set localChanged=1
|
||||
)
|
||||
)
|
||||
|
||||
IF [%localChanged%]==[1] (
|
||||
set version_modifed=+m
|
||||
)
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
::
|
||||
|
||||
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed%
|
||||
|
||||
::
|
||||
:: Update appversion.h if version has changed or modifications/mixed revisions detected
|
||||
::
|
||||
IF NOT "%new_version%"=="%old_version%" goto _update
|
||||
goto _exit
|
||||
|
||||
:_update
|
||||
echo Updating appversion.h, new version is "%new_version%", the old one was %old_version%
|
||||
|
||||
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
|
||||
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo // This file is generated automatically.>>"%srcdir%\appversion.h"
|
||||
echo // Don't edit it.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // Version defines>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_DATE "%month% %DD% %YYYY%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
:_exit
|
||||
exit /B 0
|
@ -461,6 +461,9 @@
|
||||
<ProjectReference Include="..\..\dep\cppunitlite\msvc\cppunitlite.vcxproj">
|
||||
<Project>{ceb94f7c-e459-4673-aabb-36e2074396c0}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\version\msvc\version.vcxproj">
|
||||
<Project>{6973dca5-253c-4d84-b51e-187e035eae06}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{70A2B904-B7DB-4C48-8DE0-AF567360D572}</ProjectGuid>
|
||||
@ -570,10 +573,6 @@
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@ -607,10 +606,6 @@
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@ -646,10 +641,6 @@
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@ -682,10 +673,6 @@
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Test Fixes|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@ -717,10 +704,6 @@
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@ -761,10 +744,6 @@
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\")</Command>
|
||||
<Message>Setup version from Git revision</Message>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\;$(ProjectDir)\..\metamod\include\;$(ProjectDir)\..\public\rehlds\;$(ProjectDir)\..\common;$(ProjectDir)\..\engine;$(ProjectDir)\..\public;$(ProjectDir)\..\pm_shared;$(ProjectDir)\..\rehlds\;$(ProjectDir)\..\testsuite\;$(VCInstallDir)UnitTest\include;$(SolutionDir)..\dep\bzip2\include\;$(SolutionDir)..\dep\cppunitlite\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
@ -1,206 +1,208 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
::
|
||||
:: Pre-build auto-versioning script
|
||||
::
|
||||
|
||||
set srcdir=%~1
|
||||
set repodir=%~2
|
||||
|
||||
set old_version=
|
||||
set version_major=0
|
||||
set version_minor=0
|
||||
set version_maintenance=0
|
||||
set version_modifed=
|
||||
|
||||
set commitSHA=
|
||||
set commitURL=
|
||||
set commitCount=0
|
||||
set branch_name=master
|
||||
|
||||
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
|
||||
set "YYYY=%dt:~0,4%"
|
||||
set "MM=%dt:~4,2%"
|
||||
set "DD=%dt:~6,2%"
|
||||
set "hour=%dt:~8,2%"
|
||||
set "min=%dt:~10,2%"
|
||||
set "sec=%dt:~12,2%"
|
||||
|
||||
::
|
||||
:: Remove leading zero from MM (e.g 09 > 9)
|
||||
::
|
||||
for /f "tokens=* delims=0" %%I in ("%MM%") do set MM=%%I
|
||||
|
||||
::
|
||||
:: Index into array to get month name
|
||||
::
|
||||
for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I"
|
||||
|
||||
::
|
||||
:: Check for git.exe presence
|
||||
::
|
||||
CALL git.exe describe >NUL 2>&1
|
||||
set errlvl="%ERRORLEVEL%"
|
||||
|
||||
::
|
||||
:: Read old appversion.h, if present
|
||||
::
|
||||
IF EXIST "%srcdir%\appversion.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==APP_VERSION (
|
||||
:: Remove quotes
|
||||
set v=%%k
|
||||
set old_version=!v:"=!
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
IF %errlvl% == "1" (
|
||||
echo can't locate git.exe - auto-versioning step won't be performed
|
||||
|
||||
:: if we haven't appversion.h, we need to create it
|
||||
IF NOT "%old_version%" == "" (
|
||||
set commitCount=0
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read major, minor and maintenance version components from Version.h
|
||||
::
|
||||
IF EXIST "%srcdir%\version.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==VERSION_MAJOR set version_major=%%k
|
||||
IF %%j==VERSION_MINOR set version_minor=%%k
|
||||
IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read revision and release date from it
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
:: Get current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO (
|
||||
set branch_name=%%i
|
||||
)
|
||||
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO (
|
||||
IF NOT [%%i] == [] (
|
||||
set commitCount=%%i
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Get remote url repository
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
|
||||
set branch_remote=origin
|
||||
:: Get remote name by current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." config branch.!branch_name!.remote"') DO (
|
||||
set branch_remote=%%i
|
||||
)
|
||||
:: Get remote url
|
||||
FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
:: Get commit id
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO (
|
||||
set shafull=%%i
|
||||
set commitSHA=!shafull:~0,+7!
|
||||
)
|
||||
|
||||
IF [!commitURL!] == [] (
|
||||
|
||||
FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=!commitURL!/commit/
|
||||
)
|
||||
|
||||
) ELSE (
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
:: replace : to /
|
||||
set commitURL=!commitURL::=/!
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=https://!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=https://!commitURL!/commit/
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Detect local modifications
|
||||
::
|
||||
set localChanged=0
|
||||
IF NOT %errlvl% == "1" (
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO (
|
||||
set localChanged=1
|
||||
)
|
||||
)
|
||||
|
||||
IF [%localChanged%]==[1] (
|
||||
set version_modifed=+m
|
||||
)
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
::
|
||||
|
||||
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed%
|
||||
|
||||
::
|
||||
:: Update appversion.h if version has changed or modifications/mixed revisions detected
|
||||
::
|
||||
IF NOT "%new_version%"=="%old_version%" goto _update
|
||||
goto _exit
|
||||
|
||||
:_update
|
||||
echo Updating appversion.h, new version is "%new_version%", the old one was %old_version%
|
||||
|
||||
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
|
||||
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo // This file is generated automatically.>>"%srcdir%\appversion.h"
|
||||
echo // Don't edit it.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // Version defines>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_DATE "%month% %DD% %YYYY%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
:_exit
|
||||
exit /B 0
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
::
|
||||
:: Pre-build auto-versioning script
|
||||
::
|
||||
|
||||
chcp 65001
|
||||
|
||||
set srcdir=%~1
|
||||
set repodir=%~2
|
||||
|
||||
set old_version=
|
||||
set version_major=0
|
||||
set version_minor=0
|
||||
set version_maintenance=0
|
||||
set version_modifed=
|
||||
|
||||
set commitSHA=
|
||||
set commitURL=
|
||||
set commitCount=0
|
||||
set branch_name=master
|
||||
|
||||
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
|
||||
set "YYYY=%dt:~0,4%"
|
||||
set "MM=%dt:~4,2%"
|
||||
set "DD=%dt:~6,2%"
|
||||
set "hour=%dt:~8,2%"
|
||||
set "min=%dt:~10,2%"
|
||||
set "sec=%dt:~12,2%"
|
||||
|
||||
::
|
||||
:: Remove leading zero from MM (e.g 09 > 9)
|
||||
::
|
||||
for /f "tokens=* delims=0" %%I in ("%MM%") do set MM=%%I
|
||||
|
||||
::
|
||||
:: Index into array to get month name
|
||||
::
|
||||
for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I"
|
||||
|
||||
::
|
||||
:: Check for git.exe presence
|
||||
::
|
||||
CALL git.exe describe >NUL 2>&1
|
||||
set errlvl="%ERRORLEVEL%"
|
||||
|
||||
::
|
||||
:: Read old appversion.h, if present
|
||||
::
|
||||
IF EXIST "%srcdir%\appversion.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==APP_VERSION (
|
||||
:: Remove quotes
|
||||
set v=%%k
|
||||
set old_version=!v:"=!
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
IF %errlvl% == "1" (
|
||||
echo can't locate git.exe - auto-versioning step won't be performed
|
||||
|
||||
:: if we haven't appversion.h, we need to create it
|
||||
IF NOT "%old_version%" == "" (
|
||||
set commitCount=0
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read major, minor and maintenance version components from Version.h
|
||||
::
|
||||
IF EXIST "%srcdir%\version.h" (
|
||||
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do (
|
||||
IF %%i==#define (
|
||||
IF %%j==VERSION_MAJOR set version_major=%%k
|
||||
IF %%j==VERSION_MINOR set version_minor=%%k
|
||||
IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Read revision and release date from it
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
:: Get current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO (
|
||||
set branch_name=%%i
|
||||
)
|
||||
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO (
|
||||
IF NOT [%%i] == [] (
|
||||
set commitCount=%%i
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Get remote url repository
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
|
||||
set branch_remote=origin
|
||||
:: Get remote name by current branch
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." config branch.!branch_name!.remote"') DO (
|
||||
set branch_remote=%%i
|
||||
)
|
||||
:: Get remote url
|
||||
FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
:: Get commit id
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO (
|
||||
set shafull=%%i
|
||||
set commitSHA=!shafull:~0,+7!
|
||||
)
|
||||
|
||||
IF [!commitURL!] == [] (
|
||||
|
||||
FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set commitURL=%%i
|
||||
)
|
||||
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=!commitURL!/commit/
|
||||
)
|
||||
|
||||
) ELSE (
|
||||
:: strip .git
|
||||
if "x!commitURL:~-4!"=="x.git" (
|
||||
set commitURL=!commitURL:~0,-4!
|
||||
)
|
||||
:: replace : to /
|
||||
set commitURL=!commitURL::=/!
|
||||
|
||||
:: append extra string
|
||||
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
|
||||
set commitURL=https://!commitURL!/commits/
|
||||
) ELSE (
|
||||
set commitURL=https://!commitURL!/commit/
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Detect local modifications
|
||||
::
|
||||
set localChanged=0
|
||||
IF NOT %errlvl% == "1" (
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO (
|
||||
set localChanged=1
|
||||
)
|
||||
)
|
||||
|
||||
IF [%localChanged%]==[1] (
|
||||
set version_modifed=+m
|
||||
)
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
::
|
||||
|
||||
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed%
|
||||
|
||||
::
|
||||
:: Update appversion.h if version has changed or modifications/mixed revisions detected
|
||||
::
|
||||
IF NOT "%new_version%"=="%old_version%" goto _update
|
||||
goto _exit
|
||||
|
||||
:_update
|
||||
echo Updating appversion.h, new version is "%new_version%", the old one was %old_version%
|
||||
|
||||
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
|
||||
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo // This file is generated automatically.>>"%srcdir%\appversion.h"
|
||||
echo // Don't edit it.>>"%srcdir%\appversion.h"
|
||||
echo // >>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo // Version defines>>"%srcdir%\appversion.h"
|
||||
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_DATE "%month% %DD% %YYYY%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
|
||||
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h"
|
||||
echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
|
||||
echo.>>"%srcdir%\appversion.h"
|
||||
|
||||
:_exit
|
||||
exit /B 0
|
54
rehlds/version/msvc/version.vcxproj
Normal file
54
rehlds/version/msvc/version.vcxproj
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\appversion.h" />
|
||||
<ClInclude Include="..\version.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{6973DCA5-253C-4D84-B51E-187E035EAE06}</ProjectGuid>
|
||||
<Keyword>MakeFileProj</Keyword>
|
||||
<ProjectName>version</ProjectName>
|
||||
<RootNamespace>version</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<NMakeBuildCommandLine>ECHO Setup version from Git revision
|
||||
IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\")</NMakeBuildCommandLine>
|
||||
<NMakeOutput>
|
||||
</NMakeOutput>
|
||||
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<NMakeCleanCommandLine>echo ON
|
||||
del /s $(ProjectDir)..\appversion.h >nul 2>&1</NMakeCleanCommandLine>
|
||||
<NMakeReBuildCommandLine>ECHO Setup version from Git revision
|
||||
IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\")</NMakeReBuildCommandLine>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
7
rehlds/version/msvc/version.vcxproj.filters
Normal file
7
rehlds/version/msvc/version.vcxproj.filters
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\appversion.h" />
|
||||
<ClInclude Include="..\version.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user