diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | giscanner/Makefile.am | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | giscanner/scannermain.py (renamed from tools/g-ir-scanner) | 40 | ||||
-rwxr-xr-x | tools/g-ir-scanner.in | 39 |
4 files changed, 53 insertions, 30 deletions
diff --git a/configure.ac b/configure.ac index 5487e750..8b57e17f 100644 --- a/configure.ac +++ b/configure.ac @@ -212,4 +212,5 @@ examples/Makefile docs/Makefile docs/reference/Makefile gobject-introspection-1.0.pc]) +AC_CONFIG_FILES([tools/g-ir-scanner], [chmod a+x tools/g-ir-scanner]) AC_OUTPUT diff --git a/giscanner/Makefile.am b/giscanner/Makefile.am index bc2977f6..1ecd9778 100644 --- a/giscanner/Makefile.am +++ b/giscanner/Makefile.am @@ -31,7 +31,7 @@ libgiscanner_la_CFLAGS = $(GOBJECT_CFLAGS) GCOVSOURCES = $(libgiscanner_la_SOURCES) # Python module -pkgpyexecdir = $(pyexecdir)/giscanner +pkgpyexecdir = $(pkglibdir)/giscanner pkgpyexec_LTLIBRARIES = _giscanner.la pkgpyexec_PYTHON = \ __init__.py \ @@ -47,6 +47,7 @@ pkgpyexec_PYTHON = \ libtoolimporter.py \ minixpath.py \ odict.py \ + scannermain.py \ sourcescanner.py \ transformer.py \ utils.py \ diff --git a/tools/g-ir-scanner b/giscanner/scannermain.py index 4b5b924c..f7ac884a 100755..100644 --- a/tools/g-ir-scanner +++ b/giscanner/scannermain.py @@ -2,6 +2,7 @@ # -*- 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 @@ -24,23 +25,6 @@ import optparse 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 @@ -110,7 +94,7 @@ def _get_option_parser(): 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") @@ -194,14 +178,14 @@ def validate(assertions, path): 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'] @@ -214,7 +198,7 @@ def process_packages(parser, options, packages): 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) @@ -229,9 +213,9 @@ def process_packages(parser, options, packages): 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) @@ -285,8 +269,8 @@ def main(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) @@ -301,7 +285,7 @@ def main(args): 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) @@ -333,7 +317,7 @@ def main(args): binary = IntrospectionBinary(args) else: binary = compile_introspection_binary(options, - glibtransformer.get_get_type_functions()) + glibtransformer.get_get_type_functions()) glibtransformer.set_introspection_binary(binary) @@ -356,5 +340,3 @@ def main(args): print data return 0 - -sys.exit(main(sys.argv)) diff --git a/tools/g-ir-scanner.in b/tools/g-ir-scanner.in new file mode 100755 index 00000000..b7197c9e --- /dev/null +++ b/tools/g-ir-scanner.in @@ -0,0 +1,39 @@ +#!/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)) |