From 4ddc12ce40d34801e9ab39401a7f6c357a1305d0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Aug 2015 13:58:48 -0700 Subject: [PATCH] Generate windows version automatically. This allows for the same customization git-version.cpp allows. Also, improve messaging slightly during build if git is missing, and disallow reporting for builds generated without version info to make it clear to users. --- Core/Host.h | 1 - Core/Reporting.cpp | 3 ++ Windows/git-version-gen.cmd | 71 ++++++++++++++++++++++++++++++++---- Windows/version.rc | Bin 2198 -> 2486 bytes headless/StubHost.h | 1 - 5 files changed, 66 insertions(+), 10 deletions(-) diff --git a/Core/Host.h b/Core/Host.h index 58ef4739ad..fe9bb61e65 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -25,7 +25,6 @@ struct InputState; class Host { public: virtual ~Host() {} - //virtual void StartThread() virtual void UpdateUI() {} virtual void UpdateMemView() {} diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 0c05d5eaa2..a43315e3d3 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -347,6 +347,9 @@ namespace Reporting // Not sure if we should support locked cpu at all, but definitely not far out values. if (g_Config.iLockedCPUSpeed != 0 && (g_Config.iLockedCPUSpeed < 111 || g_Config.iLockedCPUSpeed > 333)) return false; + // Don't allow builds without version info from git. They're useless for reporting. + if (strcmp(PPSSPP_GIT_VERSION, "unknown") == 0) + return false; // Some users run the exe from a zip or something, and don't have fonts. // This breaks things, but let's not report it since it's confusing. diff --git a/Windows/git-version-gen.cmd b/Windows/git-version-gen.cmd index eaa42ba57d..f2a10c1fa8 100644 --- a/Windows/git-version-gen.cmd +++ b/Windows/git-version-gen.cmd @@ -16,13 +16,22 @@ rem // If not, see http://www.gnu.org/licenses/ rem // Official git repository and contact information can be found at rem // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +rem // This file automatically generates two files during build: +rem // - git-version.cpp (contains the git version string for display.) +rem // - Windows/win-version.h (contains git version for version.rc.) +rem // +rem // If git is not installed, "unknown" is the version. + setlocal ENABLEDELAYEDEXPANSION set GIT_VERSION_FILE=%~p0..\git-version.cpp +set WIN_VERSION_FILE=%~p0.\win-version.h +set GIT_MISSING=0 + if not defined GIT ( set GIT="git" ) -call %GIT% describe > NUL 2> NUL +call %GIT% describe --always > NUL 2> NUL if errorlevel 1 ( echo Git not on path, trying default Msysgit paths set GIT="%ProgramFiles(x86)%\Git\bin\git.exe" @@ -32,32 +41,37 @@ if errorlevel 1 ( ) ) +call %GIT% describe --always > NUL 2> NUL +if errorlevel 1 ( + set GIT_MISSING=1 +) + if exist "%GIT_VERSION_FILE%" ( rem // Skip updating the file if PPSSPP_GIT_VERSION_NO_UPDATE is 1. findstr /B /C:"#define PPSSPP_GIT_VERSION_NO_UPDATE 1" "%GIT_VERSION_FILE%" > NUL if not errorlevel 1 ( - goto done + goto gitdone ) ) -call %GIT% describe --always > NUL 2> NUL -if errorlevel 1 ( - echo Unable to update git-version.cpp, git not found. +if "%GIT_MISSING%" == "1" ( + echo WARNING: Unable to update git-version.cpp, git not found. echo If you don't want to add it to your path, set the GIT environment variable. echo // This is a generated file. > "%GIT_VERSION_FILE%" echo. >> "%GIT_VERSION_FILE%" + echo // ERROR: Unable to determine version - git not on path. > "%GIT_VERSION_FILE%" echo const char *PPSSPP_GIT_VERSION = "unknown"; >> "%GIT_VERSION_FILE%" - goto done + goto gitdone ) -for /F %%I IN ('call %GIT% describe --always') do set GIT_VERSION=%%I +for /F %%I in ('call %GIT% describe --always') do set GIT_VERSION=%%I rem // Don't modify the file if it already has the current version. if exist "%GIT_VERSION_FILE%" ( findstr /C:"%GIT_VERSION%" "%GIT_VERSION_FILE%" > NUL if not errorlevel 1 ( - goto done + goto gitdone ) ) @@ -68,4 +82,45 @@ echo. >> "%GIT_VERSION_FILE%" echo // If you don't want this file to update/recompile, change to 1. >> "%GIT_VERSION_FILE%" echo #define PPSSPP_GIT_VERSION_NO_UPDATE 0 >> "%GIT_VERSION_FILE%" +:gitdone + +if exist "%WIN_VERSION_FILE%" ( + rem // Skip updating the file if PPSSPP_WIN_VERSION_NO_UPDATE is 1. + findstr /B /C:"#define PPSSPP_WIN_VERSION_NO_UPDATE 1" "%WIN_VERSION_FILE%" > NUL + if not errorlevel 1 ( + goto done + ) +) + +if "%GIT_MISSING%" == "1" ( + echo WARNING: Unable to update Windows/win-version.h, git not found. + + echo // This is a generated file. > "%WIN_VERSION_FILE%" + echo. >> "%WIN_VERSION_FILE%" + echo // ERROR: Unable to determine version - git not on path. > "%WIN_VERSION_FILE%" + echo #define PPSSPP_WIN_VERSION_STRING "unknown" > "%WIN_VERSION_FILE%" + echo #define PPSSPP_WIN_VERSION_COMMA 0,0,0,0 > "%WIN_VERSION_FILE%" + + goto done +) + +if exist "%WIN_VERSION_FILE%" ( + rem // Don't modify the file if it already has the current version. + findstr /C:"%GIT_VERSION%" "%WIN_VERSION_FILE%" > NUL + if not errorlevel 1 ( + goto done + ) +) + +for /f "tokens=1 delims=-" %%a in ("%GIT_VERSION:~1%") do set WIN_RELEASE_VERSION=%%a +for /f "tokens=2 delims=-" %%a in ("%GIT_VERSION%") do set WIN_BUILD_NUMBER=%%a + +echo // This is a generated file. > "%WIN_VERSION_FILE%" +echo. >> "%WIN_VERSION_FILE%" +echo #define PPSSPP_WIN_VERSION_STRING "%GIT_VERSION%" >> "%WIN_VERSION_FILE%" +echo #define PPSSPP_WIN_VERSION_COMMA %WIN_RELEASE_VERSION:.=,%,%WIN_BUILD_NUMBER% >> "%WIN_VERSION_FILE%" +echo. >> "%WIN_VERSION_FILE%" +echo // If you don't want this file to update/recompile, change to 1. >> "%WIN_VERSION_FILE%" +echo #define PPSSPP_WIN_VERSION_NO_UPDATE 0 >> "%WIN_VERSION_FILE%" + :done diff --git a/Windows/version.rc b/Windows/version.rc index 0be1d7d072afc159756495aa2497ec81675be61a..cb2bec46bbbda208cf24618dd1df99d81e96772a 100644 GIT binary patch delta 385 zcmb7;%?bf=6vcl&O2`7)Pb15jY4QY;CJP_U_*h9|Vv12FxyAu-3s71xQsF7-dH z%G;naWyK7Yh*B1{QSIvrZHs0Bu> k@^9vJi0KLaH;_dSQ#@guF3EfR|5$KImV#TV5ZqGN7vRE5L;wH) delta 127 zcmdlcJWY`E|36*^E(U!D{fXRnC-*Ui@ES7cFc>iCFo5aFf=sGtBI}tXH`g&qFbgYz jl_-D}D?r$j|1(QYUce%@`4j6ZCY%bsa0pHQ!f^-ylWZG4 diff --git a/headless/StubHost.h b/headless/StubHost.h index 39290b7bc2..08a8b19553 100644 --- a/headless/StubHost.h +++ b/headless/StubHost.h @@ -24,7 +24,6 @@ class HeadlessHost : public Host { public: - // void StartThread() override void UpdateUI() override {} void UpdateMemView() override {}