2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2008-2011 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
24 from .mallardwriter import MallardWriter
25 from .transformer import Transformer
28 parser = optparse.OptionParser('%prog [options] GIR-file')
30 parser.add_option("-o", "--output",
31 action="store", dest="output",
32 help="Directory to write output to")
33 parser.add_option("-l", "--language",
34 action="store", dest="language",
36 help="Output language")
38 options, args = parser.parse_args(args)
39 if not options.output:
40 raise SystemExit("missing output parameter")
41 if not os.path.isdir(options.output):
42 raise SystemExit("wrong output parameter: %s", options.output)
45 raise SystemExit("Need an input GIR filename")
47 if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ:
48 top_srcdir = os.environ['UNINSTALLED_INTROSPECTION_SRCDIR']
49 top_builddir = os.environ['UNINSTALLED_INTROSPECTION_BUILDDIR']
50 extra_include_dirs = [os.path.join(top_srcdir, 'gir'), top_builddir]
52 extra_include_dirs = []
53 transformer = Transformer.parse_from_gir(args[1], extra_include_dirs)
55 writer = MallardWriter(transformer, options.language)
56 writer.write(options.output)