package: Convert dylib handling from .la to otool

Currently, the darwin shlibs detection is done by parsing the .la file
dependency fields. This is very old code and is incomplete in some
cases so convert to using otool -l and otool -L to correctly load
the rpath and dependency information.

(From OE-Core rev: e27573b6c3562662e4b2f5d8543eb7d150c3bc92)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2014-08-02 09:48:31 +01:00
parent c70203998b
commit 53eaed5c15
1 changed files with 21 additions and 31 deletions

View File

@ -1350,6 +1350,7 @@ SHLIBSWORKDIR = "${PKGDESTWORK}/${MLPREFIX}shlibs2"
python package_do_shlibs() { python package_do_shlibs() {
import re, pipes import re, pipes
import subprocess as sub
exclude_shlibs = d.getVar('EXCLUDE_FROM_SHLIBS', 0) exclude_shlibs = d.getVar('EXCLUDE_FROM_SHLIBS', 0)
if exclude_shlibs: if exclude_shlibs:
@ -1459,38 +1460,27 @@ python package_do_shlibs() {
prov = (combo, ldir, pkgver) prov = (combo, ldir, pkgver)
sonames.append(prov) sonames.append(prov)
if file.endswith('.dylib') or file.endswith('.so'): if file.endswith('.dylib') or file.endswith('.so'):
lafile = file.replace(os.path.join(pkgdest, pkg), d.getVar('PKGD', True)) rpath = []
# Drop suffix p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file],stdout=sub.PIPE,stderr=sub.PIPE)
lafile = lafile.rsplit(".",1)[0] err, out = p.communicate()
lapath = os.path.dirname(lafile) # If returned succesfully, process stderr for results
lafile = os.path.basename(lafile) if p.returncode == 0:
# Find all combinations for l in err.split("\n"):
combos = get_combinations(lafile) l = l.strip()
for combo in combos: if l.startswith('path '):
if os.path.exists(lapath + '/' + combo + '.la'): rpath.append(l.split()[1])
break
lafile = lapath + '/' + combo + '.la'
#bb.note("Foo2: %s" % lafile) p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-L', file],stdout=sub.PIPE,stderr=sub.PIPE)
#bb.note("Foo %s" % file) err, out = p.communicate()
if os.path.exists(lafile): # If returned succesfully, process stderr for results
fd = open(lafile, 'r') if p.returncode == 0:
lines = fd.readlines() for l in err.split("\n"):
fd.close() l = l.strip()
for l in lines: if not l or l.endswith(":"):
m = re.match("\s*dependency_libs=\s*'(.*)'", l) continue
if m: name = os.path.basename(l.split()[0]).rsplit(".", 1)[0]
deps = m.group(1).split(" ") if name and name not in needed[pkg]:
for dep in deps: needed[pkg].append((name, file, []))
#bb.note("Trying %s for %s" % (dep, pkg))
name = None
if dep.endswith(".la"):
name = os.path.basename(dep).replace(".la", "")
elif dep.startswith("-l"):
name = dep.replace("-l", "lib")
if name and name not in needed[pkg]:
needed[pkg].append((name, lafile, []))
#bb.note("Adding %s for %s" % (name, pkg))
if d.getVar('PACKAGE_SNAP_LIB_SYMLINKS', True) == "1": if d.getVar('PACKAGE_SNAP_LIB_SYMLINKS', True) == "1":
snap_symlinks = True snap_symlinks = True