anv: Generate anv_entrypoints header and code in one command
authorDylan Baker <dylan@pnwbakers.com>
Fri, 3 Mar 2017 22:22:44 +0000 (14:22 -0800)
committerDylan Baker <dylan@pnwbakers.com>
Wed, 22 Mar 2017 23:22:00 +0000 (16:22 -0700)
This produces the header and the code in one command, saving the need to
call the same script twice, which parses the same XML file.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
src/intel/Android.vulkan.mk
src/intel/Makefile.vulkan.am
src/intel/vulkan/anv_entrypoints_gen.py

index bcf145554f83667703996bf23dc15c4fe5c139a1..ca2785307bd60f20335efd17d3abb3f0295ed02d 100644 (file)
@@ -179,8 +179,11 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \
 
 LOCAL_GENERATED_SOURCES += $(intermediates)/vulkan/anv_entrypoints.c
 
-$(intermediates)/vulkan/anv_entrypoints.c:
-       $(VK_ENTRYPOINTS_SCRIPT) code $@ --xml $(MESA_TOP)/src/vulkan/registry/vk.xml
+$(intermediates)/vulknan/anv_entrypoints.c:
+       $(VK_ENTRYPOINTS_SCRIPT) \
+               --xml $(MESA_TOP)/src/vulkan/registry/vk.xml \
+               --outdir $(intermediates)/vulkan
+$(intermediates)/vulkan/anv_entrypoints.h: $(intermediates)/vulkan/anv_entrypoints.c
 
 LOCAL_SHARED_LIBRARIES := libdrm_intel
 
index 96962861d8f5aae4ea42fce98dce60b8ecd0200b..da1ee93d91cd7897d33673d80c7614172f93f5f6 100644 (file)
 # out and we'll fail at `make dist'
 vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml
 
-vulkan/anv_entrypoints.h : vulkan/anv_entrypoints_gen.py $(vulkan_api_xml)
-       $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_entrypoints_gen.py header $@ --xml $(vulkan_api_xml)
-
-vulkan/anv_entrypoints.c : vulkan/anv_entrypoints_gen.py $(vulkan_api_xml)
-       $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_entrypoints_gen.py code $@ --xml $(vulkan_api_xml)
+vulkan/anv_entrypoints.c: vulkan/anv_entrypoints_gen.py $(vulkan_api_xml)
+       $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_entrypoints_gen.py \
+               --xml $(vulkan_api_xml) --outdir $(builddir)/vulkan
+vulkan/anv_entrypoints.h: vulkan/anv_entrypoints.c
 
 BUILT_SOURCES += $(VULKAN_GENERATED_FILES)
 CLEANFILES += \
index 47dc44b55ddcc7672e39f4735ce5e6c49d92cc9d..895ec949986a84c081caf6964e20868d5d3a388e 100644 (file)
@@ -354,10 +354,9 @@ def gen_code(entrypoints):
 
 def main():
     parser = argparse.ArgumentParser()
-    parser.add_argument('target', choices=['header', 'code'],
-                        help='Which file to generate.')
-    parser.add_argument('file', help='Where to write the file.')
-    parser.add_argument('--xml', help='Vulkan API XML file.')
+    parser.add_argument('--outdir', help='Where to write the files.',
+                        required=True)
+    parser.add_argument('--xml', help='Vulkan API XML file.', required=True)
     args = parser.parse_args()
 
     doc = et.parse(args.xml)
@@ -375,13 +374,11 @@ def main():
 
     # For outputting entrypoints.h we generate a anv_EntryPoint() prototype
     # per entry point.
-    if args.target == 'header':
-        with open(args.file, 'wb') as f:
-            f.write(TEMPLATE_H.render(entrypoints=entrypoints,
-                                      filename=os.path.basename(__file__)))
-    else:
-        with open(args.file, 'wb') as f:
-            f.write(gen_code(entrypoints))
+    with open(os.path.join(args.outdir, 'anv_entrypoints.h'), 'wb') as f:
+        f.write(TEMPLATE_H.render(entrypoints=entrypoints,
+                                  filename=os.path.basename(__file__)))
+    with open(os.path.join(args.outdir, 'anv_entrypoints.c'), 'wb') as f:
+        f.write(gen_code(entrypoints))
 
 
 if __name__ == '__main__':