anv/entrypoints: Run the headers through the preprocessor first

This allows us to filter based on preprocessor directives.  We could build
a partial preprocessor into the generator, but we would likely get it
wrong.  This allows us to filter out, for instance, windows-specific WSI
stuff.
This commit is contained in:
Jason Ekstrand 2015-12-02 22:06:22 -08:00
parent 4c19243562
commit fde60c1684
2 changed files with 9 additions and 3 deletions

View File

@ -30,6 +30,12 @@ vulkan_include_HEADERS = \
$(top_srcdir)/include/vulkan/vk_ext_khr_swapchain.h \
$(top_srcdir)/include/vulkan/vk_ext_khr_device_swapchain.h
# Used when generating entrypoints to filter out unwanted extensions
VULKAN_ENTRYPOINT_CPPFLAGS = \
-I$(top_srcdir)/include/vulkan \
-DVK_USE_PLATFORM_XCB_KHR \
-DVK_USE_PLATFORM_WAYLAND_KHR
lib_LTLIBRARIES = libvulkan.la
check_LTLIBRARIES = libvulkan-test.la
@ -146,10 +152,10 @@ libvulkan_la_SOURCES = \
anv_gem.c
anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_include_HEADERS)
$(AM_V_GEN)cat $(vulkan_include_HEADERS) | $(PYTHON2) $< header > $@
$(AM_V_GEN) cat $(vulkan_include_HEADERS) | $(CPP) $(VULKAN_ENTRYPOINT_CPPFLAGS) - | $(PYTHON2) $< header > $@
anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_include_HEADERS)
$(AM_V_GEN)cat $(vulkan_include_HEADERS) | $(PYTHON2) $< code > $@
$(AM_V_GEN) cat $(vulkan_include_HEADERS) | $(CPP) $(VULKAN_ENTRYPOINT_CPPFLAGS) - | $(PYTHON2) $< code > $@
isl_format_layout.c: isl_format_layout_gen.bash \
isl_format_layout.csv

View File

@ -27,7 +27,7 @@ import fileinput, re, sys
# Each function typedef in the vulkan.h header is all on one line and matches
# this regepx. We hope that won't change.
p = re.compile('typedef ([^ ]*) *\(VKAPI_PTR \*PFN_vk([^(]*)\)(.*);')
p = re.compile('typedef ([^ ]*) *\((?:VKAPI_PTR)? *\*PFN_vk([^(]*)\)(.*);')
entrypoints = []