mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-06 18:08:31 +00:00
Update s2_sample_mm AMBuildScript
Adds git-tag and git-commits-after-tag version strings, also fixes errors on fresh/empty git repos
This commit is contained in:
parent
2221689ce8
commit
2f75343a6b
@ -47,7 +47,7 @@ def runAndReturn(argv):
|
||||
output, ignored = p.communicate()
|
||||
rval = p.poll()
|
||||
if rval:
|
||||
raise subprocess.CalledProcessError(rval, argv)
|
||||
return None
|
||||
text = output.decode('utf8')
|
||||
return text.strip()
|
||||
|
||||
@ -227,8 +227,16 @@ extern const char* PLUGIN_REVISION_COUNT;
|
||||
builder.AddConfigureFile(git_head_path)
|
||||
builder.AddConfigureFile(direct_head)
|
||||
|
||||
revision_count = runAndReturn(['git', 'rev-list', '--count', 'HEAD'])
|
||||
revision_hash = runAndReturn(['git', 'log', '--pretty=format:%h:%H', '-n', '1'])
|
||||
tag = runAndReturn(['git', 'describe', '--tags']) or 'MISSING_TAG'
|
||||
commits_after_tag = '0'
|
||||
|
||||
tag_match = re.match(r'(.+?)\-(\d+)\-g[a-f\d]+$', tag, re.MULTILINE)
|
||||
if tag_match is not None:
|
||||
tag = tag_match.group(1)
|
||||
commits_after_tag = tag_match.group(2)
|
||||
|
||||
revision_count = runAndReturn(['git', 'rev-list', '--count', 'HEAD']) or 'MISSING_COUNT'
|
||||
revision_hash = runAndReturn(['git', 'log', '--pretty=format:%h:%H', '-n', '1']) or 'MISSING_SHORTHASH:MISSING_LONGHASH'
|
||||
shorthash, longhash = revision_hash.split(':')
|
||||
|
||||
if '{{git-shorthash}}' in version:
|
||||
@ -240,6 +248,12 @@ extern const char* PLUGIN_REVISION_COUNT;
|
||||
if '{{git-count}}' in version:
|
||||
version = version.replace('{{git-count}}', revision_count)
|
||||
|
||||
if '{{git-tag}}' in version:
|
||||
version = version.replace('{{git-tag}}', tag)
|
||||
|
||||
if '{{git-commits-after-tag}}' in version:
|
||||
version = version.replace('{{git-commits-after-tag}}', commits_after_tag)
|
||||
|
||||
# For the version strings and git hashes compile that to a static library instead,
|
||||
# to prevent a full recompilation on version/git changes which would only trigger this cpp
|
||||
# and linking to be performed
|
||||
|
||||
Loading…
Reference in New Issue
Block a user