diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 367903bfcd..25010c33a3 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -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 #include +#include "git-version.h" #ifdef _WIN32 #define NOMINMAX @@ -277,7 +278,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u g_messages.emplace_back(stored_message{*this, stamp, std::move(prefix), text}); } } - + // Send message to all listeners while (lis) { @@ -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)); @@ -429,7 +431,7 @@ void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::st text += prefix; text += "} "; } - + if (msg.ch && '\0' != *msg.ch->name) { text += msg.ch->name; @@ -439,7 +441,7 @@ void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::st { text += "TODO: "; } - + text += _text; text += '\n'; diff --git a/Utilities/git-version-gen.cmd b/Utilities/git-version-gen.cmd index 0346559c55..c59dd69518 100644 --- a/Utilities/git-version-gen.cmd +++ b/Utilities/git-version-gen.cmd @@ -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%" diff --git a/rpcs3/git-version.cmake b/rpcs3/git-version.cmake index 603407fd73..4b80bbd2c9 100644 --- a/rpcs3/git-version.cmake +++ b/rpcs3/git-version.cmake @@ -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") diff --git a/rpcs3/rpcs3_version.cpp b/rpcs3/rpcs3_version.cpp index 2143aed987..23b93498bf 100644 --- a/rpcs3/rpcs3_version.cpp +++ b/rpcs3/rpcs3_version.cpp @@ -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 }; } diff --git a/rpcs3/rpcs3_version.h b/rpcs3/rpcs3_version.h index 671fed850e..a24ae814ad 100644 --- a/rpcs3/rpcs3_version.h +++ b/rpcs3/rpcs3_version.h @@ -5,5 +5,7 @@ namespace rpcs3 { + std::string get_branch(); + extern const utils::version version; -} +} \ No newline at end of file diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index d411c736e9..5f5a71ae44 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -8,11 +8,28 @@ #include #include +#include + +#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());