Skip to content

Instantly share code, notes, and snippets.

@define-private-public
Created March 15, 2020 18:52
Show Gist options
  • Save define-private-public/ca73b68d76fc2e2e3c5d184af5037b71 to your computer and use it in GitHub Desktop.
Save define-private-public/ca73b68d76fc2e2e3c5d184af5037b71 to your computer and use it in GitHub Desktop.
Fix ids and rpaths for some OS X dylibs
# If on OS, we need to fix some issues with the dylibs
# namely the rpath stuff & dylib IDs, it's a bit of a pain
if is_osx:
cmds = []
# First fix Ids
dylibs = ['ogg', 'vorbis', 'vorbisenc', 'vorbisfile', 'sndfile']
for lib in dylibs:
lib_filename = 'lib%s.dylib' % (lib)
cmd = 'install_name_tool -id "@rpath/{0}" lib/{0}'.format(lib_filename)
cmds.append(cmd)
# Now fix the references
changes = [
# (old, new, [targets])
('ogg.0', 'ogg', ['FLAC', 'sndfile', 'vorbis', 'vorbisenc', 'vorbisfile']),
('vorbis.0.4.8', 'vorbis', ['sndfile', 'vorbisenc', 'vorbisfile']),
('vorbisfile.3.3.7', 'vorbisfile', ['sndfile']),
('vorbisenc.2.0.11', 'vorbisenc', ['sndfile']),
]
for (o, n, targets) in changes:
for t in targets:
change_cmd = 'install_name_tool -change "@rpath/lib{0}.dylib" "@rpath/lib{1}.dylib" lib/lib{2}.dylib'.format(o,
n, t)
cmds.append(change_cmd)
# Run the commands
[os.system(x) for x in cmds]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment