code gen: Be more robust to dirty hashes.

If any JSON files get out of whack this will print which file is
malformed. Also will show any temporary files (e.g. .rej or .orig)
as untracked in the code generation hashes dir.

Bug: angleproject:3691
Change-Id: I534e87bd2ea692182aa558bb80e09fb526e441b0
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2564000
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill
2020-11-27 15:36:05 -05:00
committed by Commit Bot
parent 3d061021c9
commit 5968da649c
2 changed files with 7 additions and 1 deletions

3
.gitignore vendored
View File

@@ -93,3 +93,6 @@ Release_Win32/
Release_x64/
TestResults.qpa
.idea/
# Any temporary files will confuse code generation.
!scripts/code_generation_hashes/*

View File

@@ -182,7 +182,10 @@ def load_hashes():
for file in os.listdir(hash_dir):
hash_fname = os.path.join(hash_dir, file)
with open(hash_fname) as hash_file:
hashes[file] = json.load(open(hash_fname))
try:
hashes[file] = json.load(hash_file)
except ValueError:
raise Exception("Could not decode JSON from %s" % file)
return hashes