[Mesa-dev] [PATCH 3/4] anv: Use central api generation scripts.
Chad Versace
chadversary at chromium.org
Thu Aug 9 17:48:20 UTC 2018
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.
More information about the mesa-dev
mailing list