summaryrefslogtreecommitdiffstats
path: root/build/osx
diff options
context:
space:
mode:
authorRJ Skerry-Ryan <rryan@mixxx.org>2018-09-26 21:51:26 -0700
committerRJ Skerry-Ryan <rryan@mixxx.org>2018-09-29 12:14:18 -0700
commitb06bd41d6caf7e50690ff328b03942d04a7d3e20 (patch)
tree410ce9e67c4981943e81c290f73c298f5ba4dc17 /build/osx
parentc4f48f315cad9c3acfb413c2ada365a2dab011dc (diff)
Add a helper to extract the rpaths from a binary.
Diffstat (limited to 'build/osx')
-rw-r--r--build/osx/otool.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/build/osx/otool.py b/build/osx/otool.py
index c350c79f7c..3e7ed66ac3 100644
--- a/build/osx/otool.py
+++ b/build/osx/otool.py
@@ -1,5 +1,6 @@
import os
+import subprocess
#This page is REALLY USEFUL: http://www.cocoadev.com/index.pl?ApplicationLinking
#question: why do dylibs embed their install name in themselves? that would seem to imply the system keeps a cache of all the "install names", but that's not what the docs seem to say.
@@ -195,3 +196,21 @@ def change_ref(binary, orig, new):
#
#keywords: @executable_path, @loader_path, @rpath. TODO: document these.
+
+def rpaths(binary):
+ """Returns a list of the LC_RPATH load commands in the provided binary."""
+ print("otool(%s)" % binary)
+ p = subprocess.Popen(['otool', '-l', binary],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+
+ lines = stdout.split('\n')
+ rpaths = []
+ for i, line in enumerate(lines):
+ if line.strip() == 'cmd LC_RPATH':
+ path_line = lines[i + 2].strip().replace('path ', '')
+ path_line = path_line[:path_line.rindex('(') - 1]
+ rpaths.append(path_line)
+ return rpaths