Commit dd19d554 by Geoff Lang Committed by Commit Bot

Change commit_id 'check' back to looking for .git files.

commit_id.py was change to try running 'git status' to confirm that git was present. This caused it to succeed if there was a git checkout somewhere above ANGLE if ANGLE's .git didn't exist, incorrectly adding a non-existant .git/HEAD file to the gn rule's inputs. Always verify that ANGLE's .git/HEAD is present in commit_id.py. BUG=angleproject:2344 Change-Id: I7e170f39c8d5cef73086ecf6d68925a1d3512de1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2082993 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarBrian Osman <brianosman@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 35785308
...@@ -462,14 +462,12 @@ action("commit_id") { ...@@ -462,14 +462,12 @@ action("commit_id") {
script = "src/commit_id.py" script = "src/commit_id.py"
outputs = [ commit_id_output_file ] outputs = [ commit_id_output_file ]
# commit id should depend on angle's HEAD revision
commit_id_git_dep = ".git/HEAD"
# Add git as a dependency if it is available. # Add git as a dependency if it is available.
angle_git_is_present = angle_git_is_present =
exec_script("src/commit_id.py", [ "check" ], "value") == 1 exec_script("src/commit_id.py", [ "check" ], "value") == 1
if (angle_git_is_present) { if (angle_git_is_present) {
inputs = [ commit_id_git_dep ] # commit id should depend on angle's HEAD revision
inputs = [ ".git/HEAD" ]
} }
args = [ args = [
......
...@@ -23,14 +23,16 @@ if len(sys.argv) < 2: ...@@ -23,14 +23,16 @@ if len(sys.argv) < 2:
sys.exit(usage) sys.exit(usage)
operation = sys.argv[1] operation = sys.argv[1]
# Set the root of ANGLE's repo as the working directory
cwd = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') cwd = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
git_dir_exists = os.path.exists(os.path.join(cwd, '.git', 'HEAD'))
if operation == 'check': if operation == 'check':
try: if git_dir_exists:
# Try a git command to verify the cwd is valid and we can use the 'gen command'
grab_output('git status', cwd)
print("1") print("1")
except: else:
print("0") print("0")
sys.exit(0) sys.exit(0)
...@@ -41,13 +43,15 @@ output_file = sys.argv[2] ...@@ -41,13 +43,15 @@ output_file = sys.argv[2]
commit_id_size = 12 commit_id_size = 12
commit_id = 'unknown hash' commit_id = 'unknown hash'
commit_date = 'unknown date' commit_date = 'unknown date'
enable_binary_loading = False
additional_defines = [] if git_dir_exists:
try: try:
commit_id = grab_output('git rev-parse --short=%d HEAD' % commit_id_size, cwd) 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) commit_date = grab_output('git show -s --format=%ci HEAD', cwd)
except: enable_binary_loading = True
additional_defines.append('#define ANGLE_DISABLE_PROGRAM_BINARY_LOAD') except:
pass
hfile = open(output_file, 'w') hfile = open(output_file, 'w')
...@@ -55,7 +59,7 @@ hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id) ...@@ -55,7 +59,7 @@ 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_HASH_SIZE %d\n' % commit_id_size)
hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date) hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date)
for additional_define in additional_defines: if not enable_binary_loading:
hfile.write(additional_define + '\n') hfile.write('#define ANGLE_DISABLE_PROGRAM_BINARY_LOAD\n')
hfile.close() hfile.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment