rpcs3/rpcs3/rpcs3_version.cpp
AniLeo 595e42c4f3
Some checks are pending
Generate Translation Template / Generate Translation Template (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.9, ubuntu-24.04-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.9, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.9, ubuntu-24.04-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.9, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (0, 51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, Intel) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (1, 8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, Apple Silicon) (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (aarch64, clang, clangarm64, ARM64, windows-11-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (x86_64, clang, clang64, X64, windows-2025) (push) Waiting to run
Build RPCS3 / RPCS3 FreeBSD (push) Waiting to run
rpcs3_version: Bump to 0.0.40
2026-03-03 13:16:24 +01:00

71 lines
1.8 KiB
C++

#include "stdafx.h"
#include "rpcs3_version.h"
#include "git-version.h"
#include "Utilities/StrUtil.h"
namespace rpcs3
{
std::string_view get_branch()
{
return RPCS3_GIT_BRANCH;
}
std::string_view get_full_branch()
{
return RPCS3_GIT_FULL_BRANCH;
}
std::pair<std::string, std::string> get_commit_and_hash()
{
auto commit_and_hash = fmt::split(RPCS3_GIT_VERSION, {"-"});
if (commit_and_hash.size() != 2)
return std::make_pair("0", "00000000");
return std::make_pair(std::move(commit_and_hash[0]), std::move(commit_and_hash[1]));
}
const utils::version& get_version()
{
static constexpr utils::version version{ 0, 0, 40, utils::version_type::alpha, 1, RPCS3_GIT_VERSION };
return version;
}
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)
{
return get_verbose_version();
}
// 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())
{
fmt::append(version, " | local_build");
}
return version;
}
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;
}
}