Make it easier to link against libunicorn on macOS (#1195)

Adding @rpath to the install name to make it possible to link against
the library without modifying it with install_name_tool. Copying both
the versioned and unversioned dylibs simplifies linking.
This commit is contained in:
Saagar Jha
2020-02-11 22:16:34 -08:00
committed by GitHub
parent 901efc4bd4
commit d69ebfa55c
2 changed files with 7 additions and 2 deletions

View File

@ -60,6 +60,7 @@ else:
if SYSTEM == 'darwin':
LIBRARY_FILE = "libunicorn.dylib"
MAC_LIBRARY_FILE = "libunicorn*.dylib"
STATIC_LIBRARY_FILE = None
elif SYSTEM in ('win32', 'cygwin'):
LIBRARY_FILE = "unicorn.dll"
@ -171,7 +172,11 @@ def build_libraries():
subprocess.call(cmd, env=new_env)
shutil.copy(LIBRARY_FILE, LIBS_DIR)
if SYSTEM == 'darwin':
for file in glob.glob(MAC_LIBRARY_FILE):
shutil.copy(file, LIBS_DIR, follow_symlinks=False)
else:
shutil.copy(LIBRARY_FILE, LIBS_DIR)
try:
# static library may fail to build on windows if user doesn't have visual studio installed. this is fine.
if STATIC_LIBRARY_FILE is not None: