# -*- Mode: Python -*-
# GObject-Introspection - a framework for introspecting GObject libraries
# Copyright (C) 2008 Johan Dahlin
+# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
import os
import sys
-# This only works on unix systems
-currentdir = os.path.dirname(os.path.abspath(sys.argv[0]))
-basedir = os.path.abspath(os.path.join(currentdir, '..'))
-if (os.path.exists(os.path.join(basedir, '.svn')) or
- os.path.exists(os.path.join(basedir, '.git'))):
- path = basedir
-else:
- libdir = 'lib'
- for p in sys.path:
- if 'lib64' in p:
- libdir = 'lib64'
- break
-
- path = os.path.join(basedir, libdir, 'python%d.%d' % sys.version_info[:2],
- 'site-packages')
-sys.path.insert(0, path)
-
from giscanner.annotationparser import AnnotationParser, InvalidAnnotationError
from giscanner.ast import Include
from giscanner.cachestore import CacheStore
help="Inject additional components into GIR XML")
parser.add_option("", "--xpath-assertions",
action="store", dest="xpath_assertions",
- help="Use given file to create assertions on GIR content")
+ help="Use given file to create assertions on GIR content")
parser.add_option("", "--c-include",
action="append", dest="c_includes", default=[],
help="headers which should be included in C programs")
xpath_assert(root, assertion)
f.close()
return 0
-
+
def process_options(output, allowed_flags):
for option in output.split():
for flag in allowed_flags:
if not option.startswith(flag):
continue
yield option
- break
+ break
def process_packages(parser, options, packages):
args = ['pkg-config', '--cflags']
sys.exit(1)
# Some pkg-config files on Windows have options we don't understand,
# so we explicitly filter to only the ones we need.
- options_whitelist = ['-I', '-D', '-U', '-l', '-L']
+ options_whitelist = ['-I', '-D', '-U', '-l', '-L']
filtered_output = list(process_options(output, options_whitelist))
pkg_options, unused = parser.parse_args(filtered_output)
options.cpp_includes.extend(pkg_options.cpp_includes)
sys.exit(1)
filtered_output = list(process_options(output, options_whitelist))
pkg_options, unused = parser.parse_args(filtered_output)
- options.library_paths.extend(pkg_options.library_paths)
+ options.library_paths.extend(pkg_options.library_paths)
-def main(args):
+def scanner_main(args):
parser = _get_option_parser()
(options, args) = parser.parse_args(args)
# Make absolute, because we do comparisons inside scannerparser.c
# against the absolute path that cpp will give us
filenames.append(os.path.abspath(arg))
-
- cachestore = CacheStore()
+
+ cachestore = CacheStore()
transformer = Transformer(cachestore,
options.namespace_name,
options.namespace_version)
raise ValueError("Invalid include path %r" % (include, ))
include_obj = Include.from_string(include)
transformer.register_include(include_obj)
-
+
packages = set(options.packages)
packages.update(transformer.get_pkgconfig_packages())
process_packages(parser, options, packages)
binary = IntrospectionBinary(args)
else:
binary = compile_introspection_binary(options,
- glibtransformer.get_get_type_functions())
+ glibtransformer.get_get_type_functions())
glibtransformer.set_introspection_binary(binary)
print data
return 0
-
-sys.exit(main(sys.argv))
--- /dev/null
+#!/usr/bin/env python
+# -*- Mode: Python -*-
+# GObject-Introspection - a framework for introspecting GObject libraries
+# Copyright (C) 2008 Johan Dahlin
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+
+import os
+import sys
+
+# This only works on unix systems
+currentdir = os.path.dirname(os.path.abspath(sys.argv[0]))
+basedir = os.path.abspath(os.path.join(currentdir, '..'))
+if (os.path.exists(os.path.join(basedir, '.svn')) or
+ os.path.exists(os.path.join(basedir, '.git'))):
+ path = basedir
+else:
+ # This is a private directory, we don't want to pollute the global
+ # namespace.
+ path = os.path.join('@libdir@', 'gobject-introspection')
+sys.path.insert(0, path)
+
+from giscanner.scannermain import scanner_main
+
+sys.exit(scanner_main(sys.argv))