Ticket #62391: patch-fix-rpath-gir-typelib.diff

File patch-fix-rpath-gir-typelib.diff, 2.1 KB (added by VinDuv, 4 years ago)
  • giscanner/shlibs.py

    old new  
    1919#
    2020
    2121import os
    22 import sys
    2322import platform
    2423import re
    2524import subprocess
     
    104103        output = subprocess.check_output(args)
    105104        if isinstance(output, bytes):
    106105            output = output.decode("utf-8", "replace")
    107 
    108106        shlibs = resolve_from_ldd_output(libraries, output)
    109         return list(map(sanitize_shlib_path, shlibs))
    110 
     107        libdir = ''
     108        # for Darwin purposes, assume libraries get installed into
     109        # the first non-build library path
     110        if platform.system() == 'Darwin':
     111            for lpath in options.library_paths:
     112                if lpath.startswith('/') and not lpath.startswith(os.getcwd()):
     113                    libdir = lpath
     114                    break
     115            if libdir == '':
     116                # no way to resolve @rpath and the like, since we can't
     117                # make a reasonable assumpion of the install libdir
     118                libdir = '@MP_LIB@'
     119            else:
     120                libdir = libdir + '/'
     121        outlibs = []
     122        for lib in shlibs:
     123            outlibs.append(sanitize_shlib_path(lib,libdir))
     124        return list (outlibs)
    111125
    112 def sanitize_shlib_path(lib):
     126def sanitize_shlib_path(lib,libdir):
    113127    # Use absolute paths on OS X to conform to how libraries are usually
    114128    # referenced on OS X systems, and file names everywhere else.
    115129    # In case we get relative paths on macOS (like @rpath) then we fall
    116130    # back to the basename as well:
    117131    # https://gitlab.gnome.org/GNOME/gobject-introspection/issues/222
    118     if sys.platform == "darwin":
     132    if platform.system() == 'Darwin':
    119133        if not os.path.isabs(lib):
    120             return os.path.basename(lib)
    121         return lib
     134            lib = os.path.basename(lib)
     135            # prepend the libdir
     136            lib = libdir + lib
    122137    else:
    123         return os.path.basename(lib)
    124 
     138        lib = os.path.basename(lib)
     139    return lib
    125140
    126141def resolve_from_ldd_output(libraries, output):
    127142    patterns = {}