From 7cfea77b93fcd65fd6a704f3521c4a5c9580799f Mon Sep 17 00:00:00 2001 From: s1lentq Date: Fri, 9 Apr 2021 06:00:30 +0700 Subject: [PATCH] workflows/build.yml: add testing HLDS demo --- .github/workflows/build.yml | 129 ++++++++++++--- msvc/ReHLDS.sln | 80 +++------ rehlds/HLTV/Console/msvc/PreBuild.bat | 6 - rehlds/dedicated/msvc/PreBuild.bat | 206 ++++++++++++++++++++++++ rehlds/dedicated/msvc/dedicated.vcxproj | 4 +- rehlds/msvc/PreBuild.bat | 6 - rehlds/msvc/ReHLDS.vcxproj | 26 ++- rehlds/unittests/TestRunner.cpp | 8 +- 8 files changed, 360 insertions(+), 105 deletions(-) create mode 100644 rehlds/dedicated/msvc/PreBuild.bat diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b287c4..02eedd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,10 +15,13 @@ jobs: windows: name: 'Windows' runs-on: windows-latest + env: solution: 'msvc/ReHLDS.sln' buildPlatform: 'Win32' - buildConfiguration: 'Release' + buildRelease: 'Release' + buildReleasePlay: 'Release Play' + buildTest: 'Test Fixes' steps: - name: Checkout @@ -39,29 +42,41 @@ jobs: vs-version: '16.8' - name: Build ReHLDS - run: - msbuild ${{ env.solution }} /t:Clean,Build -p:Configuration="${{ env.buildConfiguration }}" /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false + run: | + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildReleasePlay }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false + + - name: Build and Testing + run: | + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTest }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false + .\"msvc\Test Fixes\swds.exe" + If ($LASTEXITCODE -ne 0 -And + $LASTEXITCODE -ne 3) + {[Environment]::Exit(1)} + shell: "pwsh" - name: Move files run: | mkdir publish\debug + mkdir publish\tests mkdir publish\bin\win32\valve\dlls - move msvc\${{ env.buildConfiguration }}\hlds.exe publish\bin\win32\hlds.exe - move msvc\${{ env.buildConfiguration }}\hltv.exe publish\bin\win32\hltv.exe - move msvc\${{ env.buildConfiguration }}\swds.dll publish\bin\win32\swds.dll - move msvc\${{ env.buildConfiguration }}\core.dll publish\bin\win32\core.dll - move msvc\${{ env.buildConfiguration }}\proxy.dll publish\bin\win32\proxy.dll - move msvc\${{ env.buildConfiguration }}\demoplayer.dll publish\bin\win32\demoplayer.dll - move msvc\${{ env.buildConfiguration }}\filesystem_stdio.dll publish\bin\win32\filesystem_stdio.dll - move msvc\${{ env.buildConfiguration }}\director.dll publish\bin\win32\valve\dlls\director.dll - move msvc\${{ env.buildConfiguration }}\hlds.pdb publish\debug\hlds.pdb - move msvc\${{ env.buildConfiguration }}\hltv.pdb publish\debug\hltv.pdb - move msvc\${{ env.buildConfiguration }}\swds.pdb publish\debug\swds.pdb - move msvc\${{ env.buildConfiguration }}\core.pdb publish\debug\core.pdb - move msvc\${{ env.buildConfiguration }}\proxy.pdb publish\debug\proxy.pdb - move msvc\${{ env.buildConfiguration }}\demoplayer.pdb publish\debug\demoplayer.pdb - move msvc\${{ env.buildConfiguration }}\filesystem_stdio.pdb publish\debug\filesystem_stdio.pdb - move msvc\${{ env.buildConfiguration }}\director.pdb publish\debug\director.pdb + move "msvc\${{ env.buildReleasePlay }}\swds.dll" publish\tests\swds.dll + move msvc\${{ env.buildRelease }}\hlds.exe publish\bin\win32\hlds.exe + move msvc\${{ env.buildRelease }}\hltv.exe publish\bin\win32\hltv.exe + move msvc\${{ env.buildRelease }}\swds.dll publish\bin\win32\swds.dll + move msvc\${{ env.buildRelease }}\core.dll publish\bin\win32\core.dll + move msvc\${{ env.buildRelease }}\proxy.dll publish\bin\win32\proxy.dll + move msvc\${{ env.buildRelease }}\demoplayer.dll publish\bin\win32\demoplayer.dll + move msvc\${{ env.buildRelease }}\filesystem_stdio.dll publish\bin\win32\filesystem_stdio.dll + move msvc\${{ env.buildRelease }}\director.dll publish\bin\win32\valve\dlls\director.dll + move msvc\${{ env.buildRelease }}\hlds.pdb publish\debug\hlds.pdb + move msvc\${{ env.buildRelease }}\hltv.pdb publish\debug\hltv.pdb + move msvc\${{ env.buildRelease }}\swds.pdb publish\debug\swds.pdb + move msvc\${{ env.buildRelease }}\core.pdb publish\debug\core.pdb + move msvc\${{ env.buildRelease }}\proxy.pdb publish\debug\proxy.pdb + move msvc\${{ env.buildRelease }}\demoplayer.pdb publish\debug\demoplayer.pdb + move msvc\${{ env.buildRelease }}\filesystem_stdio.pdb publish\debug\filesystem_stdio.pdb + move msvc\${{ env.buildRelease }}\director.pdb publish\debug\director.pdb - name: Deploy artifacts uses: actions/upload-artifact@v2 @@ -69,6 +84,79 @@ jobs: name: win32 path: publish/* + testdemos: + name: 'Test demos' + runs-on: ubuntu-latest + container: s1lentq/testdemos:latest + needs: [windows] + + env: + WINEDEBUG: -all + WINEDLLOVERRIDES: mshtml= + + defaults: + run: + shell: bash + working-directory: ../../../opt/HLDS + + steps: + - name: Deploying windows artifacts + uses: actions/download-artifact@v2 + with: + name: win32 + + - name: Play demos + run: | + chown root ~ + cp -r deps/rehlds/* . + mv $GITHUB_WORKSPACE/tests/swds.dll . + + descs=( + "Half-Life: Physics singleplayer" + "Half-Life: Multiplayer on crossfire map" + "Half-Life: Shooting with several weapons" + "CS: Multiplayer" + ) + + demos=( + "rehlds-phys-single1" + "crossfire-1-multiplayer-1" + "shooting-hl-1" + "cstrike-muliplayer-1" + ) + + retVal=0 + for i in "${!demos[@]}"; do + params=$(cat "testdemos/${demos[i]}.params") + + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[0m" + echo -e " - \e[0;33mParameters $params\e[0m" + + wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/${demos[i]}.bin" $params &> result.log || retVal=$? + + if [ $retVal -ne 777 ] && [ $retVal -ne 9 ]; then + # Print with catchy messages + while read line; do + echo -e " \e[0;33m$line" + done <<< $(cat result.log | sed '0,/demo failed/I!d;/wine:/d;/./,$!d') + + echo " 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸" + while read line; do + echo -e " \e[1;31m$line"; + done < rehlds_demo_error.txt + echo -e " \e[30;41mExit code: $retVal\e[0m" + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;31m Failed ❌" + exit 6 # Test demo failed + else + # Print result HLDS console + while read line; do + echo -e " \e[0;33m$line" + done <<< $(cat result.log | sed '/wine:/d;/./,$!d') + echo -e " \e[30;43mExit code: $retVal\e[0m" + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;32m Succeed ✔" + fi + done + linux: name: 'Linux' runs-on: ubuntu-latest @@ -138,9 +226,10 @@ jobs: rm -f appversion.h publish: - needs: [windows, linux] name: 'Publish' runs-on: ubuntu-latest + needs: [windows, testdemos, linux] + steps: - name: Deploying linux artifacts uses: actions/download-artifact@v2 diff --git a/msvc/ReHLDS.sln b/msvc/ReHLDS.sln index 6a01e76..9b4dc41 100644 --- a/msvc/ReHLDS.sln +++ b/msvc/ReHLDS.sln @@ -13,14 +13,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cppunitlite", "..\dep\cppun EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\dep\bzip2\msvc\bzip2.vcxproj", "{792DF067-9904-4579-99B9-46C17277ADE3}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gradle", "gradle", "{FFC337A9-D58C-4D62-B8BB-A54DD4E4DF41}" - ProjectSection(SolutionItems) = preProject - ..\build.gradle = ..\build.gradle - ..\gradle.properties = ..\gradle.properties - ..\settings.gradle = ..\settings.gradle - ..\shared.gradle = ..\shared.gradle - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dedicated", "..\rehlds\dedicated\msvc\dedicated.vcxproj", "{D49883F3-5C5C-4B9F-B9C7-B31518F228D4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D2516ABB-21F2-4393-8CC9-2BD2D3316CD6}" @@ -70,10 +62,10 @@ Global {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release Play|Win32.Build.0 = Release|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release|Win32.ActiveCfg = Release|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release|Win32.Build.0 = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.Build.0 = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.ActiveCfg = Release|Win32 - {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.Build.0 = Release|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Test Fixes|Win32.Build.0 = Debug|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.ActiveCfg = Debug|Win32 + {CEB94F7C-E459-4673-AABB-36E2074396C0}.Tests|Win32.Build.0 = Debug|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Debug Play|Win32.ActiveCfg = Debug|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Debug Play|Win32.Build.0 = Debug|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -82,94 +74,66 @@ Global {792DF067-9904-4579-99B9-46C17277ADE3}.Release Play|Win32.Build.0 = Release|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Release|Win32.ActiveCfg = Release|Win32 {792DF067-9904-4579-99B9-46C17277ADE3}.Release|Win32.Build.0 = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.Build.0 = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.ActiveCfg = Release|Win32 - {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.Build.0 = Release|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Test Fixes|Win32.Build.0 = Debug|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.ActiveCfg = Debug|Win32 + {792DF067-9904-4579-99B9-46C17277ADE3}.Tests|Win32.Build.0 = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug Play|Win32.Build.0 = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug|Win32.ActiveCfg = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Debug|Win32.Build.0 = Debug|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release Play|Win32.ActiveCfg = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release Play|Win32.Build.0 = Release|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release|Win32.ActiveCfg = Release|Win32 {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Release|Win32.Build.0 = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Test Fixes|Win32.Build.0 = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Tests|Win32.ActiveCfg = Release|Win32 - {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Tests|Win32.Build.0 = Release|Win32 + {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {D49883F3-5C5C-4B9F-B9C7-B31518F228D4}.Tests|Win32.ActiveCfg = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug Play|Win32.Build.0 = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug|Win32.ActiveCfg = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Debug|Win32.Build.0 = Debug|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release Play|Win32.ActiveCfg = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release Play|Win32.Build.0 = Release|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release|Win32.ActiveCfg = Release|Win32 {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Release|Win32.Build.0 = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Test Fixes|Win32.Build.0 = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Tests|Win32.ActiveCfg = Release|Win32 - {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Tests|Win32.Build.0 = Release|Win32 + {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {D5CAB879-D54F-456F-8592-31D549CFD1D8}.Tests|Win32.ActiveCfg = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug Play|Win32.Build.0 = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug|Win32.ActiveCfg = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Debug|Win32.Build.0 = Debug|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release Play|Win32.ActiveCfg = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release Play|Win32.Build.0 = Release|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release|Win32.ActiveCfg = Release|Win32 {52F752EA-73D1-422D-B805-17EF1FB20E09}.Release|Win32.Build.0 = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Test Fixes|Win32.Build.0 = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Tests|Win32.ActiveCfg = Release|Win32 - {52F752EA-73D1-422D-B805-17EF1FB20E09}.Tests|Win32.Build.0 = Release|Win32 + {52F752EA-73D1-422D-B805-17EF1FB20E09}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {52F752EA-73D1-422D-B805-17EF1FB20E09}.Tests|Win32.ActiveCfg = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug Play|Win32.Build.0 = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug|Win32.ActiveCfg = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Debug|Win32.Build.0 = Debug|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release Play|Win32.ActiveCfg = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release Play|Win32.Build.0 = Release|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release|Win32.ActiveCfg = Release|Win32 {05292761-0847-4A68-BA10-9D384DC0D3EE}.Release|Win32.Build.0 = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Test Fixes|Win32.Build.0 = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Tests|Win32.ActiveCfg = Release|Win32 - {05292761-0847-4A68-BA10-9D384DC0D3EE}.Tests|Win32.Build.0 = Release|Win32 + {05292761-0847-4A68-BA10-9D384DC0D3EE}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {05292761-0847-4A68-BA10-9D384DC0D3EE}.Tests|Win32.ActiveCfg = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug Play|Win32.Build.0 = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug|Win32.ActiveCfg = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Debug|Win32.Build.0 = Debug|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release Play|Win32.ActiveCfg = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release Play|Win32.Build.0 = Release|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release|Win32.ActiveCfg = Release|Win32 {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Release|Win32.Build.0 = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Test Fixes|Win32.Build.0 = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Tests|Win32.ActiveCfg = Release|Win32 - {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Tests|Win32.Build.0 = Release|Win32 + {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {04D0594C-57F5-4277-AF1B-EAE90AED0C3C}.Tests|Win32.ActiveCfg = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug Play|Win32.Build.0 = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug|Win32.ActiveCfg = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Debug|Win32.Build.0 = Debug|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release Play|Win32.ActiveCfg = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release Play|Win32.Build.0 = Release|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release|Win32.ActiveCfg = Release|Win32 {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Release|Win32.Build.0 = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Test Fixes|Win32.Build.0 = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Tests|Win32.ActiveCfg = Release|Win32 - {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Tests|Win32.Build.0 = Release|Win32 + {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Test Fixes|Win32.ActiveCfg = Debug|Win32 + {ADDFF069-D39D-4A1B-87C9-85A62B980547}.Tests|Win32.ActiveCfg = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug Play|Win32.ActiveCfg = Debug|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug Play|Win32.Build.0 = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug|Win32.ActiveCfg = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Debug|Win32.Build.0 = Debug|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Release Play|Win32.ActiveCfg = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Release Play|Win32.Build.0 = Release|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Release|Win32.ActiveCfg = Release|Win32 {A428392F-52FB-489E-87D8-623528C7F4F9}.Release|Win32.Build.0 = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Test Fixes|Win32.ActiveCfg = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Test Fixes|Win32.Build.0 = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Tests|Win32.ActiveCfg = Release|Win32 - {A428392F-52FB-489E-87D8-623528C7F4F9}.Tests|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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/rehlds/HLTV/Console/msvc/PreBuild.bat b/rehlds/HLTV/Console/msvc/PreBuild.bat index 8c11185..8226913 100644 --- a/rehlds/HLTV/Console/msvc/PreBuild.bat +++ b/rehlds/HLTV/Console/msvc/PreBuild.bat @@ -202,11 +202,5 @@ echo.>>"%srcdir%\appversion.h" echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h" echo.>>"%srcdir%\appversion.h" -:: -:: Do update of version.cpp file last modify time to force it recompile -:: -copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp" -endlocal - :_exit exit /B 0 diff --git a/rehlds/dedicated/msvc/PreBuild.bat b/rehlds/dedicated/msvc/PreBuild.bat new file mode 100644 index 0000000..cb4aff8 --- /dev/null +++ b/rehlds/dedicated/msvc/PreBuild.bat @@ -0,0 +1,206 @@ +@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/dedicated/msvc/dedicated.vcxproj b/rehlds/dedicated/msvc/dedicated.vcxproj index a05bc81..34c9a39 100644 --- a/rehlds/dedicated/msvc/dedicated.vcxproj +++ b/rehlds/dedicated/msvc/dedicated.vcxproj @@ -71,7 +71,7 @@ ws2_32.lib;winmm.lib;%(AdditionalDependencies) - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") + IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\version\" "$(ProjectDir)..\..\") Setup version from Git revision @@ -116,7 +116,7 @@ ws2_32.lib;winmm.lib;%(AdditionalDependencies) - IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\version\" "$(ProjectDir)..\") + IF EXIST "$(ProjectDir)PreBuild.bat" (CALL "$(ProjectDir)PreBuild.bat" "$(ProjectDir)..\..\version\" "$(ProjectDir)..\..\") Setup version from Git revision diff --git a/rehlds/msvc/PreBuild.bat b/rehlds/msvc/PreBuild.bat index eb93af6..61dd70d 100644 --- a/rehlds/msvc/PreBuild.bat +++ b/rehlds/msvc/PreBuild.bat @@ -202,11 +202,5 @@ echo.>>"%srcdir%\appversion.h" echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h" echo.>>"%srcdir%\appversion.h" -:: -:: Do update of version.cpp file last modify time to force it recompile -:: -copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp" -endlocal - :_exit exit /B 0 diff --git a/rehlds/msvc/ReHLDS.vcxproj b/rehlds/msvc/ReHLDS.vcxproj index 5742693..2ae61ae 100644 --- a/rehlds/msvc/ReHLDS.vcxproj +++ b/rehlds/msvc/ReHLDS.vcxproj @@ -176,9 +176,17 @@ true true - + + true + true + true + true + true + true + true + true true @@ -553,21 +561,27 @@ swds + true swds + true - filesystem_stdio + swds + true - filesystem_stdio + swds + true swds + false swds + false @@ -655,7 +669,7 @@ Level3 Disabled true - REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) + REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) MultiThreadedDebug Use precompiled.h @@ -691,7 +705,7 @@ Level3 Disabled true - REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_UNIT_TESTS;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) + REHLDS_API;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_FIXES;HAVE_OPT_STRTOOLS;REHLDS_SELF;REHLDS_SSE;REHLDS_JIT;REHLDS_UNIT_TESTS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) MultiThreadedDebug Use precompiled.h @@ -728,7 +742,7 @@ true true true - REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;HAVE_OPT_STRTOOLS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded /arch:IA32 %(AdditionalOptions) Use diff --git a/rehlds/unittests/TestRunner.cpp b/rehlds/unittests/TestRunner.cpp index cb9fa86..965daaf 100644 --- a/rehlds/unittests/TestRunner.cpp +++ b/rehlds/unittests/TestRunner.cpp @@ -6,11 +6,5 @@ int main(int argc, char* argv[]) { printf("TestRunner: main()\n"); GradleAdapter a; - int res = a.testsEntryPoint(argc, argv); - -#ifdef _BUILD_FROM_IDE - system("PAUSE"); -#endif - - return res; + return a.testsEntryPoint(argc, argv); }