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 25 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 = os.path.join(os.path.dirname(__file__), "src", "vulkan.h.in") 33VULKAN_DIR = os.path.join(os.path.dirname(__file__), "..", "framework", "vulkan") 34 35INL_HEADER = """\ 36/* WARNING: This is auto-generated file. Do not modify, since changes will 37 * be lost! Modify the generating script instead. 38 */\ 39""" 40 41TYPE_SUBSTITUTIONS = [ 42 ("uint8_t", "deUint8"), 43 ("uint16_t", "deUint16"), 44 ("uint32_t", "deUint32"), 45 ("uint64_t", "deUint64"), 46 ("int8_t", "deInt8"), 47 ("int16_t", "deInt16"), 48 ("int32_t", "deInt32"), 49 ("int64_t", "deInt64"), 50 ("bool32_t", "deUint32"), 51 ("size_t", "deUintptr"), 52] 53 54def readFile (filename): 55 with open(filename, 'rb') as f: 56 return f.read() 57 58def writeVulkanCHeader (src, filename): 59 def gen (): 60 dst = src.replace('#include "vk_platform.h"','') 61 62 for old_type, new_type in TYPE_SUBSTITUTIONS: 63 dst = dst.replace(old_type, new_type) 64 yield dst 65 writeInlFile(filename, INL_HEADER, gen()) 66 67if __name__ == "__main__": 68 src = readFile(VULKAN_H) 69 writeVulkanCHeader (src, os.path.join(VULKAN_DIR, "vkVulkan_c.inl")) 70