3
0
Fork 0

different rpath for components, libraries and binaries

small_fixes
reg_ 13 years ago
parent 0080827b41
commit f228490138

@ -5,15 +5,41 @@ import os
import subprocess import subprocess
import re import re
MODE_COMPONENT = 1
MODE_BINARY = 2
MODE_LIBRARY = 3
MODES = {'c': MODE_COMPONENT,
'b': MODE_BINARY,
'l': MODE_LIBRARY}
is_library = False
is_component = False
is_binary = False
def usage(): def usage():
print(u"Usage: %s component/path.dylib" % sys.argv[0]) print(u"Usage: %s MODE component/path.dylib" % sys.argv[0])
print(u" MODE is c: component or b: binary or l: library")
if len(sys.argv) < 2: if len(sys.argv) < 3:
usage() usage()
exit(0) exit(0)
component = sys.argv[1] component = sys.argv[1]
mode = MODES.get(sys.argv[2].lower())
if not mode:
usage()
exit(1)
# mode switchers
if mode == MODE_COMPONENT:
is_component = True
elif mode == MODE_LIBRARY:
is_library = True
else:
is_binary = True
if not os.path.exists(component): if not os.path.exists(component):
print(u"Unable to access component at: %s" % component) print(u"Unable to access component at: %s" % component)
@ -21,20 +47,18 @@ if not os.path.exists(component):
# we'll also allow binaries to be fixed. # we'll also allow binaries to be fixed.
# #
# if not component.endswith('.dylib'): if (is_library or is_component) and not component.endswith('.dylib'):
# print(u"%s is not a dylib component" % component) print(u"%s is not a dylib component" % component)
# exit(1) exit(1)
print("Fixing %s..." % component) print("Fixing %s..." % component)
basename = os.path.basename(component) basename = os.path.basename(component)
try: try:
name, ext = basename.rsplit('.', 1) name, ext = basename.rsplit('.', 1)
is_library = True
except ValueError: except ValueError:
name = basename name = basename
ext = '' ext = ''
is_library = False
libname = u'lib%s%s.0.dylib' % (name[0].upper(), name[1:]) libname = u'lib%s%s.0.dylib' % (name[0].upper(), name[1:])
# run otool to get a list of deps. # run otool to get a list of deps.
@ -64,10 +88,13 @@ for line in otool_out.split('\n'):
match = re.match(r'lib([a-z\_\-\d]+)([\.?\d]*)\.dylib', _basename) match = re.match(r'lib([a-z\_\-\d]+)([\.?\d]*)\.dylib', _basename)
if match: if match:
print("match: %s" % match.groups()[0]) print("match: %s" % match.groups()[0])
if is_library: if is_component:
newpath = u'@executable_path/../Frameworks/lib%s.dylib' % match.groups()[0] newpath = u'@executable_path/../Frameworks/lib%s.dylib' % match.groups()[0]
else: elif is_binary:
newpath = u'@executable_path/../../Frameworks/lib%s.dylib' % match.groups()[0] newpath = u'@executable_path/../../Frameworks/lib%s.dylib' % match.groups()[0]
else:
newpath = u'@loader_path/lib%s.dylib' % match.groups()[0]
print('install_name_tool -change %s %s %s' % (path, newpath, component)) print('install_name_tool -change %s %s %s' % (path, newpath, component))
os.system('install_name_tool -change %s %s %s' % (path, newpath, component)) os.system('install_name_tool -change %s %s %s' % (path, newpath, component))
continue continue

Loading…
Cancel
Save