Skip to content

Commit

Permalink
Implement get_missing_libraries() for mach-o
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiggins committed Oct 3, 2015
1 parent 25a8d01 commit e282cdf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rpathology/macho.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from machotools.detect import is_macho
from machotools.macho_rewriter import rewriter_factory

LOADER_PATH = '@loader_path'


def build_rpath(root, lib_dir, file_path):
""" Constructs an RPATH for a file.
"""
parts = ['@loader_path']
parts = [LOADER_PATH]
moves = [op.relpath(root, op.dirname(file_path)),
op.relpath(lib_dir, root)]
parts.extend([m for m in moves if m != '.'])
Expand All @@ -23,7 +25,15 @@ def is_executable(path):
def get_missing_libraries(path):
""" Return a list of missing libraries for a given executable.
"""
raise NotImplementedError
missing = []
loader_path = op.dirname(path)
rewriter = rewriter_factory(path)
for dependency in rewriter.dependencies:
if dependency.startswith(LOADER_PATH):
dependency = loader_path + dependency[len(LOADER_PATH):]
if not op.exists(dependency):
missing.append(op.basename(dependency))
return missing


def get_rpaths(path):
Expand Down

0 comments on commit e282cdf

Please sign in to comment.