<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 22, 2016 at 10:27 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"><span class="">On 22 April 2016 at 04:36, Kristian Høgsberg <<a href="mailto:krh@bitplanet.net">krh@bitplanet.net</a>> wrote:<br>
> On Thu, Apr 21, 2016 at 5:18 PM, Emil Velikov <<a href="mailto:emil.l.velikov@gmail.com">emil.l.velikov@gmail.com</a>> wrote:<br>
>> On 21 April 2016 at 22:50, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
>>> On Thu, Apr 21, 2016 at 6:16 AM, Emil Velikov <<a href="mailto:emil.l.velikov@gmail.com">emil.l.velikov@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> 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>
>>><br>
>>><br>
>>> Yes, but it takes almost zero time to generate them and it's going to run in<br>
>>> parallel before anything else gets built.  I don't know that this really<br>
>>> saves us anything.<br>
>>><br>
>> Are you sure about this one? Based on my brief testing - things were<br>
>> pretty much stalled until both files were generated. I'll take another<br>
>> look.<br>
>><br>
>> If anything the approach cuts down the bash output redirection and<br>
>> some nasty handling around it.<br>
>> Talking about the following $(PYHON) ....  > $@ || ($(RM) $@; false)<br>
>> and how often we forget to add it.<br>
>><br>
</span>Things get stalled for all the sources to be generated before proceeding with<br>
the compilation. Thus there isn't much benefit with the current approach afaict.<br><div><div class="h5"></div></div></blockquote><div><br></div><div>Yes, but if they run in parallel (which they will on *any* modern machine), then it only takes as long as the longest one takes to run.  I don't think it's actually helping anything to do them both with one python invocation except for the make -j1 case.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
>>>><br>
>>>> 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>
>>>> ++++++++++++++++++++++++---------<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)<br>
>>>> - | $(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)<br>
>>>> - | $(PYTHON2) $< code > $@<br>
>>>> +anv_entrypoints.c anv_entrypoints.h : anv_entrypoints_gen.py<br>
>>>> $(vulkan_include_HEADERS)<br>
>>>> +       $(AM_V_GEN) cat $(vulkan_include_HEADERS) | $(CPP) $(AM_CPPFLAGS)<br>
>>>> - | \<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<br>
>>>> 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<br>
>>>> 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>
>>><br>
>>><br>
>>> This is a bit ugly...<br>
>>><br>
>> s/a bit/a fair bit/<br>
>><br>
>> Definitely, but in all honesty the currently the script isn't the<br>
>> prettiest one either. I'm pretty sure Dylan will end up rewriting the<br>
>> whole thing if he has the time/chance. Even without this patch ;-)<br>
><br>
> The rewrite that would be worthwhile is to make it parse the spec xml.<br>
> Not sure churning this script really helps anything.<br>
><br>
</div></div>Precisely why I've went ahead with the fastest/least evasive solution :-)<br>
<span class="HOEnZb"><font color="#888888"><br>
-Emil<br>
</font></span></blockquote></div><br></div></div>