amd/vulkan: Use str.removesuffix() from Python 3.9

Signed-off-by: Ernst Persson <ernstp@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36398>
This commit is contained in:
Ernst Persson 2025-07-27 13:46:57 +02:00 committed by Marge Bot
parent 2bdbc72d27
commit fc8a734849

View file

@ -52,17 +52,6 @@ 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()
@ -79,7 +68,7 @@ def main():
if not e.name.startswith('Cmd') or e.alias or e.return_type != "void":
continue
stripped_name = removesuffix(removesuffix(removesuffix(e.name, 'EXT'), 'KHR'), '2')
stripped_name = e.name.removesuffix('EXT').removesuffix('KHR').removesuffix('2')
if stripped_name in commands_names or stripped_name in EXCLUDED_COMMANDS:
continue