anv/entrypoints: Run the headers through the preprocessor first
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 3 Dec 2015 06:06:22 +0000 (22:06 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 3 Dec 2015 22:13:55 +0000 (14:13 -0800)
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.

src/vulkan/Makefile.am
src/vulkan/anv_entrypoints_gen.py

index 3f6d4a3e2e95340e2a5b5bc03f0c709bdf5a2613..2f24948827036487a0a72df3203f2d1ea6b12523 100644 (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
index 406f1421054a7302102b73ecd5028db3018f02bc..1e4cfcb17555fa7d829d2de393ceac0a6bfc3873 100644 (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 = []