blob: 9d66caec72ecef4cdcb147fc2d55e34f4f1a658f [file] [log] [blame]
Ian Elliott2d4ab1e2015-01-13 17:52:38 -07001#!/usr/bin/env python3
2#
3# XGL
4#
5# Copyright (C) 2015 LunarG, Inc.
6#
7# Permission is hereby granted, free of charge, to any person obtaining a
8# copy of this software and associated documentation files (the "Software"),
9# to deal in the Software without restriction, including without limitation
10# the rights to use, copy, modify, merge, publish, distribute, sublicense,
11# and/or sell copies of the Software, and to permit persons to whom the
12# Software is furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be included
15# in all copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23# DEALINGS IN THE SOFTWARE.
24#
25# Authors:
26# Chia-I Wu <olv@lunarg.com>
27# Ian Elliott <ian@lunarg.com>
28
29import sys
30
31import xgl
32
33def generate_get_proc_addr_check(name):
34 return " if (!%s || %s[0] != 'x' || %s[1] != 'g' || %s[2] != 'l')\n" \
35 " return NULL;" % ((name,) * 4)
36
37class Subcommand(object):
38 def __init__(self, argv):
39 self.argv = argv
40 self.headers = xgl.headers
41 self.protos = xgl.protos
42
43 def run(self):
44 print(self.generate())
45
46 def generate(self):
47 copyright = self.generate_copyright()
48 header = self.generate_header()
49 body = self.generate_body()
50 footer = self.generate_footer()
51
52 contents = []
53 if copyright:
54 contents.append(copyright)
55 if header:
56 contents.append(header)
57 if body:
58 contents.append(body)
59 if footer:
60 contents.append(footer)
61
62 return "\n\n".join(contents)
63
64 def generate_copyright(self):
65 return """; THIS FILE IS GENERATED. DO NOT EDIT.
66
67;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
68; XGL
69;
70; Copyright (C) 2015 LunarG, Inc.
71;
72; Permission is hereby granted, free of charge, to any person obtaining a
73; copy of this software and associated documentation files (the "Software"),
74; to deal in the Software without restriction, including without limitation
75; the rights to use, copy, modify, merge, publish, distribute, sublicense,
76; and/or sell copies of the Software, and to permit persons to whom the
77; Software is furnished to do so, subject to the following conditions:
78;
79; The above copyright notice and this permission notice shall be included
80; in all copies or substantial portions of the Software.
81;
82; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
83; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
84; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
85; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
86; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
87; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
88; DEALINGS IN THE SOFTWARE.
89;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
90
91; The following is required on Windows, for exporting symbols from the DLL"""
92
93 def generate_header(self):
94 pass
95
96 def generate_body(self):
Ian Elliott92c80d72015-02-04 15:19:32 -070097 return "LIBRARY XGLLayer" + sys.argv[1]
Ian Elliott2d4ab1e2015-01-13 17:52:38 -070098
99 def generate_footer(self):
100 return "EXPORTS\n xglGetProcAddr\n xglEnumerateLayers"
101
102def main():
103
104 if len(sys.argv) < 1:
105 print("Usage: %s <file>" % sys.argv[0])
106 exit(1)
107
108 subcmd = Subcommand(sys.argv[1:])
109 subcmd.run()
110
111if __name__ == "__main__":
112 main()