mirror of
https://github.com/utmapp/angle.git
synced 2026-12-06 11:52:50 -10:00
The SPIRV-Tools 'external revision generate' script is coded such that it assumes a .git folder is present. This causes a problem for the tarball build. We can fix this by using the same tooling we use for ANGLE's commit id script to check if the .git directory is present before running the generator. If it is missing, we insert a hard-coded dummy header. Also use the 'DEPS' file as a placeholder for .git/HEAD to check if the current revision needs updating. Bug: chromium:799620 Bug: angleproject:2237 Change-Id: Icea8e9c66f1600df7dca2aaa45fe449f687f5b55 Reviewed-on: https://chromium-review.googlesource.com/854255 Reviewed-by: Jamie Madill <[email protected]> Commit-Queue: Jamie Madill <[email protected]>
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
import subprocess as sp
|
|
import sys
|
|
import os
|
|
|
|
usage = """\
|
|
Usage: commit_id.py check <angle_dir> - check if git is present
|
|
commit_id.py gen <angle_dir> <file_to_write> - generate commit.h"""
|
|
|
|
def grab_output(command, cwd):
|
|
return sp.Popen(command, stdout=sp.PIPE, shell=True, cwd=cwd).communicate()[0].strip()
|
|
|
|
if len(sys.argv) < 3:
|
|
sys.exit(usage)
|
|
|
|
operation = sys.argv[1]
|
|
cwd = sys.argv[2]
|
|
|
|
if operation == 'check':
|
|
index_path = os.path.join(cwd, '.git', 'index')
|
|
if os.path.exists(index_path):
|
|
print("1")
|
|
else:
|
|
print("0")
|
|
sys.exit(0)
|
|
|
|
if len(sys.argv) < 4 or operation != 'gen':
|
|
sys.exit(usage)
|
|
|
|
output_file = sys.argv[3]
|
|
commit_id_size = 12
|
|
|
|
try:
|
|
commit_id = grab_output('git rev-parse --short=%d HEAD' % commit_id_size, cwd)
|
|
commit_date = grab_output('git show -s --format=%ci HEAD', cwd)
|
|
except:
|
|
commit_id = 'invalid-hash'
|
|
commit_date = 'invalid-date'
|
|
|
|
hfile = open(output_file, 'w')
|
|
|
|
hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id)
|
|
hfile.write('#define ANGLE_COMMIT_HASH_SIZE %d\n' % commit_id_size)
|
|
hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date)
|
|
|
|
hfile.close()
|