mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Make Test spec JSON generator hashless.
Removes scripts/code_generation_hashes/Test_spec_JSON.json Instead, run codegen in --verify-only mode and compare content. This run during presubmits and is fast (~0.2s in my tests) Similar to https://crrev.com/c/4604579 With this, should be able to auto-resolve conflicts in infra/specs/angle.json Also testing/buildbot/mixins.pyl seems to have had hashes routinely updated by autorolls. Bug: angleproject:8193 Change-Id: Ic1a657dbf464e6f4a8066ea8c5e18297e27a3b4c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4605467 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Auto-Submit: Roman Lavrov <romanl@google.com> Commit-Queue: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
@@ -13,6 +13,7 @@ import os
|
||||
import pprint
|
||||
import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
d = os.path.dirname
|
||||
THIS_DIR = d(os.path.abspath(__file__))
|
||||
@@ -84,18 +85,44 @@ def main():
|
||||
outputs = ['angle.json', 'mixins.pyl']
|
||||
if sys.argv[1] == 'inputs':
|
||||
print(','.join(inputs))
|
||||
elif sys.argv[1] == 'outputs':
|
||||
return 0
|
||||
if sys.argv[1] == 'outputs':
|
||||
print(','.join(outputs))
|
||||
else:
|
||||
print('Invalid script parameters')
|
||||
return 1
|
||||
return 0
|
||||
return 0
|
||||
|
||||
chromium_args = generate_buildbot_json.BBJSONGenerator.parse_args(sys.argv[1:])
|
||||
# --verify-only enables dirty checks without relying on checked in hashes.
|
||||
# Compares the content of the existing file with the generated content.
|
||||
verify_only = '--verify-only' in sys.argv
|
||||
|
||||
if verify_only:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
return run_generator(verify_only, temp_dir)
|
||||
else:
|
||||
return run_generator(verify_only, None)
|
||||
|
||||
|
||||
def write_or_verify_file(filename, content, verify_only):
|
||||
if verify_only:
|
||||
try:
|
||||
with open(filename) as f:
|
||||
# Note: .gitattributes "* text=auto" handles LF <-> CRLF on Windows
|
||||
return f.read() == content
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
else:
|
||||
with open(filename, 'w') as fout:
|
||||
fout.write(content)
|
||||
return True
|
||||
|
||||
|
||||
def run_generator(verify_only, temp_dir):
|
||||
chromium_args = generate_buildbot_json.BBJSONGenerator.parse_args([])
|
||||
chromium_generator = generate_buildbot_json.BBJSONGenerator(chromium_args)
|
||||
chromium_generator.load_configuration_files()
|
||||
|
||||
override_args = sys.argv[1:] + ['--pyl-files-dir', THIS_DIR]
|
||||
override_args = ['--pyl-files-dir', THIS_DIR]
|
||||
if verify_only:
|
||||
override_args += ['--output-dir', temp_dir]
|
||||
angle_args = generate_buildbot_json.BBJSONGenerator.parse_args(override_args)
|
||||
angle_generator = generate_buildbot_json.BBJSONGenerator(angle_args)
|
||||
angle_generator.load_configuration_files()
|
||||
@@ -131,11 +158,25 @@ def main():
|
||||
}
|
||||
generated_mixin_pyl = MIXINS_PYL_TEMPLATE.format(**format_data)
|
||||
|
||||
with open(MIXIN_FILE_NAME, 'w') as f:
|
||||
f.write(generated_mixin_pyl)
|
||||
f.close()
|
||||
if not write_or_verify_file(MIXIN_FILE_NAME, generated_mixin_pyl, verify_only):
|
||||
print('infra/specs/mixins.pyl dirty')
|
||||
return 1
|
||||
|
||||
return angle_generator.main()
|
||||
if angle_generator.main() != 0:
|
||||
print('buildbot (pyl to json) generation failed')
|
||||
return 1
|
||||
|
||||
if verify_only:
|
||||
for waterfall in angle_generator.waterfalls:
|
||||
filename = waterfall['name'] + '.json' # angle.json, might have more in future
|
||||
with open(os.path.join(temp_dir, filename)) as f:
|
||||
content = f.read()
|
||||
angle_filename = os.path.join(THIS_DIR, filename)
|
||||
if not write_or_verify_file(angle_filename, content, True):
|
||||
print('infra/specs/%s dirty' % filename)
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"infra/specs/angle.json":
|
||||
"767f56197f6f853c88c9bd6221a71983",
|
||||
"infra/specs/generate_test_spec_json.py":
|
||||
"b8dbb50c814b7fe05eb77cf6e376cee4",
|
||||
"infra/specs/mixins.pyl":
|
||||
"54a3f8bd82fa04025538a2d96f163066",
|
||||
"infra/specs/test_suite_exceptions.pyl":
|
||||
"55886f8b6ae4122306ce42083c5126c7",
|
||||
"infra/specs/test_suites.pyl":
|
||||
"64dbc702fcf98524edd79a154e97efb9",
|
||||
"infra/specs/variants.pyl":
|
||||
"8cfcaa99fa07ad2a2d5d14f220fd5037",
|
||||
"infra/specs/waterfalls.pyl":
|
||||
"dc0b858cd95192e7b5695b80c57a5614",
|
||||
"testing/buildbot/generate_buildbot_json.py":
|
||||
"981e4588c647f09b090f028bd9816d51",
|
||||
"testing/buildbot/mixins.pyl":
|
||||
"73791de121604a26f47488ce160593aa"
|
||||
}
|
||||
@@ -120,8 +120,6 @@ generators = {
|
||||
'src/common/spirv/gen_spirv_builder_and_parser.py',
|
||||
'Static builtins':
|
||||
'src/compiler/translator/gen_builtin_symbols.py',
|
||||
'Test spec JSON':
|
||||
'infra/specs/generate_test_spec_json.py',
|
||||
'uniform type':
|
||||
'src/common/gen_uniform_type_table.py',
|
||||
'Vulkan format':
|
||||
@@ -136,6 +134,7 @@ generators = {
|
||||
# Fast and supports --verify-only without hashes.
|
||||
hashless_generators = {
|
||||
'ANGLE features': 'include/platform/gen_features.py',
|
||||
'Test spec JSON': 'infra/specs/generate_test_spec_json.py',
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user