From 53bc79561689d8cf045061ba972a9e5099aa750f Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 5 Apr 2024 16:50:14 -0500 Subject: [PATCH] nouveau: Use hyphenated arguments to class_parser.py This is more consistent with other code generators in Mesa. Part-of: --- src/nouveau/headers/class_parser.py | 15 ++++++++++----- src/nouveau/headers/meson.build | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/nouveau/headers/class_parser.py b/src/nouveau/headers/class_parser.py index 43d305d649d..6b71f656db7 100644 --- a/src/nouveau/headers/class_parser.py +++ b/src/nouveau/headers/class_parser.py @@ -252,6 +252,7 @@ def parse_header(nvcl, f): # state 2 looking for enums for a fields in a method # blank lines reset the state machine to 0 + version = None state = 0 mthddict = {} curmthd = {} @@ -271,6 +272,9 @@ def parse_header(nvcl, f): continue if not list[1].startswith(nvcl): + if len(list) > 2 and list[2].startswith("0x"): + assert version is None + version = (list[1], list[2]) continue if list[1].endswith("TYPEDEF"): @@ -331,13 +335,13 @@ def parse_header(nvcl, f): curmthd = x state = 1 - return mthddict + return (version, mthddict) def main(): parser = argparse.ArgumentParser() - parser.add_argument('--out_h', required=True, help='Output C header.') - parser.add_argument('--out_c', required=True, help='Output C file.') - parser.add_argument('--in_h', + parser.add_argument('--out-h', required=True, help='Output C header.') + parser.add_argument('--out-c', required=True, help='Output C file.') + parser.add_argument('--in-h', help='Input class header file.', required=True) args = parser.parse_args() @@ -350,12 +354,13 @@ def main(): nvcl = "NV" + nvcl with open(args.in_h, 'r', encoding='utf-8') as f: - mthddict = parse_header(nvcl, f) + (version, mthddict) = parse_header(nvcl, f) environment = { 'clheader': clheader, 'header': os.path.basename(args.out_h), 'nvcl': nvcl, + 'version': version, 'mthddict': mthddict, 'bs': '\\' } diff --git a/src/nouveau/headers/meson.build b/src/nouveau/headers/meson.build index cc490263a54..13b6a3289a1 100644 --- a/src/nouveau/headers/meson.build +++ b/src/nouveau/headers/meson.build @@ -34,8 +34,8 @@ foreach cl : nvk_classes cl + '.h', input : ['class_parser.py', 'nvidia/classes/'+cl+'.h'], output : ['nvk_'+cl+'.h', 'nvk_'+cl+'.c'], - command : [prog_python, '@INPUT0@', '--in_h', '@INPUT1@', - '--out_h', '@OUTPUT0@', '--out_c', '@OUTPUT1@'], + command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', + '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@'], depend_files: nvk_cl_header_depend_files, ) endforeach