1+ # ===========================================================================
2+ #
3+ # Daemon BSD Source Code
4+ # Copyright (c) 2025 Daemon Developers
5+ # All rights reserved.
6+ #
7+ # This file is part of the Daemon BSD Source Code (Daemon Source Code).
8+ #
9+ # Redistribution and use in source and binary forms, with or without
10+ # modification, are permitted provided that the following conditions are met:
11+ # * Redistributions of source code must retain the above copyright
12+ # notice, this list of conditions and the following disclaimer.
13+ # * Redistributions in binary form must reproduce the above copyright
14+ # notice, this list of conditions and the following disclaimer in the
15+ # documentation and/or other materials provided with the distribution.
16+ # * Neither the name of the Daemon developers nor the
17+ # names of its contributors may be used to endorse or promote products
18+ # derived from this software without specific prior written permission.
19+ #
20+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+ # DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
24+ # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+ #
31+ # ===========================================================================
32+
33+ from os import system , remove
34+ from sys import executable
35+ from subprocess import run
36+
37+ headers = [
38+ ( "vulkan_core" , "w" , "" ),
39+ ( "vulkan_beta" , "a" , "VK_ENABLE_BETA_EXTENSIONS" ),
40+ ( "vulkan_win32" , "a" , "VK_USE_PLATFORM_WIN32_KHR" ),
41+ ( "vulkan_wayland" , "a" , "VK_USE_PLATFORM_WAYLAND_KHR" ),
42+ ( "vulkan_xlib" , "a" , "VK_USE_PLATFORM_XLIB_KHR" ),
43+ ( "vulkan_xlib_xrandr" , "a" , "VK_USE_PLATFORM_XLIB_XRANDR_EXT" )
44+ ]
45+
46+ with open ( "FunctionDecls.h" , "w" ) as f :
47+ with open ( "FunctionLoaderInstance.cpp" , "w" ) as f1 :
48+ with open ( "FunctionLoaderDevice.cpp" , "w" ) as f2 :
49+ print ( "" )
50+
51+ vulkanLoaderPath = "../../src/engine/renderer-vulkan/VulkanLoader/"
52+
53+ for header in headers :
54+ if header [2 ]:
55+ run ( [executable , "genvk.py" , "-o" , vulkanLoaderPath + "vulkan/" , "-apiname" , "vulkan" , "-mode" , header [1 ],
56+ "-define" , header [2 ], header [0 ] + ".h" ], check = True )
57+ else :
58+ run ( [executable , "genvk.py" , "-o" , vulkanLoaderPath + "vulkan/" , "-apiname" , "vulkan" , "-mode" , header [1 ],
59+ header [0 ] + ".h" ], check = True )
60+
61+ with open ( "FunctionDecls.h" , "r" ) as inp :
62+ with open ( vulkanLoaderPath + "Vulkan.h" , "w" ) as out :
63+ out .write ( inp .read () )
64+ out .write ( '#endif // VULKAN_LOADER_H' )
65+
66+ with open ( 'VulkanLoadFunctions.cpp' , mode = 'r' , encoding = 'utf-8' , newline = '\n ' ) as inp :
67+ functionLoadStart = inp .read ()
68+
69+ with open ( "FunctionLoaderInstance.cpp" , "r" ) as inp :
70+ with open ( "FunctionLoaderDevice.cpp" , "r" ) as inp2 :
71+ with open ( vulkanLoaderPath + "VulkanLoadFunctions.cpp" , "w" ) as out :
72+ out .write ( functionLoadStart )
73+ out .write ( '\n \n void VulkanLoadInstanceFunctions( VkInstance instance ) {\n ' )
74+ out .write ( inp .read () )
75+ out .write ( '}\n \n ' )
76+ out .write ( 'void VulkanLoadDeviceFunctions( VkDevice device ) {\n ' )
77+ out .write ( inp2 .read () )
78+ out .write ( '}' )
79+
80+ remove ( "FunctionDecls.h" )
81+ remove ( "FunctionLoaderInstance.cpp" )
82+ remove ( "FunctionLoaderDevice.cpp" )
0 commit comments