2020-12-05 12:08:24 +00:00
|
|
|
#include "stdafx.h"
|
2016-05-07 18:38:52 +00:00
|
|
|
#include "rpcs3_version.h"
|
|
|
|
#include "git-version.h"
|
2019-09-11 07:55:43 +00:00
|
|
|
#include "Utilities/StrUtil.h"
|
2016-05-07 18:38:52 +00:00
|
|
|
|
|
|
|
namespace rpcs3
|
|
|
|
{
|
2020-02-12 20:52:11 +00:00
|
|
|
std::string_view get_branch()
|
2017-09-16 11:54:25 +00:00
|
|
|
{
|
|
|
|
return RPCS3_GIT_BRANCH;
|
|
|
|
}
|
|
|
|
|
2020-03-27 13:37:27 +00:00
|
|
|
std::string_view get_full_branch()
|
|
|
|
{
|
|
|
|
return RPCS3_GIT_FULL_BRANCH;
|
|
|
|
}
|
|
|
|
|
2019-09-11 07:55:43 +00:00
|
|
|
std::pair<std::string, std::string> get_commit_and_hash()
|
|
|
|
{
|
2019-10-22 03:12:44 +00:00
|
|
|
const auto commit_and_hash = fmt::split(RPCS3_GIT_VERSION, {"-"});
|
2019-09-11 07:55:43 +00:00
|
|
|
if (commit_and_hash.size() != 2)
|
|
|
|
return std::make_pair("0", "00000000");
|
|
|
|
|
|
|
|
return std::make_pair(commit_and_hash[0], commit_and_hash[1]);
|
|
|
|
}
|
|
|
|
|
2019-09-17 20:17:20 +00:00
|
|
|
// TODO: Make this accessible from cmake and keep in sync with MACOSX_BUNDLE_BUNDLE_VERSION.
|
|
|
|
// Currently accessible by Windows and Linux build scripts, see implementations when doing MACOSX
|
2020-01-30 21:03:36 +00:00
|
|
|
const utils::version& get_version()
|
|
|
|
{
|
2022-05-01 12:34:29 +00:00
|
|
|
static constexpr utils::version version{ 0, 0, 22, utils::version_type::alpha, 1, RPCS3_GIT_VERSION };
|
2020-01-30 21:03:36 +00:00
|
|
|
return version;
|
|
|
|
}
|
2020-02-20 02:55:25 +00:00
|
|
|
|
|
|
|
std::string get_version_and_branch()
|
|
|
|
{
|
|
|
|
// Add branch and commit hash to version on frame unless it's master.
|
|
|
|
if (rpcs3::get_branch() != "master"sv && rpcs3::get_branch() != "HEAD"sv)
|
|
|
|
{
|
2022-04-14 20:32:45 +00:00
|
|
|
return get_verbose_version();
|
2020-02-20 02:55:25 +00:00
|
|
|
}
|
2022-04-14 20:32:45 +00:00
|
|
|
|
|
|
|
// Get version by substringing VersionNumber-buildnumber-commithash to get just the part before the dash
|
|
|
|
std::string version = rpcs3::get_version().to_string();
|
|
|
|
|
|
|
|
const auto last_minus = version.find_last_of('-');
|
|
|
|
version = version.substr(0, last_minus);
|
|
|
|
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string get_verbose_version()
|
|
|
|
{
|
|
|
|
std::string version = fmt::format("%s | %s", rpcs3::get_version().to_string(), get_branch());
|
|
|
|
if (is_local_build())
|
2020-02-20 02:55:25 +00:00
|
|
|
{
|
2022-04-14 20:32:45 +00:00
|
|
|
fmt::append(version, " | local_build");
|
2020-02-20 02:55:25 +00:00
|
|
|
}
|
|
|
|
return version;
|
|
|
|
}
|
2022-04-14 20:32:45 +00:00
|
|
|
|
|
|
|
bool is_release_build()
|
|
|
|
{
|
|
|
|
static constexpr bool is_release_build = std::string_view(RPCS3_GIT_FULL_BRANCH) == "RPCS3/rpcs3/master"sv;
|
|
|
|
return is_release_build;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_local_build()
|
|
|
|
{
|
|
|
|
static constexpr bool is_local_build = std::string_view(RPCS3_GIT_FULL_BRANCH) == "local_build"sv;
|
|
|
|
return is_local_build;
|
|
|
|
}
|
2016-05-07 18:38:52 +00:00
|
|
|
}
|