Skip to content

Commit c2bafae

Browse files
authored
Treat version and operand_kinds as optional in generate_language_headers (KhronosGroup#6706)
Grammars such as NonSemantic.Graph.DebugInfo omit operand_kinds and version. Match SPIRV-Headers optional-field handling so GN header generation succeeds. This should fix the CI error I'm seeing here: KhronosGroup/glslang#4275 ``` python3 ../../External/spirv-tools/utils/generate_language_headers.py --extinst-grammar ../../External/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.nonsemantic.graph.debuginfo.grammar.json --extinst-output-path gen/External/spirv-tools/NonSemanticGraphDebugInfo.h Traceback (most recent call last): File "/tmpfs/src/github/glslang/out/Default-hlsl-false/../../External/spirv-tools/utils/generate_language_headers.py", line 185, in main() File "/tmpfs/src/github/glslang/out/Default-hlsl-false/../../External/spirv-tools/utils/generate_language_headers.py", line 176, in main operand_kinds = grammar_json['operand_kinds'], ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ KeyError: 'operand_kinds' ``` This change was mostly debugged/written using Cursor.
1 parent 21c81e0 commit c2bafae

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

utils/generate_language_headers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,20 @@ def main():
170170
with open(args.extinst_grammar) as json_file:
171171
grammar_json = json.loads(json_file.read())
172172
grammar_name = os.path.splitext(os.path.basename(args.extinst_output_path))[0]
173+
if 'version' in grammar_json:
174+
version = grammar_json['version']
175+
else:
176+
version = 0
177+
if 'operand_kinds' in grammar_json:
178+
operand_kinds = grammar_json['operand_kinds']
179+
else:
180+
operand_kinds = []
181+
173182
grammar = ExtInstGrammar(name = grammar_name,
174183
copyright = grammar_json['copyright'],
175184
instructions = grammar_json['instructions'],
176-
operand_kinds = grammar_json['operand_kinds'],
177-
version = grammar_json['version'],
185+
operand_kinds = operand_kinds,
186+
version = version,
178187
revision = grammar_json['revision'])
179188
make_path_to_file(args.extinst_output_path)
180189
with open(args.extinst_output_path, 'w') as f:

0 commit comments

Comments
 (0)