Replace SCM_IS_MASTER with SCM_COMMITS_AHEAD_MASTER

This commit is contained in:
Jordan Woyak 2024-03-23 00:18:51 -05:00
parent 3948ac9513
commit 02f57a4778
5 changed files with 18 additions and 10 deletions

View File

@ -18,6 +18,10 @@ if(GIT_FOUND)
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE DOLPHIN_WC_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
# defines DOLPHIN_WC_COMMITS_AHEAD_MASTER
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD ^master
OUTPUT_VARIABLE DOLPHIN_WC_COMMITS_AHEAD_MASTER
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# version number
@ -35,12 +39,7 @@ if(NOT DOLPHIN_WC_REVISION)
set(DOLPHIN_WC_DESCRIBE "${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR}")
set(DOLPHIN_WC_REVISION "${DOLPHIN_WC_DESCRIBE} (no further info)")
set(DOLPHIN_WC_BRANCH "master")
endif()
if(DOLPHIN_WC_BRANCH STREQUAL "master" OR DOLPHIN_WC_BRANCH STREQUAL "stable")
set(DOLPHIN_WC_IS_STABLE "1")
else()
set(DOLPHIN_WC_IS_STABLE "0")
set(DOLPHIN_WC_COMMITS_AHEAD_MASTER 0)
endif()
configure_file(

View File

@ -20,7 +20,8 @@ namespace Common
const std::string& GetScmRevStr()
{
static const std::string scm_rev_str = "Dolphin "
#if !SCM_IS_MASTER
// Note this macro can be empty if the master branch does not exist.
#if 1 - SCM_COMMITS_AHEAD_MASTER - 1 != 0
"[" SCM_BRANCH_STR "] "
#endif
@ -74,4 +75,10 @@ const std::string& GetNetplayDolphinVer()
return netplay_dolphin_ver;
}
int GetScmCommitsAheadMaster()
{
// Note this macro can be empty if the master branch does not exist.
return SCM_COMMITS_AHEAD_MASTER + 0;
}
} // namespace Common

View File

@ -14,4 +14,5 @@ const std::string& GetScmRevGitStr();
const std::string& GetScmDistributorStr();
const std::string& GetScmUpdateTrackStr();
const std::string& GetNetplayDolphinVer();
int GetScmCommitsAheadMaster();
} // namespace Common

View File

@ -5,6 +5,7 @@ var outfile = "./scmrev.h";
var cmd_revision = " rev-parse HEAD";
var cmd_describe = " describe --always --long --dirty";
var cmd_branch = " rev-parse --abbrev-ref HEAD";
var cmd_commits_ahead = " rev-list --count HEAD ^master";
function GetGitExe()
{
@ -76,7 +77,7 @@ var gitexe = GetGitExe();
var revision = GetFirstStdOutLine(gitexe + cmd_revision);
var describe = GetFirstStdOutLine(gitexe + cmd_describe);
var branch = GetFirstStdOutLine(gitexe + cmd_branch);
var isStable = +("master" == branch || "stable" == branch);
var commits_ahead = GetFirstStdOutLine(gitexe + cmd_commits_ahead);
// Get environment information.
var distributor = wshShell.ExpandEnvironmentStrings("%DOLPHIN_DISTRIBUTOR%");
@ -91,7 +92,7 @@ var out_contents =
"#define SCM_REV_STR \"" + revision + "\"\n" +
"#define SCM_DESC_STR \"" + describe + "\"\n" +
"#define SCM_BRANCH_STR \"" + branch + "\"\n" +
"#define SCM_IS_MASTER " + isStable + "\n" +
"#define SCM_COMMITS_AHEAD_MASTER " + commits_ahead + "\n" +
"#define SCM_DISTRIBUTOR_STR \"" + distributor + "\"\n" +
"#define SCM_UPDATE_TRACK_STR \"" + default_update_track + "\"\n";

View File

@ -1,6 +1,6 @@
#define SCM_REV_STR "${DOLPHIN_WC_REVISION}"
#define SCM_DESC_STR "${DOLPHIN_WC_DESCRIBE}"
#define SCM_BRANCH_STR "${DOLPHIN_WC_BRANCH}"
#define SCM_IS_MASTER ${DOLPHIN_WC_IS_STABLE}
#define SCM_COMMITS_AHEAD_MASTER ${DOLPHIN_WC_COMMITS_AHEAD_MASTER}
#define SCM_DISTRIBUTOR_STR "${DISTRIBUTOR}"
#define SCM_UPDATE_TRACK_STR "${DOLPHIN_DEFAULT_UPDATE_TRACK}"