]>
Commit | Line | Data |
---|---|---|
1 | import optparse | |
2 | import sys | |
3 | import os | |
4 | import string | |
5 | import types | |
6 | ||
7 | import c_tools | |
8 | import doxymlparser | |
9 | import sip_tools | |
10 | import swig_tools | |
11 | ||
12 | from common import * | |
13 | ||
14 | if __name__ == "__main__": | |
15 | option_dict = { | |
16 | "output_dir" : ("output", "Directory to output bindings to"), | |
17 | "sip" : (True, "Produce SIP bindings"), | |
18 | "swig" : (True, "Produce SWIG bindings."), | |
19 | "c" : (True, "Produce C wrappers."), | |
20 | ||
21 | } | |
22 | ||
23 | parser = optparse.OptionParser(usage="usage: %prog <doxyml files to parse>\n" , version="%prog 1.0") | |
24 | ||
25 | for opt in option_dict: | |
26 | default = option_dict[opt][0] | |
27 | ||
28 | action = "store" | |
29 | if type(default) == types.BooleanType: | |
30 | action = "store_true" | |
31 | parser.add_option("--" + opt, default=default, action=action, dest=opt, help=option_dict[opt][1]) | |
32 | ||
33 | options, arguments = parser.parse_args() | |
34 | ||
35 | if len(arguments) < 1: | |
36 | parser.print_usage() | |
37 | sys.exit(1) | |
38 | ||
39 | doxyparse = doxymlparser.DoxyMLParser() | |
40 | for arg in arguments: | |
41 | doxyparse.parse(arg) | |
42 | ||
43 | if options.sip: | |
44 | builder = sip_tools.SIPBuilder(doxyparse, options.output_dir) | |
45 | builder.make_bindings() | |
46 | ||
47 | if options.swig: | |
48 | builder = swig_tools.SWIGBuilder(doxyparse, options.output_dir) | |
49 | builder.make_bindings() | |
50 | ||
51 | if options.c: | |
52 | builder = c_tools.CBuilder(doxyparse, options.output_dir) | |
53 | builder.make_bindings() |