1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
7 # Copyright (c) 2015 Google Inc.
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
13 # http://www.apache.org/licenses/LICENSE-2.0
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.
21 #-------------------------------------------------------------------------
27 sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
29 from build.common import DEQP_DIR
30 from khr_util.format import writeInlFile
32 VULKAN_H = os.path.join(os.path.dirname(__file__), "src", "vulkan_core.h")
33 VULKAN_DIR = os.path.join(os.path.dirname(__file__), "..", "framework", "vulkan")
36 /* WARNING: This is auto-generated file. Do not modify, since changes will
37 * be lost! Modify the generating script instead.
41 TYPE_SUBSTITUTIONS = [
42 ("uint8_t", "deUint8"),
43 ("uint16_t", "deUint16"),
44 ("uint32_t", "deUint32"),
45 ("uint64_t", "deUint64"),
47 ("int16_t", "deInt16"),
48 ("int32_t", "deInt32"),
49 ("int64_t", "deInt64"),
50 ("bool32_t", "deUint32"),
51 ("size_t", "deUintptr"),
54 def readFile (filename):
55 with open(filename, 'rt') as f:
58 def writeVulkanCHeader (src, filename):
60 dst = src.replace('#include "vk_platform.h"','')
62 # Amber is compiled using C++11 but under MSVC __cplusplus macro
63 # is incorrectly recognized and this triggers invalid definition
64 dst = dst.replace('VK_NULL_HANDLE ((void*)0)','VK_NULL_HANDLE 0')
66 for old_type, new_type in TYPE_SUBSTITUTIONS:
67 dst = dst.replace(old_type, new_type)
69 writeInlFile(filename, INL_HEADER, gen())
71 if __name__ == "__main__":
72 src = readFile(VULKAN_H)
73 writeVulkanCHeader (src, os.path.join(VULKAN_DIR, "vkVulkan_c.inl"))