Depend on SONAME dylib
This commit is contained in:
parent
2056202381
commit
a54dfda14d
@ -32,14 +32,14 @@ BUILD_DIR = os.path.join(UC_DIR, 'build_python')
|
|||||||
VERSION = "2.0.0rc7"
|
VERSION = "2.0.0rc7"
|
||||||
|
|
||||||
if SYSTEM == 'darwin':
|
if SYSTEM == 'darwin':
|
||||||
LIBRARY_FILE = "libunicorn.dylib"
|
LIBRARY_FILE = "libunicorn.2.dylib"
|
||||||
STATIC_LIBRARY_FILE = None
|
STATIC_LIBRARY_FILE = None
|
||||||
elif SYSTEM in ('win32', 'cygwin'):
|
elif SYSTEM in ('win32', 'cygwin'):
|
||||||
LIBRARY_FILE = "unicorn.dll"
|
LIBRARY_FILE = "unicorn.dll"
|
||||||
STATIC_LIBRARY_FILE = "unicorn.lib"
|
STATIC_LIBRARY_FILE = "unicorn.lib"
|
||||||
else:
|
else:
|
||||||
LIBRARY_FILE = "libunicorn.so"
|
LIBRARY_FILE = "libunicorn.so.2"
|
||||||
STATIC_LIBRARY_FILE = None
|
STATIC_LIBRARY_FILE = "libunicorn.a"
|
||||||
|
|
||||||
def clean_bins():
|
def clean_bins():
|
||||||
shutil.rmtree(LIBS_DIR, ignore_errors=True)
|
shutil.rmtree(LIBS_DIR, ignore_errors=True)
|
||||||
@ -140,15 +140,8 @@ def build_libraries():
|
|||||||
subprocess.check_call(["cmake", "--build", ".", "-j" + threads])
|
subprocess.check_call(["cmake", "--build", ".", "-j" + threads])
|
||||||
|
|
||||||
shutil.copy(LIBRARY_FILE, LIBS_DIR)
|
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:
|
|
||||||
shutil.copy(STATIC_LIBRARY_FILE, LIBS_DIR)
|
shutil.copy(STATIC_LIBRARY_FILE, LIBS_DIR)
|
||||||
except FileNotFoundError:
|
|
||||||
print('Warning: Could not build static library file! This build is not appropriate for a binary distribution')
|
|
||||||
# enforce this
|
|
||||||
if 'upload' in sys.argv:
|
|
||||||
sys.exit(1)
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ _python2 = sys.version_info[0] < 3
|
|||||||
if _python2:
|
if _python2:
|
||||||
range = xrange
|
range = xrange
|
||||||
|
|
||||||
_lib = { 'darwin': 'libunicorn.dylib',
|
_lib = { 'darwin': 'libunicorn.2.dylib',
|
||||||
'win32': 'unicorn.dll',
|
'win32': 'unicorn.dll',
|
||||||
'cygwin': 'cygunicorn.dll',
|
'cygwin': 'cygunicorn.dll',
|
||||||
'linux': 'libunicorn.so',
|
'linux': 'libunicorn.so.2',
|
||||||
'linux2': 'libunicorn.so' }
|
'linux2': 'libunicorn.so.2' }
|
||||||
|
|
||||||
|
|
||||||
# Windows DLL in dependency order
|
# Windows DLL in dependency order
|
||||||
@ -57,12 +57,12 @@ def _load_win_support(path):
|
|||||||
if sys.platform in ('win32', 'cygwin'):
|
if sys.platform in ('win32', 'cygwin'):
|
||||||
_load_win_support('')
|
_load_win_support('')
|
||||||
|
|
||||||
def _load_lib(path):
|
def _load_lib(path, lib_name):
|
||||||
try:
|
try:
|
||||||
if sys.platform in ('win32', 'cygwin'):
|
if sys.platform in ('win32', 'cygwin'):
|
||||||
_load_win_support(path)
|
_load_win_support(path)
|
||||||
|
|
||||||
lib_file = os.path.join(path, _lib.get(sys.platform, 'libunicorn.so'))
|
lib_file = os.path.join(path, lib_name)
|
||||||
dll = ctypes.cdll.LoadLibrary(lib_file)
|
dll = ctypes.cdll.LoadLibrary(lib_file)
|
||||||
#print('SUCCESS')
|
#print('SUCCESS')
|
||||||
return dll
|
return dll
|
||||||
@ -93,9 +93,23 @@ _path_list = [os.getenv('LIBUNICORN_PATH', None),
|
|||||||
|
|
||||||
for _path in _path_list:
|
for _path in _path_list:
|
||||||
if _path is None: continue
|
if _path is None: continue
|
||||||
_uc = _load_lib(_path)
|
_uc = _load_lib(_path, _lib.get(sys.platform, "libunicorn.so"))
|
||||||
if _uc is not None: break
|
if _uc is not None:
|
||||||
else:
|
break
|
||||||
|
|
||||||
|
# Try to search old unicorn1 library without SONAME
|
||||||
|
if _uc is None:
|
||||||
|
for _path in _path_list:
|
||||||
|
if _path is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
_uc = _load_lib(_path, "libunicorn.so")
|
||||||
|
if _uc is not None:
|
||||||
|
# In this case, show a warning for users
|
||||||
|
print("Found an old style dynamic library libunicorn.so, consider checking your installation", file=sys.stderr)
|
||||||
|
break
|
||||||
|
|
||||||
|
if _uc is None:
|
||||||
raise ImportError("ERROR: fail to load the dynamic library.")
|
raise ImportError("ERROR: fail to load the dynamic library.")
|
||||||
|
|
||||||
__version__ = "%u.%u.%u" % (uc.UC_VERSION_MAJOR, uc.UC_VERSION_MINOR, uc.UC_VERSION_PATCH)
|
__version__ = "%u.%u.%u" % (uc.UC_VERSION_MAJOR, uc.UC_VERSION_MINOR, uc.UC_VERSION_PATCH)
|
||||||
|
Loading…
Reference in New Issue
Block a user