Use AppVeyor vars for extended version info.

This commit is contained in:
gibbed 2021-08-08 10:20:51 -05:00 committed by Rick Gibbed
parent a9e35b443f
commit ed0a15dcc8
3 changed files with 51 additions and 4 deletions

View File

@ -54,7 +54,12 @@ EmulatorWindow::EmulatorWindow(Emulator* emulator)
" CHECKED"
#endif
#endif
" (" XE_BUILD_BRANCH "/" XE_BUILD_COMMIT_SHORT "/" XE_BUILD_DATE
" ("
#ifdef XE_BUILD_IS_PR
"PR#" XE_BUILD_PR_NUMBER " " XE_BUILD_PR_REPO
" " XE_BUILD_PR_BRANCH "@" XE_BUILD_PR_COMMIT_SHORT " against "
#endif
XE_BUILD_BRANCH "@" XE_BUILD_COMMIT_SHORT " on " XE_BUILD_DATE
")";
}
@ -426,8 +431,13 @@ void EmulatorWindow::ToggleFullscreen() {
void EmulatorWindow::ShowHelpWebsite() { LaunchWebBrowser("https://xenia.jp"); }
void EmulatorWindow::ShowCommitID() {
#ifdef XE_BUILD_IS_PR
LaunchWebBrowser(
"https://github.com/xenia-project/xenia/pull/" XE_BUILD_PR_NUMBER);
#else
LaunchWebBrowser(
"https://github.com/xenia-project/xenia/commit/" XE_BUILD_COMMIT "/");
#endif
}
void EmulatorWindow::UpdateTitle() {

View File

@ -162,7 +162,13 @@ int Main() {
}
// Print version info.
XELOGI("Build: " XE_BUILD_BRANCH " / " XE_BUILD_COMMIT " on " XE_BUILD_DATE);
XELOGI(
"Build: "
#ifdef XE_BUILD_IS_PR
"PR#" XE_BUILD_PR_NUMBER " " XE_BUILD_PR_REPO " " XE_BUILD_PR_BRANCH
"@" XE_BUILD_PR_COMMIT_SHORT " against "
#endif
XE_BUILD_BRANCH "@" XE_BUILD_COMMIT_SHORT " on " XE_BUILD_DATE);
// Request high performance timing.
if (cvars::win32_high_freq) {

View File

@ -262,13 +262,31 @@ def generate_version_h():
"""Generates a build/version.h file that contains current git info.
"""
header_file = 'build/version.h'
if git_is_repository():
pr_number = 0
pr_repo_name = ""
pr_branch_name = ""
pr_commit = ""
pr_commit_short = ""
if os.getenv('APPVEYOR') == 'True':
branch_name = os.getenv('APPVEYOR_REPO_BRANCH')
commit = os.getenv('APPVEYOR_REPO_COMMIT')
commit_short = commit[:9]
pr_number = os.getenv('APPVEYOR_PULL_REQUEST_NUMBER')
if not pr_number:
pr_number = 0
else:
pr_repo_name = os.getenv('APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME')
pr_branch_name = os.getenv('APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH')
pr_commit = os.getenv('APPVEYOR_PULL_REQUEST_HEAD_COMMIT')
pr_commit_short = pr_commit[:9]
elif git_is_repository():
(branch_name, commit, commit_short) = git_get_head_info()
else:
branch_name = 'tarball'
commit = ':(-dont-do-this'
commit_short = ':('
# header
contents_new = '''// Autogenerated by `xb premake`.
#ifndef GENERATED_VERSION_H_
#define GENERATED_VERSION_H_
@ -276,9 +294,22 @@ def generate_version_h():
#define XE_BUILD_COMMIT "{}"
#define XE_BUILD_COMMIT_SHORT "{}"
#define XE_BUILD_DATE __DATE__
#endif // GENERATED_VERSION_H_
'''.format(branch_name, commit, commit_short)
# PR info (if available)
if pr_number != 0:
contents_new += '''#define XE_BUILD_IS_PR
#define XE_BUILD_PR_NUMBER "{}"
#define XE_BUILD_PR_REPO "{}"
#define XE_BUILD_PR_BRANCH "{}"
#define XE_BUILD_PR_COMMIT "{}"
#define XE_BUILD_PR_COMMIT_SHORT "{}"
'''.format(pr_number, pr_repo_name, pr_branch_name, pr_commit, pr_commit_short)
# footer
contents_new += '''#endif // GENERATED_VERSION_H_
'''
contents_old = None
if os.path.exists(header_file) and os.path.getsize(header_file) < 1024:
with open(header_file, 'r') as f: