anv: Make anv_icd.py more generic and independent

Instead of depending on anv_extensions.py, fetch the patch version from
the XML ourselves.  This way it can be moved to common code and used by
other ICDs going forward.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8792>
This commit is contained in:
Jason Ekstrand 2021-01-30 09:57:27 -06:00 committed by Marge Bot
parent c7a045ed63
commit 91931c4edd
2 changed files with 46 additions and 15 deletions

View file

@ -20,29 +20,59 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import argparse
import json
import os.path
import argparse
import re
import xml.etree.ElementTree as et
from anv_extensions import MAX_API_VERSION
def get_xml_patch_version(xml_file):
xml = et.parse(xml_file)
for d in xml.findall('.types/type'):
if d.get('category', None) != 'define':
continue
name = d.find('.name')
if name.text != 'VK_HEADER_VERSION':
continue;
return name.tail.strip()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--out', help='Output json file.', required=True)
parser.add_argument('--lib-path', help='Path to libvulkan_intel.so')
parser.add_argument('--api-version', required=True,
help='Vulkan API version.')
parser.add_argument('--xml', required=False,
help='Vulkan registry XML for patch version')
parser.add_argument('--lib-path', required=True,
help='Path to installed library')
parser.add_argument('--out', required=False,
help='Output json file.')
args = parser.parse_args()
path = 'libvulkan_intel.so'
if args.lib_path:
path = os.path.join(args.lib_path, path)
version = args.api_version
if args.xml:
re.match(r'\d+\.\d+', version)
version = version + '.' + get_xml_patch_version(args.xml)
else:
re.match(r'\d+\.\d+\.\d+', version)
json_data = {
'file_format_version': '1.0.0',
'ICD': {
'library_path': path,
'api_version': str(MAX_API_VERSION),
'library_path': args.lib_path,
'api_version': version,
},
}
with open(args.out, 'w') as f:
json.dump(json_data, f, indent=4, sort_keys=True, separators=(',', ': '))
json_params = {
'indent': 4,
'sort_keys': True,
'separators': (',', ': '),
}
if args.out:
with open(args.out, 'w') as f:
json.dump(json_data, f, **json_params)
else:
print(json.dumps(json_data, **json_params))

View file

@ -58,14 +58,15 @@ anv_extensions_h = custom_target(
intel_icd = custom_target(
'intel_icd',
input : 'anv_icd.py',
input : ['anv_icd.py', vk_api_xml],
output : 'intel_icd.@0@.json'.format(host_machine.cpu()),
command : [
prog_python, '@INPUT@',
'--lib-path', join_paths(get_option('prefix'), get_option('libdir')),
prog_python, '@INPUT0@',
'--api-version', '1.2', '--xml', '@INPUT1@',
'--lib-path', join_paths(get_option('prefix'), get_option('libdir'),
'libvulkan_intel.so'),
'--out', '@OUTPUT@',
],
depend_files : anv_extensions_py,
build_by_default : true,
install_dir : with_vulkan_icd_dir,
install : true,