2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2010 Johan Dahlin
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 from giscanner.annotationparser import AnnotationParser
24 from giscanner.scannermain import (get_preprocessor_option_group,
25 create_source_scanner,
28 def annotation_main(args):
29 parser = optparse.OptionParser('%prog [options] sources')
31 group = optparse.OptionGroup(parser, "Tool modes, one is required")
32 group.add_option("-e", "--extract",
33 action="store_true", dest="extract",
34 help="Extract annotations from the input files")
35 parser.add_option_group(group)
37 group = get_preprocessor_option_group(parser)
38 group.add_option("-L", "--library-path",
39 action="append", dest="library_paths", default=[],
40 help="directories to search for libraries")
41 group.add_option("", "--pkg",
42 action="append", dest="packages", default=[],
43 help="pkg-config packages to get cflags from")
44 parser.add_option_group(group)
46 options, args = parser.parse_args(args)
48 if not options.extract:
49 raise SystemExit("ERROR: Nothing to do")
52 process_packages(options, options.packages)
54 ss = create_source_scanner(options, args)
57 ap = AnnotationParser()
58 blocks = ap.parse(ss.get_comments())
59 for block in blocks.values():
60 print block.to_gtk_doc()
62 elif options.validate:
63 transformer = create_transformer(namespace, options)
64 transformer.parse(ss.get_symbols())
66 shlibs = create_binary(transformer, options, args)
68 ap = AnnotationParser()
69 blocks = ap.parse(ss.get_comments())
71 main = MainTransformer(transformer, blocks)
74 final = IntrospectablePass(transformer)