From e4497d5b9a3e8e30213435d8fd36ea62141490a4 Mon Sep 17 00:00:00 2001 From: illusion98 <37698908+illusion98@users.noreply.github.com> Date: Sun, 12 Jan 2020 16:30:09 +1100 Subject: [PATCH] Add commit number --- src/xenia/app/emulator_window.cc | 2 ++ xenia-build | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc index ad35b9318..5ce94b43e 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -58,6 +58,8 @@ EmulatorWindow::EmulatorWindow(Emulator* emulator) #endif #endif L" (" + xe::to_wstring(XE_BUILD_BRANCH) + L"/" + + L"0.0.0." + + xe::to_wstring(XE_BUILD_COMMIT_NUMBER) + L"/" + xe::to_wstring(XE_BUILD_COMMIT_SHORT) + L"/" + xe::to_wstring(XE_BUILD_DATE) + L")"; } diff --git a/xenia-build b/xenia-build index 3fcfbd2ba..4b545632c 100755 --- a/xenia-build +++ b/xenia-build @@ -229,6 +229,14 @@ def get_git_head_info(): ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() branch_name = stdout.decode('ascii').strip() or 'detached' + p = subprocess.Popen([ + 'git', + 'rev-list', + 'HEAD', + '--count', + ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (stdout, stderr) = p.communicate() + commit_number = stdout.decode('ascii').strip() or '0000' p = subprocess.Popen([ 'git', 'rev-parse', @@ -244,22 +252,23 @@ def get_git_head_info(): ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() commit_short = stdout.decode('ascii').strip() or 'unknown' - return branch_name, commit, commit_short + return branch_name, commit_number, commit, commit_short def generate_version_h(): """Generates a build/version.h file that contains current git info. """ - (branch_name, commit, commit_short) = get_git_head_info() + (branch_name, commit_number, commit, commit_short) = get_git_head_info() contents = '''// Autogenerated by `xb premake`. #ifndef GENERATED_VERSION_H_ #define GENERATED_VERSION_H_ #define XE_BUILD_BRANCH "%s" + #define XE_BUILD_COMMIT_NUMBER "%s" #define XE_BUILD_COMMIT "%s" #define XE_BUILD_COMMIT_SHORT "%s" #define XE_BUILD_DATE __DATE__ #endif // GENERATED_VERSION_H_ - ''' % (branch_name, commit, commit_short) + ''' % (branch_name, commit_number, commit, commit_short) with open('build/version.h', 'w') as f: f.write(contents)