Skip to content

Commit

Permalink
Make SYSTEM_LIBRARY_BLACKLIST less brittle
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Oct 11, 2018
1 parent de3dd3f commit b247c41
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions admin/osx/macdeployqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from glob import glob
from distutils.version import LooseVersion

bundle_dir = sys.argv[1]
qmake_path = sys.argv[2]

def QueryQMake(attrib):
return subprocess.check_output([qmake_path, '-query', attrib]).rstrip('\n')

Expand All @@ -48,10 +51,9 @@ def QueryQMake(attrib):
QT_PLUGINS_SEARCH_PATH=[
]

# Package these libraries even if they are (also) a system lib
SYSTEM_LIBRARY_BLACKLIST=[
'libcrypto.dylib',
'libssl.dylib'
# Package libraries from these paths even if they are also a system library
SYSTEM_LIBRARY_BLACKLIST = [
QueryQMake('QT_INSTALL_LIBS')
]

class Error(Exception):
Expand Down Expand Up @@ -83,8 +85,6 @@ class CouldNotFindFrameworkError(Error):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

bundle_dir = sys.argv[1]
qmake_path = sys.argv[2]

bundle_name = os.path.basename(bundle_dir).split('.')[0]

Expand Down Expand Up @@ -203,7 +203,7 @@ def FixFramework(path):
FixLibraryInstallPath(library, new_path)

def FixLibrary(path):
if path in fixed_libraries or FindSystemLibrary(os.path.basename(path)) is not None:
if path in fixed_libraries or FindSystemLibrary(path) is not None:
return
else:
fixed_libraries.append(path)
Expand Down Expand Up @@ -308,18 +308,20 @@ def FixInstallPath(library_path, library, new_path):
args = ['install_name_tool', '-change', library_path, new_path, library]
commands.append(args)

def FindSystemLibrary(library_name):
if library_name in SYSTEM_LIBRARY_BLACKLIST:
return None
def FindSystemLibrary(library_path):
for item in SYSTEM_LIBRARY_BLACKLIST:
if library_path.startswith(item):
return None

library_name = os.path.basename(library_path)
for path in ['/lib', '/usr/lib']:
full_path = os.path.join(path, library_name)
if os.path.exists(full_path):
return full_path
return None

def FixLibraryInstallPath(library_path, library):
system_library = FindSystemLibrary(os.path.basename(library_path))
system_library = FindSystemLibrary(library_path)
if system_library is None:
new_path = '@executable_path/../MacOS/%s' % os.path.basename(library_path)
FixInstallPath(library_path, library, new_path)
Expand Down

0 comments on commit b247c41

Please sign in to comment.