Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 2 | # |
Karl Schultz | 8e42f40 | 2016-02-02 19:32:33 -0700 | [diff] [blame] | 3 | # Copyright (c) 2015-2016 The Khronos Group Inc. |
| 4 | # Copyright (c) 2015-2016 Valve Corporation |
| 5 | # Copyright (c) 2015-2016 LunarG, Inc. |
| 6 | # Copyright (c) 2015-2016 Google Inc. |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 7 | # |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 11 | # |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 13 | # |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
Chia-I Wu | 701f3f6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 19 | # |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 20 | # Author: Chia-I Wu <olv@lunarg.com> |
| 21 | # Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 22 | # Author: Jon Ashburn <jon@lunarg.com> |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 23 | # Author: Gwan-gyeong Mun <kk.moon@samsung.com> |
Mark Lobodzinski | cef655d | 2016-10-27 08:33:09 -0600 | [diff] [blame] | 24 | # Author: Mark Lobodzinski <mark@lunarg.com> |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 25 | |
| 26 | import sys |
| 27 | |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 28 | import vulkan |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 29 | |
Chia-I Wu | 6cdaedb | 2015-01-05 12:55:13 +0800 | [diff] [blame] | 30 | def generate_get_proc_addr_check(name): |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 31 | return " if (!%s || %s[0] != 'v' || %s[1] != 'k')\n" \ |
| 32 | " return NULL;" % ((name,) * 3) |
Chia-I Wu | 6cdaedb | 2015-01-05 12:55:13 +0800 | [diff] [blame] | 33 | |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 34 | class Subcommand(object): |
| 35 | def __init__(self, argv): |
| 36 | self.argv = argv |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 37 | self.headers = vulkan.headers |
| 38 | self.protos = vulkan.protos |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 39 | self.outfile = None |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 40 | |
| 41 | def run(self): |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 42 | if self.outfile: |
| 43 | with open(self.outfile, "w") as outfile: |
| 44 | outfile.write(self.generate()) |
| 45 | else: |
| 46 | print(self.generate()) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 47 | |
| 48 | def generate(self): |
| 49 | copyright = self.generate_copyright() |
| 50 | header = self.generate_header() |
| 51 | body = self.generate_body() |
| 52 | footer = self.generate_footer() |
| 53 | |
| 54 | contents = [] |
| 55 | if copyright: |
| 56 | contents.append(copyright) |
| 57 | if header: |
| 58 | contents.append(header) |
| 59 | if body: |
| 60 | contents.append(body) |
| 61 | if footer: |
| 62 | contents.append(footer) |
| 63 | |
| 64 | return "\n\n".join(contents) |
| 65 | |
| 66 | def generate_copyright(self): |
| 67 | return """/* THIS FILE IS GENERATED. DO NOT EDIT. */ |
| 68 | |
| 69 | /* |
Karl Schultz | 8e42f40 | 2016-02-02 19:32:33 -0700 | [diff] [blame] | 70 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 71 | * Copyright (c) 2015-2016 Valve Corporation |
| 72 | * Copyright (c) 2015-2016 LunarG, Inc. |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 73 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 74 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 75 | * you may not use this file except in compliance with the License. |
| 76 | * You may obtain a copy of the License at |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 77 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 78 | * http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 79 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 80 | * Unless required by applicable law or agreed to in writing, software |
| 81 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 82 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 83 | * See the License for the specific language governing permissions and |
| 84 | * limitations under the License. |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 85 | * |
| 86 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 87 | */""" |
| 88 | |
| 89 | def generate_header(self): |
Chia-I Wu | 6bdf019 | 2014-09-13 13:36:06 +0800 | [diff] [blame] | 90 | return "\n".join(["#include <" + h + ">" for h in self.headers]) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 91 | |
| 92 | def generate_body(self): |
| 93 | pass |
| 94 | |
| 95 | def generate_footer(self): |
| 96 | pass |
| 97 | |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 98 | class DispatchTableOpsSubcommand(Subcommand): |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 99 | def __init__(self, argv): |
| 100 | self.argv = argv |
| 101 | self.headers = vulkan.headers_all |
| 102 | self.protos = vulkan.protos_all |
| 103 | self.outfile = None |
| 104 | |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 105 | def run(self): |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 106 | if len(self.argv) < 1: |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 107 | print("DispatchTableOpsSubcommand: <prefix> unspecified") |
| 108 | return |
| 109 | |
| 110 | self.prefix = self.argv[0] |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 111 | |
| 112 | if len(self.argv) > 2: |
| 113 | print("DispatchTableOpsSubcommand: <prefix> [outfile]") |
| 114 | return |
| 115 | |
| 116 | if len(self.argv) == 2: |
| 117 | self.outfile = self.argv[1] |
| 118 | |
Michael Lentine | 695f2c2 | 2015-09-09 12:39:13 -0700 | [diff] [blame] | 119 | super(DispatchTableOpsSubcommand, self).run() |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 120 | |
| 121 | def generate_header(self): |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 122 | return "\n".join(["#include <vulkan/vulkan.h>", |
| 123 | "#include <vulkan/vk_layer.h>", |
Jon Ashburn | 1dd0a5c | 2015-05-04 09:16:41 -0600 | [diff] [blame] | 124 | "#include <string.h>"]) |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 125 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 126 | def _generate_init_dispatch(self, type): |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 127 | stmts = [] |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 128 | func = [] |
| 129 | if type == "device": |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 130 | # GPA has to be first one and uses wrapped object |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 131 | stmts.append(" memset(table, 0, sizeof(*table));") |
| 132 | stmts.append(" // Core device function pointers") |
| 133 | stmts.append(" table->GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) gpa(device, \"vkGetDeviceProcAddr\");") |
| 134 | |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 135 | for proto in self.protos: |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 136 | if proto.name == "CreateInstance" or proto.name == "EnumerateInstanceExtensionProperties" or \ |
| 137 | proto.name == "EnumerateInstanceLayerProperties" or proto.params[0].ty == "VkInstance" or \ |
| 138 | proto.params[0].ty == "VkPhysicalDevice" or proto.name == "GetDeviceProcAddr": |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 139 | continue |
Mark Lobodzinski | cef655d | 2016-10-27 08:33:09 -0600 | [diff] [blame] | 140 | stmts.append(" table->%s = (PFN_vk%s) gpa(device, \"vk%s\");" % (proto.name, proto.name, proto.name)) |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 141 | func.append("static inline void %s_init_device_dispatch_table(VkDevice device," |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 142 | % self.prefix) |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 143 | func.append("%s VkLayerDispatchTable *table," |
| 144 | % (" " * len(self.prefix))) |
| 145 | func.append("%s PFN_vkGetDeviceProcAddr gpa)" |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 146 | % (" " * len(self.prefix))) |
| 147 | else: |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 148 | stmts.append(" memset(table, 0, sizeof(*table));") |
| 149 | stmts.append(" // Core instance function pointers") |
| 150 | stmts.append(" table->GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) gpa(instance, \"vkGetInstanceProcAddr\");") |
| 151 | |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 152 | for proto in self.protos: |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 153 | if proto.params[0].ty != "VkInstance" and proto.params[0].ty != "VkPhysicalDevice" or \ |
| 154 | proto.name == "CreateDevice" or proto.name == "GetInstanceProcAddr": |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 155 | continue |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 156 | # Protect platform-dependent APIs with #ifdef |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 157 | if 'KHR' in proto.name and 'Win32' in proto.name: |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 158 | stmts.append("#ifdef VK_USE_PLATFORM_WIN32_KHR") |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 159 | if 'KHR' in proto.name and 'Xlib' in proto.name: |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 160 | stmts.append("#ifdef VK_USE_PLATFORM_XLIB_KHR") |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 161 | if 'KHR' in proto.name and 'Xcb' in proto.name: |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 162 | stmts.append("#ifdef VK_USE_PLATFORM_XCB_KHR") |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 163 | if 'KHR' in proto.name and 'Mir' in proto.name: |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 164 | stmts.append("#ifdef VK_USE_PLATFORM_MIR_KHR") |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 165 | if 'KHR' in proto.name and 'Wayland' in proto.name: |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 166 | stmts.append("#ifdef VK_USE_PLATFORM_WAYLAND_KHR") |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 167 | if 'KHR' in proto.name and 'Android' in proto.name: |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 168 | stmts.append("#ifdef VK_USE_PLATFORM_ANDROID_KHR") |
| 169 | # Output dispatch table entry |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 170 | stmts.append(" table->%s = (PFN_vk%s) gpa(instance, \"vk%s\");" % |
| 171 | (proto.name, proto.name, proto.name)) |
Mark Lobodzinski | 817acda | 2016-10-26 08:19:24 -0600 | [diff] [blame] | 172 | # If entry was protected by an #ifdef, close with a #endif |
| 173 | if 'KHR' in proto.name and 'Win32' in proto.name: |
| 174 | stmts.append("#endif // VK_USE_PLATFORM_WIN32_KHR") |
| 175 | if 'KHR' in proto.name and 'Xlib' in proto.name: |
| 176 | stmts.append("#endif // VK_USE_PLATFORM_XLIB_KHR") |
| 177 | if 'KHR' in proto.name and 'Xcb' in proto.name: |
| 178 | stmts.append("#endif // VK_USE_PLATFORM_XCB_KHR") |
| 179 | if 'KHR' in proto.name and 'Mir' in proto.name: |
| 180 | stmts.append("#endif // VK_USE_PLATFORM_MIR_KHR") |
| 181 | if 'KHR' in proto.name and 'Wayland' in proto.name: |
| 182 | stmts.append("#endif // VK_USE_PLATFORM_WAYLAND_KHR") |
| 183 | if 'KHR' in proto.name and 'Android' in proto.name: |
| 184 | stmts.append("#endif // VK_USE_PLATFORM_ANDROID_KHR") |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 185 | func.append("static inline void %s_init_instance_dispatch_table(" % self.prefix) |
| 186 | func.append("%s VkInstance instance," % (" " * len(self.prefix))) |
| 187 | func.append("%s VkLayerInstanceDispatchTable *table," % (" " * len(self.prefix))) |
| 188 | func.append("%s PFN_vkGetInstanceProcAddr gpa)" % (" " * len(self.prefix))) |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 189 | func.append("{") |
Mark Young | aa1aa3a | 2016-07-05 16:41:50 -0600 | [diff] [blame] | 190 | func.append("%s" % "\n".join(stmts)) |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 191 | func.append("}") |
| 192 | |
| 193 | return "\n".join(func) |
| 194 | |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 195 | def generate_body(self): |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 196 | body = [self._generate_init_dispatch("device"), |
| 197 | self._generate_init_dispatch("instance")] |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 198 | |
| 199 | return "\n\n".join(body) |
| 200 | |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 201 | class WinDefFileSubcommand(Subcommand): |
| 202 | def run(self): |
| 203 | library_exports = { |
| 204 | "all": [], |
| 205 | "icd": [ |
Jon Ashburn | f5e9754 | 2016-01-07 09:46:26 -0700 | [diff] [blame] | 206 | "vk_icdGetInstanceProcAddr", |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 207 | ], |
| 208 | "layer": [ |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 209 | "vkGetInstanceProcAddr", |
| 210 | "vkGetDeviceProcAddr", |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 211 | "vkEnumerateInstanceLayerProperties", |
| 212 | "vkEnumerateInstanceExtensionProperties" |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 213 | ], |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 214 | "layer_multi": [ |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 215 | "multi2GetInstanceProcAddr", |
| 216 | "multi1GetDeviceProcAddr" |
| 217 | ] |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 218 | } |
| 219 | |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 220 | if len(self.argv) < 2 or len(self.argv) > 3 or self.argv[1] not in library_exports: |
| 221 | print("WinDefFileSubcommand: <library-name> {%s} [outfile]" % |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 222 | "|".join(library_exports.keys())) |
| 223 | return |
| 224 | |
| 225 | self.library = self.argv[0] |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 226 | if self.library == "VkLayer_multi": |
| 227 | self.exports = library_exports["layer_multi"] |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 228 | else: |
| 229 | self.exports = library_exports[self.argv[1]] |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 230 | |
Jamie Madill | dbda66b | 2016-05-10 07:36:20 -0700 | [diff] [blame] | 231 | if len(self.argv) == 3: |
| 232 | self.outfile = self.argv[2] |
| 233 | |
Jamie Madill | c001885 | 2016-04-04 11:20:24 -0400 | [diff] [blame] | 234 | super(WinDefFileSubcommand, self).run() |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 235 | |
| 236 | def generate_copyright(self): |
| 237 | return """; THIS FILE IS GENERATED. DO NOT EDIT. |
| 238 | |
| 239 | ;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 240 | ; Vulkan |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 241 | ; |
Karl Schultz | 8e42f40 | 2016-02-02 19:32:33 -0700 | [diff] [blame] | 242 | ; Copyright (c) 2015-2016 The Khronos Group Inc. |
| 243 | ; Copyright (c) 2015-2016 Valve Corporation |
| 244 | ; Copyright (c) 2015-2016 LunarG, Inc. |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 245 | ; |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 246 | ; Licensed under the Apache License, Version 2.0 (the "License"); |
| 247 | ; you may not use this file except in compliance with the License. |
| 248 | ; You may obtain a copy of the License at |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 249 | ; |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 250 | ; http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 251 | ; |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 252 | ; Unless required by applicable law or agreed to in writing, software |
| 253 | ; distributed under the License is distributed on an "AS IS" BASIS, |
| 254 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 255 | ; See the License for the specific language governing permissions and |
| 256 | ; limitations under the License. |
Courtney Goeltzenleuchter | bdde0b2 | 2015-12-16 14:57:27 -0700 | [diff] [blame] | 257 | ; |
| 258 | ; Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 259 | ;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;""" |
| 260 | |
| 261 | def generate_header(self): |
| 262 | return "; The following is required on Windows, for exporting symbols from the DLL" |
| 263 | |
| 264 | def generate_body(self): |
| 265 | body = [] |
| 266 | |
| 267 | body.append("LIBRARY " + self.library) |
| 268 | body.append("EXPORTS") |
| 269 | |
Jon Ashburn | 2919a01 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 270 | for proto in self.exports: |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 271 | if self.library != "VkLayerSwapchain" or proto != "vkEnumerateInstanceExtensionProperties" and proto != "vkEnumerateInstanceLayerProperties": |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 272 | body.append( proto) |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 273 | |
| 274 | return "\n".join(body) |
| 275 | |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 276 | def main(): |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 277 | wsi = { |
| 278 | "Win32", |
| 279 | "Android", |
| 280 | "Xcb", |
| 281 | "Xlib", |
| 282 | "Wayland", |
Petros Bantolas | 2b40be7 | 2016-04-15 11:02:59 +0100 | [diff] [blame] | 283 | "Mir", |
Johannes van Waveren | aabf1fd | 2016-07-22 16:10:11 -0500 | [diff] [blame] | 284 | "Display", |
Johannes van Waveren | 05c2536 | 2016-10-30 05:47:59 +0100 | [diff] [blame^] | 285 | "AllPlatforms", |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 286 | } |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 287 | subcommands = { |
Chia-I Wu | 29271d7 | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 288 | "dispatch-table-ops": DispatchTableOpsSubcommand, |
Chia-I Wu | 0a6644b | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 289 | "win-def-file": WinDefFileSubcommand, |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 290 | } |
| 291 | |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 292 | if len(sys.argv) < 3 or sys.argv[1] not in wsi or sys.argv[2] not in subcommands: |
Johannes van Waveren | 05c2536 | 2016-10-30 05:47:59 +0100 | [diff] [blame^] | 293 | print("Usage: %s <wsi> <subcommand> <option>" % sys.argv[0]) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 294 | print |
Johannes van Waveren | 05c2536 | 2016-10-30 05:47:59 +0100 | [diff] [blame^] | 295 | print("Available wsi are: %s" % " ".join(wsi)) |
| 296 | print("Available subcommands are: %s" % " ".join(subcommands)) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 297 | exit(1) |
| 298 | |
Mun, Gwan-gyeong | 82a244a | 2016-02-22 20:23:59 +0900 | [diff] [blame] | 299 | subcmd = subcommands[sys.argv[2]](sys.argv[3:]) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 300 | subcmd.run() |
| 301 | |
| 302 | if __name__ == "__main__": |
| 303 | main() |