[Mesa-dev] [PATCH v3 04/15] anv: don't pass xmlfile via stdin anv_entrypoints_gen.py

Dylan Baker dylan at pnwbakers.com
Fri Feb 24 18:21:32 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 1e53970..9dabf1c 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)
@@ -177,7 +177,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints libmesa_genxml
 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 449188f..565559c 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -146,12 +146,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 d3f028e..ea15065 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
 
@@ -56,13 +56,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
@@ -138,7 +131,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
@@ -154,7 +153,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