diff --git a/msvc/ReHLDS.sln b/msvc/ReHLDS.sln index 9b4dc41..4129d4a 100644 --- a/msvc/ReHLDS.sln +++ b/msvc/ReHLDS.sln @@ -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 diff --git a/rehlds/HLTV/Console/msvc/Console.vcxproj b/rehlds/HLTV/Console/msvc/Console.vcxproj index 3ecc3b6..ec6f883 100644 --- a/rehlds/HLTV/Console/msvc/Console.vcxproj +++ b/rehlds/HLTV/Console/msvc/Console.vcxproj @@ -83,6 +83,11 @@ + + + {6973dca5-253c-4d84-b51e-187e035eae06} + + {D5CAB879-D54F-456F-8592-31D549CFD1D8} Win32Proj @@ -157,10 +162,6 @@ build.always.run build.always.run - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\..\version\" "$(ProjectDir)..\..\..\") - Setup version from Git revision - @@ -193,12 +194,8 @@ build.always.run build.always.run - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\..\version\" "$(ProjectDir)..\..\..\") - Setup version from Git revision - - + \ No newline at end of file diff --git a/rehlds/HLTV/Console/msvc/PreBuild.bat b/rehlds/HLTV/Console/msvc/PreBuild.bat deleted file mode 100644 index 8226913..0000000 --- a/rehlds/HLTV/Console/msvc/PreBuild.bat +++ /dev/null @@ -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 diff --git a/rehlds/dedicated/msvc/dedicated.vcxproj b/rehlds/dedicated/msvc/dedicated.vcxproj index 34c9a39..327d295 100644 --- a/rehlds/dedicated/msvc/dedicated.vcxproj +++ b/rehlds/dedicated/msvc/dedicated.vcxproj @@ -70,12 +70,6 @@ true ws2_32.lib;winmm.lib;%(AdditionalDependencies) - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\version\" "$(ProjectDir)..\..\") - - - Setup version from Git revision - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") @@ -115,12 +109,6 @@ true ws2_32.lib;winmm.lib;%(AdditionalDependencies) - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\version\" "$(ProjectDir)..\..\") - - - Setup version from Git revision - IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") @@ -184,7 +172,12 @@ + + + {6973dca5-253c-4d84-b51e-187e035eae06} + + - + \ No newline at end of file diff --git a/rehlds/msvc/PreBuild.bat b/rehlds/msvc/PreBuild.bat deleted file mode 100644 index 61dd70d..0000000 --- a/rehlds/msvc/PreBuild.bat +++ /dev/null @@ -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 diff --git a/rehlds/msvc/ReHLDS.vcxproj b/rehlds/msvc/ReHLDS.vcxproj index d76110b..2078e83 100644 --- a/rehlds/msvc/ReHLDS.vcxproj +++ b/rehlds/msvc/ReHLDS.vcxproj @@ -461,6 +461,9 @@ {ceb94f7c-e459-4673-aabb-36e2074396c0} + + {6973dca5-253c-4d84-b51e-187e035eae06} + {70A2B904-B7DB-4C48-8DE0-AF567360D572} @@ -570,10 +573,6 @@ false - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - $(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) Level3 @@ -607,10 +606,6 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - $(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) Level3 @@ -646,10 +641,6 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - $(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) Level3 @@ -682,10 +673,6 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - $(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) Level3 @@ -717,10 +704,6 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - $(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) Level3 @@ -761,10 +744,6 @@ - - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") - Setup version from Git revision - $(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) Level3 diff --git a/rehlds/dedicated/msvc/PreBuild.bat b/rehlds/version/appversion.bat similarity index 95% rename from rehlds/dedicated/msvc/PreBuild.bat rename to rehlds/version/appversion.bat index cb4aff8..b2d4bdb 100644 --- a/rehlds/dedicated/msvc/PreBuild.bat +++ b/rehlds/version/appversion.bat @@ -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 diff --git a/rehlds/version/msvc/version.vcxproj b/rehlds/version/msvc/version.vcxproj new file mode 100644 index 0000000..6eea1c3 --- /dev/null +++ b/rehlds/version/msvc/version.vcxproj @@ -0,0 +1,54 @@ + + + + + Release + Win32 + + + + + + + + {6973DCA5-253C-4D84-B51E-187E035EAE06} + MakeFileProj + version + version + 10.0 + + + + Makefile + false + v120 + v140 + v141 + v142 + + + + + + + + + + + + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\") + + + WIN32;NDEBUG;$(NMakePreprocessorDefinitions) + echo ON +del /s $(ProjectDir)..\appversion.h >nul 2>&1 + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\") + + + + + + + \ No newline at end of file diff --git a/rehlds/version/msvc/version.vcxproj.filters b/rehlds/version/msvc/version.vcxproj.filters new file mode 100644 index 0000000..b2ccc8c --- /dev/null +++ b/rehlds/version/msvc/version.vcxproj.filters @@ -0,0 +1,7 @@ + + + + + + +