1
# Copyright 2017 Intel Corporation
3
# Permission is hereby granted, free of charge, to any person obtaining a
4
# copy of this software and associated documentation files (the
5
# "Software"), to deal in the Software without restriction, including
6
# without limitation the rights to use, copy, modify, merge, publish,
7
# distribute, sub license, and/or sell copies of the Software, and to
8
# permit persons to whom the Software is furnished to do so, subject to
9
# the following conditions:
11
# The above copyright notice and this permission notice (including the
12
# next paragraph) shall be included in all copies or substantial portions
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
18
# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
19
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
import xml.etree.ElementTree as et
29
def get_xml_patch_version(xml_file):
30
xml = et.parse(xml_file)
31
for d in xml.findall('.types/type'):
32
if d.get('category', None) != 'define':
35
name = d.find('.name')
36
if name.text != 'VK_HEADER_VERSION':
39
return name.tail.strip()
41
if __name__ == '__main__':
42
parser = argparse.ArgumentParser()
43
parser.add_argument('--api-version', required=True,
44
help='Vulkan API version.')
45
parser.add_argument('--xml', required=False,
46
help='Vulkan registry XML for patch version')
47
parser.add_argument('--lib-path', required=True,
48
help='Path to installed library')
49
parser.add_argument('--out', required=False,
50
help='Output json file.')
51
parser.add_argument('--use-backslash', action='store_true',
52
help='Use backslash (Windows).')
53
args = parser.parse_args()
55
version = args.api_version
57
re.match(r'\d+\.\d+', version)
58
version = version + '.' + get_xml_patch_version(args.xml)
60
re.match(r'\d+\.\d+\.\d+', version)
62
lib_path = args.lib_path
63
if args.use_backslash:
64
lib_path = lib_path.replace('/', '\\')
67
'file_format_version': '1.0.0',
69
'library_path': lib_path,
70
'api_version': version,
77
'separators': (',', ': '),
81
with open(args.out, 'w') as f:
82
json.dump(json_data, f, **json_params)
84
print(json.dumps(json_data, **json_params))