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