From b926cd3dd9bd20745b4e0492c32c7ac202d71390 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 19 Apr 2024 16:51:40 +0200 Subject: [PATCH] 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 Acked-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/layers/radv_annotate_layer_gen.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/layers/radv_annotate_layer_gen.py b/src/amd/vulkan/layers/radv_annotate_layer_gen.py index 107852c2e9e..7878a9fcda1 100644 --- a/src/amd/vulkan/layers/radv_annotate_layer_gen.py +++ b/src/amd/vulkan/layers/radv_annotate_layer_gen.py @@ -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