[Mesa-dev] [PATCH 3/4] anv: Use central api generation scripts.
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Thu Aug 9 23:10:52 UTC 2018
On Thu, Aug 9, 2018 at 7:48 PM, Chad Versace <chadversary at chromium.org> wrote:
> On Wed 08 Aug 2018, Bas Nieuwenhuizen wrote:
>> This became kind of messy as python imports cannot really look up
>> parent/sibling directories. I saw some scripts use sys.path but
>> that became even more messy due to import locations.
>>
>> I also move the selections of the dispatch table out of the
>> generation script because it is not easily shared, and generating
>> it did not really win anything anyway.
>> ---
>> src/intel/Android.vulkan.mk | 9 +
>> src/intel/Makefile.vulkan.am | 25 +-
>> src/intel/vulkan/anv_device.c | 46 ++
>> src/intel/vulkan/anv_entrypoints_gen.py | 537 +-----------------------
>> src/intel/vulkan/anv_extensions.py | 68 +--
>> src/intel/vulkan/anv_extensions_gen.py | 177 +-------
>> src/intel/vulkan/meson.build | 15 +-
>> src/vulkan/util/vk_extensions.py | 5 +-
>> 8 files changed, 98 insertions(+), 784 deletions(-)
>>
>> diff --git a/src/intel/Android.vulkan.mk b/src/intel/Android.vulkan.mk
>
>
>> $(intermediates)/vulkan/anv_entrypoints.h: $(intermediates)/vulkan/dummy.c
>> + PYTHONPATH=$(MESA_TOP)/src/vulkan/util \
>> $(VK_ENTRYPOINTS_SCRIPT) \
>> --outdir $(dir $@) \
>> --xml $(MESA_TOP)/src/vulkan/registry/vk.xml
>
> Yes, modifying PYTHONPATH is messy, but it seems to me that it's the the
> least-messy way.
>
> I'm no expert on build systems, but I think it's wrong to clobber
> PYTHONPATH. Instead, you should prepend the dir to PYTHONPATH.
>
> For example, on my machine, PYTHONPATH is already set:
>
> $ echo $PYTHONPATH
> /usr/local/buildtools/current/sitecustomize
>
> So, this is more correct...
>
> $(intermediates)/vulkan/anv_entrypoints.h: $(intermediates)/vulkan/dummy.c
> PYTHONPATH="$(MESA_TOP)/src/vulkan/util:$${PYTHONPATH}"
> $(VK_ENTRYPOINTS_SCRIPT) \
> --outdir $(dir $@) \
> --xml $(MESA_TOP)/src/vulkan/registry/vk.xml
>
> but runs the risk of accidentally inserting $PWD into PYTHONPATH, because
> Python interprets each empty path in PYTHONPATH as equivalent to $PWD.
>
> So... perhaps it is better to modify sys.path instead of PYTHONPATH. It is
> definitely safer.
I'm also not sure I can modify the PYTHONPATH in meson.
The main problem with sys.path is that the {radv,anv}_extensions use
quite a bit of helpers in vk_extensions.py, and the generators use
quite a bit of {radv,anv}_extensions. However, with sys.path we change
the path in the main function after changing the arguments (note a
relative path is relative from the working directory, not the source
directory). This means we have to use late imports too and likely not
a global scope, which makes things messy. I'll look a bit more into
it.
Do people prefer the shared directory or using sys.path?
More information about the mesa-dev
mailing list