• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- coding: utf-8 -*-
2
3#-------------------------------------------------------------------------
4# Vulkan CTS
5# ----------
6#
7# Copyright (c) 2015 Google Inc.
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13#      http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20#
21#-------------------------------------------------------------------------
22
23import os
24import sys
25import re
26
27sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
28
29from build.common import DEQP_DIR
30from khr_util.format import writeInlFile
31
32VULKAN_H	= [
33	os.path.join(os.path.dirname(__file__), "..", "..", "vulkan-docs", "src", "include", "vk_video", "vulkan_video_codecs_common.h"),
34	os.path.join(os.path.dirname(__file__), "..", "..", "vulkan-docs", "src", "include", "vk_video", "vulkan_video_codec_h264std.h"),
35	os.path.join(os.path.dirname(__file__), "..", "..", "vulkan-docs", "src", "include", "vk_video", "vulkan_video_codec_h264std_encode.h"),
36	os.path.join(os.path.dirname(__file__), "..", "..", "vulkan-docs", "src", "include", "vk_video", "vulkan_video_codec_h265std.h"),
37	os.path.join(os.path.dirname(__file__), "..", "..", "vulkan-docs", "src", "include", "vk_video", "vulkan_video_codec_h264std_decode.h"),
38	os.path.join(os.path.dirname(__file__), "..", "..", "vulkan-docs", "src", "include", "vk_video", "vulkan_video_codec_h265std_decode.h"),
39	os.path.join(os.path.dirname(__file__), "..", "..", "vulkan-docs", "src", "include", "vulkan", "vulkan_core.h"),
40	]
41
42INL_HEADER = """\
43/* WARNING: This is auto-generated file. Do not modify, since changes will
44 * be lost! Modify the generating script instead.
45 */\
46"""
47
48TYPE_SUBSTITUTIONS		= [
49	("uint8_t",		"deUint8"),
50	("uint16_t",	"deUint16"),
51	("uint32_t",	"deUint32"),
52	("uint64_t",	"deUint64"),
53	("int8_t",		"deInt8"),
54	("int16_t",		"deInt16"),
55	("int32_t",		"deInt32"),
56	("int64_t",		"deInt64"),
57	("bool32_t",	"deUint32"),
58	("size_t",		"deUintptr"),
59]
60
61def readFile (filename):
62	with open(filename, 'rt') as f:
63		return f.read()
64
65def writeVulkanCHeader (src, filename):
66	def gen ():
67		dst = re.sub(r'(#include "[^\s,\n}]+")', '', src)
68
69		for old_type, new_type in TYPE_SUBSTITUTIONS:
70			dst = dst.replace(old_type, new_type)
71		yield dst
72	writeInlFile(filename, INL_HEADER, gen())
73
74if __name__ == "__main__":
75
76	# script requires output path to which .inl files will be written
77	if len(sys.argv) == 1:
78		sys.exit("Error - output path wasn't specified in argument")
79	outputPath = str(sys.argv[1])
80
81	src = ""
82	for file in VULKAN_H:
83		src += readFile(file)
84
85	writeVulkanCHeader				(src, os.path.join(outputPath, "vkVulkan_c.inl"))
86