Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 2 | # |
Karl Schultz | c85a02f | 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 | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 7 | # |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | # of this software and/or associated documentation files (the "Materials"), to |
| 10 | # deal in the Materials without restriction, including without limitation the |
| 11 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 12 | # sell copies of the Materials, and to permit persons to whom the Materials |
| 13 | # are furnished to do so, subject to the following conditions: |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 14 | # |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 15 | # The above copyright notice(s) and this permission notice shall be included |
| 16 | # in all copies or substantial portions of the Materials. |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 17 | # |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 18 | # The Materials are Confidential Information as defined by the Khronos |
| 19 | # Membership Agreement until designated non-confidential by Khronos, at which |
| 20 | # point this condition clause shall be removed. |
| 21 | # |
| 22 | # THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 25 | # |
| 26 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 27 | # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 28 | # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 29 | # USE OR OTHER DEALINGS IN THE MATERIALS |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 30 | # |
Courtney Goeltzenleuchter | 96cd795 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 31 | # Author: Chia-I Wu <olv@lunarg.com> |
| 32 | # Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 33 | # Author: Jon Ashburn <jon@lunarg.com> |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 34 | |
| 35 | import sys |
| 36 | |
Courtney Goeltzenleuchter | a8c0628 | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 37 | import vulkan |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 38 | |
Chia-I Wu | f7d6d3c | 2015-01-05 12:55:13 +0800 | [diff] [blame] | 39 | def generate_get_proc_addr_check(name): |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 40 | return " if (!%s || %s[0] != 'v' || %s[1] != 'k')\n" \ |
| 41 | " return NULL;" % ((name,) * 3) |
Chia-I Wu | f7d6d3c | 2015-01-05 12:55:13 +0800 | [diff] [blame] | 42 | |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 43 | class Subcommand(object): |
| 44 | def __init__(self, argv): |
| 45 | self.argv = argv |
Courtney Goeltzenleuchter | a8c0628 | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 46 | self.headers = vulkan.headers |
| 47 | self.protos = vulkan.protos |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 48 | |
| 49 | def run(self): |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 50 | print(self.generate()) |
| 51 | |
| 52 | def generate(self): |
| 53 | copyright = self.generate_copyright() |
| 54 | header = self.generate_header() |
| 55 | body = self.generate_body() |
| 56 | footer = self.generate_footer() |
| 57 | |
| 58 | contents = [] |
| 59 | if copyright: |
| 60 | contents.append(copyright) |
| 61 | if header: |
| 62 | contents.append(header) |
| 63 | if body: |
| 64 | contents.append(body) |
| 65 | if footer: |
| 66 | contents.append(footer) |
| 67 | |
| 68 | return "\n\n".join(contents) |
| 69 | |
| 70 | def generate_copyright(self): |
| 71 | return """/* THIS FILE IS GENERATED. DO NOT EDIT. */ |
| 72 | |
| 73 | /* |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 74 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 75 | * Copyright (c) 2015-2016 Valve Corporation |
| 76 | * Copyright (c) 2015-2016 LunarG, Inc. |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 77 | * |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 78 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 79 | * of this software and/or associated documentation files (the "Materials"), to |
| 80 | * deal in the Materials without restriction, including without limitation the |
| 81 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 82 | * sell copies of the Materials, and to permit persons to whom the Materials are |
| 83 | * furnished to do so, subject to the following conditions: |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 84 | * |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 85 | * The above copyright notice(s) and this permission notice shall be included in |
| 86 | * all copies or substantial portions of the Materials. |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 87 | * |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 88 | * The Materials are Confidential Information as defined by the Khronos |
| 89 | * Membership Agreement until designated non-confidential by Khronos, at which |
| 90 | * point this condition clause shall be removed. |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 91 | * |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 92 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 93 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 94 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 95 | * |
| 96 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 97 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 98 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 99 | * USE OR OTHER DEALINGS IN THE MATERIALS. |
Courtney Goeltzenleuchter | 96cd795 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 100 | * |
| 101 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 102 | */""" |
| 103 | |
| 104 | def generate_header(self): |
Chia-I Wu | 6ae460f | 2014-09-13 13:36:06 +0800 | [diff] [blame] | 105 | return "\n".join(["#include <" + h + ">" for h in self.headers]) |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 106 | |
| 107 | def generate_body(self): |
| 108 | pass |
| 109 | |
| 110 | def generate_footer(self): |
| 111 | pass |
| 112 | |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 113 | class DispatchTableOpsSubcommand(Subcommand): |
| 114 | def run(self): |
| 115 | if len(self.argv) != 1: |
| 116 | print("DispatchTableOpsSubcommand: <prefix> unspecified") |
| 117 | return |
| 118 | |
| 119 | self.prefix = self.argv[0] |
Michael Lentine | 9268944 | 2015-09-09 12:39:13 -0700 | [diff] [blame] | 120 | super(DispatchTableOpsSubcommand, self).run() |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 121 | |
| 122 | def generate_header(self): |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 123 | return "\n".join(["#include <vulkan/vulkan.h>", |
| 124 | "#include <vulkan/vk_layer.h>", |
Jon Ashburn | aef6588 | 2015-05-04 09:16:41 -0600 | [diff] [blame] | 125 | "#include <string.h>"]) |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 126 | |
Jon Ashburn | 4f2575f | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 127 | def _generate_init_dispatch(self, type): |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 128 | stmts = [] |
Jon Ashburn | d956400 | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 129 | func = [] |
| 130 | if type == "device": |
Jon Ashburn | 4f2575f | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 131 | # GPA has to be first one and uses wrapped object |
Courtney Goeltzenleuchter | f83cd4a | 2015-06-26 15:05:29 -0600 | [diff] [blame] | 132 | stmts.append("memset(table, 0, sizeof(*table));") |
Jon Ashburn | 4f2575f | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 133 | stmts.append("table->GetDeviceProcAddr =(PFN_vkGetDeviceProcAddr) gpa(device,\"vkGetDeviceProcAddr\");") |
Jon Ashburn | d956400 | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 134 | for proto in self.protos: |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 135 | if proto.name == "CreateInstance" or proto.name == "EnumerateInstanceExtensionProperties" or proto.name == "EnumerateInstanceLayerProperties" or proto.params[0].ty == "VkInstance" or proto.params[0].ty == "VkPhysicalDevice": |
Jon Ashburn | 2666e2f | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 136 | continue |
Jon Ashburn | 83334db | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 137 | if proto.name != "GetDeviceProcAddr" and 'KHR' not in proto.name: |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 138 | stmts.append("table->%s = (PFN_vk%s) gpa(device, \"vk%s\");" % |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 139 | (proto.name, proto.name, proto.name)) |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 140 | func.append("static inline void %s_init_device_dispatch_table(VkDevice device," |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 141 | % self.prefix) |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 142 | func.append("%s VkLayerDispatchTable *table," |
| 143 | % (" " * len(self.prefix))) |
| 144 | func.append("%s PFN_vkGetDeviceProcAddr gpa)" |
Jon Ashburn | d956400 | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 145 | % (" " * len(self.prefix))) |
| 146 | else: |
Jon Ashburn | 4f2575f | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 147 | stmts.append("table->GetInstanceProcAddr =(PFN_vkGetInstanceProcAddr) gpa(instance,\"vkGetInstanceProcAddr\");") |
Jon Ashburn | d956400 | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 148 | for proto in self.protos: |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 149 | if proto.params[0].ty != "VkInstance" and proto.params[0].ty != "VkPhysicalDevice": |
Jon Ashburn | d956400 | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 150 | continue |
Courtney Goeltzenleuchter | be63799 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 151 | if proto.name == "CreateDevice": |
| 152 | continue |
Jon Ashburn | 83334db | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 153 | if proto.name != "GetInstanceProcAddr" and 'KHR' not in proto.name: |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 154 | stmts.append("table->%s = (PFN_vk%s) gpa(instance, \"vk%s\");" % |
Jon Ashburn | d956400 | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 155 | (proto.name, proto.name, proto.name)) |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 156 | func.append("static inline void %s_init_instance_dispatch_table(" % self.prefix) |
| 157 | func.append("%s VkInstance instance," % (" " * len(self.prefix))) |
| 158 | func.append("%s VkLayerInstanceDispatchTable *table," % (" " * len(self.prefix))) |
| 159 | func.append("%s PFN_vkGetInstanceProcAddr gpa)" % (" " * len(self.prefix))) |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 160 | func.append("{") |
| 161 | func.append(" %s" % "\n ".join(stmts)) |
| 162 | func.append("}") |
| 163 | |
| 164 | return "\n".join(func) |
| 165 | |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 166 | def generate_body(self): |
Jon Ashburn | 4f2575f | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 167 | body = [self._generate_init_dispatch("device"), |
| 168 | self._generate_init_dispatch("instance")] |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 169 | |
| 170 | return "\n\n".join(body) |
| 171 | |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 172 | class WinDefFileSubcommand(Subcommand): |
| 173 | def run(self): |
| 174 | library_exports = { |
| 175 | "all": [], |
| 176 | "icd": [ |
Jon Ashburn | 89a1c46 | 2016-01-07 09:46:26 -0700 | [diff] [blame] | 177 | "vk_icdGetInstanceProcAddr", |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 178 | ], |
| 179 | "layer": [ |
Jon Ashburn | 88049b1 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 180 | "vkGetInstanceProcAddr", |
| 181 | "vkGetDeviceProcAddr", |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 182 | "vkEnumerateInstanceLayerProperties", |
| 183 | "vkEnumerateInstanceExtensionProperties" |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 184 | ], |
Mark Lobodzinski | 2e87e61 | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 185 | "layer_multi": [ |
Jon Ashburn | 88049b1 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 186 | "multi2GetInstanceProcAddr", |
| 187 | "multi1GetDeviceProcAddr" |
| 188 | ] |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | if len(self.argv) != 2 or self.argv[1] not in library_exports: |
| 192 | print("WinDefFileSubcommand: <library-name> {%s}" % |
| 193 | "|".join(library_exports.keys())) |
| 194 | return |
| 195 | |
| 196 | self.library = self.argv[0] |
Mark Lobodzinski | 2e87e61 | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 197 | if self.library == "VkLayer_multi": |
| 198 | self.exports = library_exports["layer_multi"] |
Jon Ashburn | 88049b1 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 199 | else: |
| 200 | self.exports = library_exports[self.argv[1]] |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 201 | |
| 202 | super().run() |
| 203 | |
| 204 | def generate_copyright(self): |
| 205 | return """; THIS FILE IS GENERATED. DO NOT EDIT. |
| 206 | |
| 207 | ;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 208 | ; Vulkan |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 209 | ; |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 210 | ; Copyright (c) 2015-2016 The Khronos Group Inc. |
| 211 | ; Copyright (c) 2015-2016 Valve Corporation |
| 212 | ; Copyright (c) 2015-2016 LunarG, Inc. |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 213 | ; |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 214 | ; Permission is hereby granted, free of charge, to any person obtaining a copy |
| 215 | ; of this software and/or associated documentation files (the "Materials"), to |
| 216 | ; deal in the Materials without restriction, including without limitation the |
| 217 | ; rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 218 | ; sell copies of the Materials, and to permit persons to whom the Materials are |
| 219 | ; furnished to do so, subject to the following conditions: |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 220 | ; |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 221 | ; The above copyright notice(s) and this permission notice shall be included in |
| 222 | ; all copies or substantial portions of the Materials. |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 223 | ; |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 224 | ; The Materials are Confidential Information as defined by the Khronos |
| 225 | ; Membership Agreement until designated non-confidential by Khronos, at which |
| 226 | ; point this condition clause shall be removed. |
| 227 | ; |
| 228 | ; THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 229 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Karl Schultz | c85a02f | 2016-02-02 19:32:33 -0700 | [diff] [blame^] | 230 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 231 | ; |
| 232 | ; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 233 | ; DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 234 | ; OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 235 | ; USE OR OTHER DEALINGS IN THE MATERIALS. |
Courtney Goeltzenleuchter | cf8ff4f | 2015-12-16 14:57:27 -0700 | [diff] [blame] | 236 | ; |
| 237 | ; Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 238 | ;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;""" |
| 239 | |
| 240 | def generate_header(self): |
| 241 | return "; The following is required on Windows, for exporting symbols from the DLL" |
| 242 | |
| 243 | def generate_body(self): |
| 244 | body = [] |
| 245 | |
| 246 | body.append("LIBRARY " + self.library) |
| 247 | body.append("EXPORTS") |
| 248 | |
Jon Ashburn | 88049b1 | 2015-08-13 14:15:07 -0700 | [diff] [blame] | 249 | for proto in self.exports: |
Mark Lobodzinski | 2e87e61 | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 250 | if self.library != "VkLayerSwapchain" or proto != "vkEnumerateInstanceExtensionProperties" and proto != "vkEnumerateInstanceLayerProperties": |
Ian Elliott | 329da01 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 251 | body.append( proto) |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 252 | |
| 253 | return "\n".join(body) |
| 254 | |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 255 | def main(): |
| 256 | subcommands = { |
Chia-I Wu | 28b8d8c | 2015-01-04 10:19:50 +0800 | [diff] [blame] | 257 | "dispatch-table-ops": DispatchTableOpsSubcommand, |
Chia-I Wu | d98a23c | 2015-04-11 10:56:50 +0800 | [diff] [blame] | 258 | "win-def-file": WinDefFileSubcommand, |
Chia-I Wu | fb2559d | 2014-08-01 11:19:52 +0800 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | if len(sys.argv) < 2 or sys.argv[1] not in subcommands: |
| 262 | print("Usage: %s <subcommand> [options]" % sys.argv[0]) |
| 263 | print |
| 264 | print("Available sucommands are: %s" % " ".join(subcommands)) |
| 265 | exit(1) |
| 266 | |
| 267 | subcmd = subcommands[sys.argv[1]](sys.argv[2:]) |
| 268 | subcmd.run() |
| 269 | |
| 270 | if __name__ == "__main__": |
| 271 | main() |