<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 21, 2016 at 6:16 AM, Emil Velikov <span dir="ltr"><<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
<br>
Rather than parsing through the same files (public headers) twice, tweak<br>
the python script to create both files at the same time.<br></blockquote><div><br></div><div>Yes, but it takes almost zero time to generate them and it's going to run in parallel before anything else gets built. I don't know that this really saves us anything.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Chances are that if the public headers change, both files will need to<br>
be regenerated.<br>
<br>
Note to the python masters: this patch aims to be the least evasive<br>
change. Feel free to change/rewrite things to your liking.<br>
<br>
Signed-off-by: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
---<br>
src/intel/vulkan/Makefile.am | 8 +++----<br>
src/intel/vulkan/anv_entrypoints_gen.py | 41 ++++++++++++++++++++++++---------<br>
2 files changed, 33 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am<br>
index 360e97f..110961e 100644<br>
--- a/src/intel/vulkan/Makefile.am<br>
+++ b/src/intel/vulkan/Makefile.am<br>
@@ -126,11 +126,9 @@ VULKAN_LIB_DEPS += \<br>
<br>
libvulkan_intel_la_SOURCES = $(VULKAN_GEM_FILES)<br>
<br>
-anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_include_HEADERS)<br>
- $(AM_V_GEN) cat $(vulkan_include_HEADERS) | $(CPP) $(AM_CPPFLAGS) - | $(PYTHON2) $< header > $@<br>
-<br>
-anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_include_HEADERS)<br>
- $(AM_V_GEN) cat $(vulkan_include_HEADERS) | $(CPP) $(AM_CPPFLAGS) - | $(PYTHON2) $< code > $@<br>
+anv_entrypoints.c anv_entrypoints.h : anv_entrypoints_gen.py $(vulkan_include_HEADERS)<br>
+ $(AM_V_GEN) cat $(vulkan_include_HEADERS) | $(CPP) $(AM_CPPFLAGS) - | \<br>
+ $(PYTHON2) $(srcdir)/anv_entrypoints_gen.py $(builddir)<br>
<br>
CLEANFILES = $(BUILT_SOURCES)<br>
<br>
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py<br>
index cedecfe..19bfb93 100644<br>
--- a/src/intel/vulkan/anv_entrypoints_gen.py<br>
+++ b/src/intel/vulkan/anv_entrypoints_gen.py<br>
@@ -22,7 +22,7 @@<br>
# IN THE SOFTWARE.<br>
#<br>
<br>
-import fileinput, re, sys<br>
+import fileinput, re, sys, os<br>
<br>
# Each function typedef in the vulkan.h header is all on one line and matches<br>
# this regepx. We hope that won't change.<br>
@@ -51,15 +51,21 @@ def hash(name):<br>
<br>
return h<br>
<br>
-opt_header = False<br>
-opt_code = False<br>
+if len(sys.argv[1:]) != 1:<br>
+ print "Usage: %s <output_directory>" % sys.argv[0]<br>
+ exit(1)<br>
+<br>
+output_dir = sys.argv[1]<br>
+if not os.path.isdir(output_dir):<br>
+ if os.path.exists(output_dir):<br>
+ print "ERROR: Invalid output directory: %s" % output_dir<br>
+ exit(1)<br>
+<br>
+sys.argv.pop()<br>
+# Output path exists, now just run the template<br>
+output_file = os.sep.join([output_dir, 'anv_entrypoints.c'])<br>
+output_header = os.sep.join([output_dir, 'anv_entrypoints.h'])<br>
<br>
-if (sys.argv[1] == "header"):<br>
- opt_header = True<br>
- sys.argv.pop()<br>
-elif (sys.argv[1] == "code"):<br>
- opt_code = True<br>
- sys.argv.pop()<br>
<br>
# Parse the entry points in the header<br>
<br>
@@ -77,7 +83,11 @@ for line in fileinput.input():<br>
# For outputting entrypoints.h we generate a anv_EntryPoint() prototype<br>
# per entry point.<br>
<br>
-if opt_header:<br>
+def generate_header(output_header):<br>
+ orig_stdout = sys.stdout<br>
+ hdr = file(output_header, 'w')<br>
+ sys.stdout = hdr<br></blockquote><div><br></div><div>This is a bit ugly...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
print "/* This file generated from vk_gen.py, don't edit directly. */\n"<br>
<br>
print "struct anv_dispatch_table {"<br>
@@ -100,9 +110,15 @@ if opt_header:<br>
print "%s gen8_%s%s;" % (type, name, args)<br>
print "%s gen9_%s%s;" % (type, name, args)<br>
print "%s anv_validate_%s%s;" % (type, name, args)<br>
- exit()<br>
<br>
+ sys.stdout = orig_stdout<br>
+ hdr.close()<br>
<br>
+generate_header(output_header)<br>
+<br>
+orig_stdout = sys.stdout<br>
+src = file(output_file, 'w')<br>
+sys.stdout = src<br>
<br>
print """/*<br>
* Copyright © 2015 Intel Corporation<br>
@@ -321,3 +337,6 @@ anv_lookup_entrypoint(const char *name)<br>
return anv_resolve_entrypoint(i);<br>
}<br>
""" % (prime_factor, prime_step, hash_mask)<br>
+<br>
+sys.stdout = orig_stdout<br>
+src.close()<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.8.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>