Add commit number

This commit is contained in:
illusion98 2020-01-12 16:30:09 +11:00 committed by illusion
parent 709843dba5
commit e4497d5b9a
2 changed files with 14 additions and 3 deletions

View File

@ -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")";
}

View File

@ -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)