[Mesa-dev] [RESEND v4 04/16] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

Dylan Baker dylan at pnwbakers.com
Tue Mar 7 21:14:45 UTC 2017


It's slow, and has the potential for encoding issues.

v2: - pass xml file location via argument
    - update Android.mk

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 src/intel/vulkan/Android.mk             |  4 ++--
 src/intel/vulkan/Makefile.am            |  6 ++----
 src/intel/vulkan/anv_entrypoints_gen.py | 19 +++++++++----------
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/intel/vulkan/Android.mk b/src/intel/vulkan/Android.mk
index a6a7d26..d0b27cd 100644
--- a/src/intel/vulkan/Android.mk
+++ b/src/intel/vulkan/Android.mk
@@ -61,7 +61,7 @@ $(intermediates)/dummy.c:
 	$(hide) touch $@
 
 $(intermediates)/anv_entrypoints.h:
-	$(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | $(VK_ENTRYPOINTS_SCRIPT) header > $@
+	$(VK_ENTRYPOINTS_SCRIPT) header --xml $(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
         $(intermediates)
@@ -181,7 +181,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \
 LOCAL_GENERATED_SOURCES += $(intermediates)/anv_entrypoints.c
 
 $(intermediates)/anv_entrypoints.c:
-	$(hide) cat $(MESA_TOP)/src/vulkan/registry/vk.xml | $(VK_ENTRYPOINTS_SCRIPT) code > $@
+	$(VK_ENTRYPOINTS_SCRIPT) code --xml $(MESA_TOP)/src/vulkan/registry/vk.xml > $@
 
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 3cd01e4..9276723 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -147,12 +147,10 @@ libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
 anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_api_xml)
-	$(AM_V_GEN) cat $(vulkan_api_xml) |\
-	$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header > $@
+	$(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py header --xml $(vulkan_api_xml) > $@
 
 anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_api_xml)
-	$(AM_V_GEN) cat $(vulkan_api_xml) |\
-	$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
+	$(AM_V_GEN)$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code --xml $(vulkan_api_xml) > $@
 
 BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json intel_icd. at host_cpu@.json
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py
index 47df4ce..12ee735 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -22,7 +22,7 @@
 # IN THE SOFTWARE.
 #
 
-import sys
+import argparse
 import textwrap
 import xml.etree.ElementTree as et
 
@@ -58,13 +58,6 @@ PRIME_STEP = 19
 opt_header = False
 opt_code = False
 
-if sys.argv[1] == "header":
-    opt_header = True
-    sys.argv.pop()
-elif sys.argv[1] == "code":
-    opt_code = True
-    sys.argv.pop()
-
 
 def hash(name):
     h = 0
@@ -140,7 +133,13 @@ def get_entrypoints_defines(doc):
 
 
 def main():
-    doc = et.parse(sys.stdin)
+    parser = argparse.ArgumentParser()
+    parser.add_argument('target', choices=['header', 'code'],
+                        help='Which file to generate.')
+    parser.add_argument('--xml', help='Vulkan API XML file.')
+    args = parser.parse_args()
+
+    doc = et.parse(args.xml)
     entrypoints = get_entrypoints(doc, get_entrypoints_defines(doc))
 
     # Manually add CreateDmaBufImageINTEL for which we don't have an extension
@@ -156,7 +155,7 @@ def main():
     # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
     # per entry point.
 
-    if opt_header:
+    if args.target == 'header':
         print "/* This file generated from vk_gen.py, don't edit directly. */\n"
 
         print "struct anv_dispatch_table {"
-- 
git-series 0.9.1


More information about the mesa-dev mailing list