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.
diff --git a/scripts/generate_vulkan_wrapper.py b/scripts/generate_vulkan_wrapper.py
index 5abdc27..09be2ca 100755
--- a/scripts/generate_vulkan_wrapper.py
+++ b/scripts/generate_vulkan_wrapper.py
@@ -1800,14 +1800,19 @@
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;