Merge branch 'master' into vulkan
This commit is contained in:
35
xenia-build
35
xenia-build
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user