From a12d15bd45312fb6d3c3d20bf686fdc695483e66 Mon Sep 17 00:00:00 2001 From: Mike Schuchardt Date: Wed, 15 Sep 2021 08:53:19 -0700 Subject: scripts: Ignore compatibility constants in wrapper When the working group changes the name of a constant: VK_KHR_MAINTENANCE1_SPEC_VERSION -> VK_KHR_MAINTENANCE_1_SPEC_VERSION they will still #define the original name to maintain backward compatibility with existing code that uses it: #define VK_KHR_MAINTENANCE_1_SPEC_VERSION 2 #define VK_KHR_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_maintenance1" #define VK_KHR_MAINTENANCE1_SPEC_VERSION VK_KHR_MAINTENANCE_1_SPEC_VERSION #define VK_KHR_MAINTENANCE1_EXTENSION_NAME VK_KHR_MAINTENANCE_1_EXTENSION_NAME In this case, we need to ignore the non-numeric _SPEC_VERSION and unquoted _EXTENSION_NAME constants because they don't define a separate extension. --- scripts/generate_vulkan_wrapper.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/generate_vulkan_wrapper.py b/scripts/generate_vulkan_wrapper.py index 5abdc279..09be2ca4 100755 --- a/scripts/generate_vulkan_wrapper.py +++ b/scripts/generate_vulkan_wrapper.py @@ -1800,14 +1800,19 @@ def parse_subheader(filename, ext_guard): current_ext.add_command(Command.from_c_typedef(line)) elif line.startswith("#define") and "SPEC_VERSION " in line: version_begin = line.rfind(" ") + 1 - spec_version = int(line[version_begin:]) + version_str = line[version_begin:] + # Non-numeric versions are used for backward compatibility and should be ignored + if version_str.isdigit(): + spec_version = int(version_str) elif line.startswith("#define") and "EXTENSION_NAME " in line: name_end = line.rfind("\"") - name_begin = line.rfind("\"", 0, name_end) + 1 - name = line[name_begin:name_end] - # add extension - current_ext = Extension(name, spec_version, ext_guard) - sub_extensions.append(current_ext) + name_begin = line.rfind("\"", 0, name_end) + # Unquoted names are used for backward compatibility and should be ignored + if name_begin != -1 and name_end != -1: + name = line[name_begin + 1:name_end] + # add extension + current_ext = Extension(name, spec_version, ext_guard) + sub_extensions.append(current_ext) return sub_extensions; -- cgit v1.2.3