[Mesa-dev] [PATCH] vulkan: provide vk.xml as argument to the python generator

Eric Engestrom eric.engestrom at imgtec.com
Wed Mar 1 11:18:14 UTC 2017


On Tuesday, 2017-02-28 18:56:23 +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Do not hardcode the file in the python script, but pass it via the build
> system(s). The former is the only one that should know about the file
> locaiton/tree structure.

s/former/latter/; s/locaiton/location/

Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

> 
> Cc: Dylan Baker <dylan at pnwbakers.com>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/vulkan/Android.mk              | 2 +-
>  src/vulkan/Makefile.am             | 2 +-
>  src/vulkan/util/gen_enum_to_str.py | 5 ++---
>  3 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/src/vulkan/Android.mk b/src/vulkan/Android.mk
> index 0825c1ac10..9f71d8ff8f 100644
> --- a/src/vulkan/Android.mk
> +++ b/src/vulkan/Android.mk
> @@ -45,7 +45,7 @@ vulkan_api_xml = $(MESA_TOP)/src/vulkan/registry/vk.xml
>  $(LOCAL_GENERATED_SOURCES): $(MESA_TOP)/src/vulkan/util/gen_enum_to_str.py $(vulkan_api_xml)
>  	@echo "target Generated: $(PRIVATE_MODULE) <= $(notdir $(@))"
>  	@mkdir -p $(dir $@)
> -	$(hide) $(MESA_PYTHON2) $(MESA_TOP)/src/vulkan/util/gen_enum_to_str.py --outdir $(intermediates)/util
> +	$(hide) $(MESA_PYTHON2) $(MESA_TOP)/src/vulkan/util/gen_enum_to_str.py --xml $(vulkan_api_xml) --outdir $(intermediates)/util
>  
>  LOCAL_EXPORT_C_INCLUDE_DIRS := \
>          $(intermediates)
> diff --git a/src/vulkan/Makefile.am b/src/vulkan/Makefile.am
> index e28a81c8cf..f7aca8e937 100644
> --- a/src/vulkan/Makefile.am
> +++ b/src/vulkan/Makefile.am
> @@ -16,7 +16,7 @@ BUILT_SOURCES = \
>  
>  util/vk_enum_to_str.c util/vk_enum_to_str.h: util/gen_enum_to_str.py $(vulkan_api_xml)
>  	$(MKDIR_GEN)
> -	$(PYTHON_GEN) $(srcdir)/util/gen_enum_to_str.py --outdir $(top_builddir)/src/vulkan/util
> +	$(PYTHON_GEN) $(srcdir)/util/gen_enum_to_str.py --xml $(vulkan_api_xml) --outdir $(top_builddir)/src/vulkan/util
>  
>  libvulkan_util_la_SOURCES = $(VULKAN_UTIL_GENERATED_FILES)
>  
> diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
> index 8c11569b6a..fb31addf94 100644
> --- a/src/vulkan/util/gen_enum_to_str.py
> +++ b/src/vulkan/util/gen_enum_to_str.py
> @@ -29,8 +29,6 @@ import xml.etree.cElementTree as et
>  
>  from mako.template import Template
>  
> -VK_XML = os.path.join(os.path.dirname(__file__), '..', 'registry', 'vk.xml')
> -
>  COPYRIGHT = textwrap.dedent(u"""\
>      * Copyright © 2017 Intel Corporation
>      *
> @@ -160,13 +158,14 @@ def xml_parser(filename):
>  
>  def main():
>      parser = argparse.ArgumentParser()
> +    parser.add_argument('--xml', help='Vulkan API XML file.', required=True)
>      parser.add_argument('--outdir',
>                          help='Directory to put the generated files in',
>                          required=True)
>  
>      args = parser.parse_args()
>  
> -    enums = xml_parser(VK_XML)
> +    enums = xml_parser(args.xml)
>      for template, file_ in [(C_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.c')),
>                              (H_TEMPLATE, os.path.join(args.outdir, 'vk_enum_to_str.h'))]:
>          with open(file_, 'wb') as f:
> -- 
> 2.11.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list