| #!/usr/bin/env python3 |
| # |
| # XGL |
| # |
| # Copyright (C) 2015 LunarG, Inc. |
| # |
| # Permission is hereby granted, free of charge, to any person obtaining a |
| # copy of this software and associated documentation files (the "Software"), |
| # to deal in the Software without restriction, including without limitation |
| # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| # and/or sell copies of the Software, and to permit persons to whom the |
| # Software is furnished to do so, subject to the following conditions: |
| # |
| # The above copyright notice and this permission notice shall be included |
| # in all copies or substantial portions of the Software. |
| # |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| # DEALINGS IN THE SOFTWARE. |
| # |
| # Authors: |
| # Chia-I Wu <olv@lunarg.com> |
| # Ian Elliott <ian@lunarg.com> |
| |
| import sys |
| |
| import xgl |
| |
| def generate_get_proc_addr_check(name): |
| return " if (!%s || %s[0] != 'x' || %s[1] != 'g' || %s[2] != 'l')\n" \ |
| " return NULL;" % ((name,) * 4) |
| |
| class Subcommand(object): |
| def __init__(self, argv): |
| self.argv = argv |
| self.headers = xgl.headers |
| self.protos = xgl.protos |
| |
| def run(self): |
| print(self.generate()) |
| |
| def generate(self): |
| copyright = self.generate_copyright() |
| header = self.generate_header() |
| body = self.generate_body() |
| footer = self.generate_footer() |
| |
| contents = [] |
| if copyright: |
| contents.append(copyright) |
| if header: |
| contents.append(header) |
| if body: |
| contents.append(body) |
| if footer: |
| contents.append(footer) |
| |
| return "\n\n".join(contents) |
| |
| def generate_copyright(self): |
| return """; THIS FILE IS GENERATED. DO NOT EDIT. |
| |
| ;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| ; XGL |
| ; |
| ; Copyright (C) 2015 LunarG, Inc. |
| ; |
| ; Permission is hereby granted, free of charge, to any person obtaining a |
| ; copy of this software and associated documentation files (the "Software"), |
| ; to deal in the Software without restriction, including without limitation |
| ; the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| ; and/or sell copies of the Software, and to permit persons to whom the |
| ; Software is furnished to do so, subject to the following conditions: |
| ; |
| ; The above copyright notice and this permission notice shall be included |
| ; in all copies or substantial portions of the Software. |
| ; |
| ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| ; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| ; DEALINGS IN THE SOFTWARE. |
| ;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| |
| ; The following is required on Windows, for exporting symbols from the DLL""" |
| |
| def generate_header(self): |
| pass |
| |
| def generate_body(self): |
| return "LIBRARY XGLLayer" + sys.argv[1] |
| |
| def generate_footer(self): |
| return "EXPORTS\n xglGetProcAddr\n xglEnumerateLayers" |
| |
| def main(): |
| |
| if len(sys.argv) < 1: |
| print("Usage: %s <file>" % sys.argv[0]) |
| exit(1) |
| |
| subcmd = Subcommand(sys.argv[1:]) |
| subcmd.run() |
| |
| if __name__ == "__main__": |
| main() |