1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

Add git_branch to git-version.h, add display version info to gs_frame and add branch and version to log. (#3186)

* Added version number and branch name to gs_frame and log file. This also involved making the files that generate git-version.h , get the branch.
This commit is contained in:
Peter Mcteague 2017-09-16 12:54:25 +01:00 committed by Ivan
parent 6a54b3929e
commit c18e71ca29
6 changed files with 47 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#include "Log.h"
#include "Log.h"
#include "File.h"
#include "StrFmt.h"
#include "sema.h"
@ -7,6 +7,7 @@
#include "rpcs3_version.h"
#include <string>
#include <unordered_map>
#include "git-version.h"
#ifdef _WIN32
#define NOMINMAX
@ -393,7 +394,8 @@ logs::file_listener::file_listener(const std::string& name)
ver.m.ch = nullptr;
ver.m.sev = level::always;
ver.stamp = 0;
ver.text = fmt::format("RPCS3 v%s\n%s", rpcs3::version.to_string(), utils::get_system_info());
ver.text = fmt::format("RPCS3 v%s\nBranch: %s\n%s\n", rpcs3::version.to_string(), rpcs3::get_branch(), utils::get_system_info());
file_writer::log(logs::level::always, ver.text.data(), ver.text.size());
file_writer::log(logs::level::always, "\n", 1);
g_messages.emplace_back(std::move(ver));

View File

@ -47,6 +47,7 @@ if errorlevel 1 (
echo // This is a generated file. > "%GIT_VERSION_FILE%"
echo. >> "%GIT_VERSION_FILE%"
echo #define RPCS3_GIT_VERSION "unknown" >> "%GIT_VERSION_FILE%"
echo #define RPCS3_GIT_BRANCH "unknown" >> "%GIT_VERSION_FILE%"
echo. >> "%GIT_VERSION_FILE%"
echo // If you don't want this file to update/recompile, change to 1. >> "%GIT_VERSION_FILE%"
echo #define RPCS3_GIT_VERSION_NO_UPDATE 0 >> "%GIT_VERSION_FILE%"
@ -55,6 +56,7 @@ if errorlevel 1 (
for /F %%I IN ('call %GIT% rev-list HEAD --count') do set GIT_VERSION=%%I
for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%GIT_VERSION%-%%I
for /F %%I IN ('call %GIT% rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%I
rem // Don't modify the file if it already has the current version.
if exist "%GIT_VERSION_FILE%" (
@ -67,6 +69,7 @@ if exist "%GIT_VERSION_FILE%" (
echo // This is a generated file. > "%GIT_VERSION_FILE%"
echo. >> "%GIT_VERSION_FILE%"
echo #define RPCS3_GIT_VERSION "%GIT_VERSION%" >> "%GIT_VERSION_FILE%"
echo #define RPCS3_GIT_BRANCH "%GIT_BRANCH%" >> "%GIT_VERSION_FILE%"
echo. >> "%GIT_VERSION_FILE%"
echo // If you don't want this file to update/recompile, change to 1. >> "%GIT_VERSION_FILE%"
echo #define RPCS3_GIT_VERSION_NO_UPDATE 0 >> "%GIT_VERSION_FILE%"

View File

@ -1,5 +1,6 @@
set(GIT_VERSION_FILE "${SOURCE_DIR}/git-version.h")
set(GIT_VERSION "unknown")
set(GIT_BRANCH "unknown")
set(GIT_VERSION_UPDATE "1")
find_package(Git)
@ -18,10 +19,19 @@ if(GIT_FOUND AND EXISTS "${SOURCE_DIR}/../.git/")
if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include version.")
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
RESULT_VARIABLE exit_code
OUTPUT_VARIABLE GIT_BRANCH)
if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include git branch.")
endif()
string(STRIP ${GIT_VERSION} GIT_VERSION)
string(STRIP ${GIT_VERSION_} GIT_VERSION_)
string(STRIP ${GIT_VERSION}-${GIT_VERSION_} GIT_VERSION)
string(STRIP ${GIT_BRANCH} GIT_BRANCH)
message(STATUS "GIT_VERSION: " ${GIT_VERSION})
message(STATUS "GIT_BRANCH: " ${GIT_BRANCH})
else()
message(WARNING "git not found, unable to include version.")
endif()
@ -43,7 +53,8 @@ if(EXISTS ${GIT_VERSION_FILE})
endif()
set(code_string "// This is a generated file.\n\n"
"#define RPCS3_GIT_VERSION \"${GIT_VERSION}\"\n\n"
"#define RPCS3_GIT_VERSION \"${GIT_VERSION}\"\n"
"#define RPCS3_GIT_BRANCH \"${GIT_BRANCH}\"\n\n"
"// If you don't want this file to update/recompile, change to 1.\n"
"#define RPCS3_GIT_VERSION_NO_UPDATE 0\n")

View File

@ -4,5 +4,10 @@
namespace rpcs3
{
std::string get_branch()
{
return RPCS3_GIT_BRANCH;
}
const extern utils::version version{ 0, 0, 3, utils::version_type::alpha, 1, RPCS3_GIT_VERSION };
}

View File

@ -5,5 +5,7 @@
namespace rpcs3
{
std::string get_branch();
extern const utils::version version;
}

View File

@ -8,11 +8,28 @@
#include <QTimer>
#include <QThread>
#include <string>
#include "rpcs3_version.h"
#include "git-version.h"
constexpr auto qstr = QString::fromStdString;
gs_frame::gs_frame(const QString& title, int w, int h, QIcon appIcon, bool disableMouse)
: QWindow(), m_windowTitle(title), m_disable_mouse(disableMouse)
{
//Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash
std::string version = rpcs3::version.to_string();
version = version.substr(0 , version.find_last_of("-"));
//Add branch to version on frame , unless it's master.
if (rpcs3::get_branch() != "master")
{
version = version + "-" + rpcs3::get_branch();
}
m_windowTitle += qstr(" | " + version);
if (!Emu.GetTitle().empty())
{
m_windowTitle += qstr(" | " + Emu.GetTitle());