radv: don't use python 3.9 feature in radv_annotate_layer_gen.py

This commit adds an implementation of removesuffix so we don't
need the 'str' one which was added in 3.9.

Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28831>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2024-04-19 16:51:40 +02:00
committed by Marge Bot
parent 27a3880ada
commit b926cd3dd9
@@ -52,6 +52,18 @@ annotate_${c.name}(${c.decl_params()})
% endfor
""")
# str.removesuffix requires python 3.9+ so implement our own to not break build
# on older versions
def removesuffix(s, suffix):
l = len(suffix)
if l == 0:
return s
idx = s.find(suffix)
if idx == len(s) - l:
return s[:-l]
return s
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--out-c", required=True, help="Output C file.")
@@ -67,7 +79,7 @@ def main():
if not e.name.startswith('Cmd') or e.alias or e.return_type != "void":
continue
stripped_name = e.name.removesuffix('EXT').removesuffix('KHR').removesuffix('2')
stripped_name = removesuffix(removesuffix(removesuffix(e.name, 'EXT'), 'KHR'), '2')
if stripped_name in commands_names or stripped_name in EXCLUDED_COMMANDS:
continue