diff options
-rw-r--r-- | giscanner/libtoolimporter.py | 73 | ||||
-rw-r--r-- | giscanner/meson.build | 1 | ||||
-rw-r--r-- | giscanner/sourcescanner.py | 17 | ||||
-rw-r--r-- | giscanner/utils.py | 16 |
4 files changed, 9 insertions, 98 deletions
diff --git a/giscanner/libtoolimporter.py b/giscanner/libtoolimporter.py deleted file mode 100644 index c8501035..00000000 --- a/giscanner/libtoolimporter.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- Mode: Python -*- -# GObject-Introspection - a framework for introspecting GObject libraries -# Copyright (C) 2008 Johan Dahlin -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# - -import imp -import os -import sys - -from .utils import extract_libtool - - -class LibtoolImporter(object): - - def __init__(self, name, path): - self.name = name - self.path = path - - @classmethod - def find_module(cls, name, packagepath=None): - modparts = name.split('.') - filename = modparts.pop() + '.la' - - # Given some.package.module 'path' is where subpackages of some.package - # should be looked for. See if we can find a ".libs/module.la" relative - # to those directories and failing that look for file - # "some/package/.libs/module.la" relative to sys.path - if len(modparts) > 0: - modprefix = os.path.join(*modparts) - modprefix = os.path.join(modprefix, '.libs') - else: - modprefix = '.libs' - - for path in sys.path: - full = os.path.join(path, modprefix, filename) - if os.path.exists(full): - return cls(name, full) - - def load_module(self, name): - realpath = extract_libtool(self.path) - - # The first item of the suffix tuple (which can be, depending on platform, - # one or more valid filename extensions used to name c extension modules) - # is ignored by imp.load_module(). Thus, there is no use in pretending it - # is important and we set it to an empty string. - suffix = ('', 'rb', imp.C_EXTENSION) - - mod = imp.load_module(name, open(realpath), realpath, suffix) - mod.__loader__ = self - return mod - - @classmethod - def __enter__(cls): - sys.meta_path.append(cls) - - @classmethod - def __exit__(cls, exc_type, exc_val, exc_tb): - sys.meta_path.remove(cls) diff --git a/giscanner/meson.build b/giscanner/meson.build index a3b06f37..098b7b6b 100644 --- a/giscanner/meson.build +++ b/giscanner/meson.build @@ -13,7 +13,6 @@ giscanner_files = [ 'girparser.py', 'girwriter.py', 'gdumpparser.py', - 'libtoolimporter.py', 'maintransformer.py', 'mdextensions.py', 'message.py', diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py index e50f40aa..09f90441 100644 --- a/giscanner/sourcescanner.py +++ b/giscanner/sourcescanner.py @@ -21,19 +21,18 @@ import os import tempfile -from .libtoolimporter import LibtoolImporter from .message import Position from .ccompiler import CCompiler from .utils import have_debug_flag, dll_dirs -with LibtoolImporter(None, None): - dlldirs = dll_dirs() - dlldirs.add_dll_dirs(['gio-2.0']) - if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ: - from _giscanner import SourceScanner as CSourceScanner - else: - from giscanner._giscanner import SourceScanner as CSourceScanner - dlldirs.cleanup_dll_dirs() + +dlldirs = dll_dirs() +dlldirs.add_dll_dirs(['gio-2.0']) +if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ: + from _giscanner import SourceScanner as CSourceScanner +else: + from giscanner._giscanner import SourceScanner as CSourceScanner +dlldirs.cleanup_dll_dirs() HEADER_EXTS = ['.h', '.hpp', '.hxx'] SOURCE_EXTS = ['.c', '.cpp', '.cc', '.cxx'] diff --git a/giscanner/utils.py b/giscanner/utils.py index d9938fc7..3983eb79 100644 --- a/giscanner/utils.py +++ b/giscanner/utils.py @@ -121,24 +121,10 @@ def extract_libtool_shlib(la_file): if libdir is None: return dlbasename return libdir + '/' + dlbasename - # From the comments in extract_libtool(), older libtools had - # a path rather than the raw dlname + # Older libtools had a path rather than the raw dlname return os.path.basename(dlname) -def extract_libtool(la_file): - dlname = _extract_dlname_field(la_file) - if dlname is None: - raise ValueError("%s has no dlname. Not a shared library?" % la_file) - libname = os.path.join(os.path.dirname(la_file), - '.libs', dlname) - # FIXME: This hackish, but I'm not sure how to do this - # in a way which is compatible with both libtool 2.2 - # and pre-2.2. Johan 2008-10-21 - libname = libname.replace('.libs/.libs', '.libs').replace('.libs\\.libs', '.libs') - return libname - - # Returns arguments for invoking libtool, if applicable, otherwise None def get_libtool_command(options): libtool_infection = not options.nolibtool |