mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-01 20:06:53 +01:00
Use cross version of otool if available.
This commit is contained in:
parent
6901c9b1b6
commit
f829fd2d0d
62
dist/macdeploy.py
vendored
62
dist/macdeploy.py
vendored
@ -23,19 +23,16 @@ import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
LOGGER = logging.getLogger("macdeploy")
|
||||
LOGGER = logging.getLogger('macdeploy')
|
||||
|
||||
FRAMEWORK_SEARCH_PATH=[
|
||||
'/target',
|
||||
'/target/lib',
|
||||
'/Library/Frameworks',
|
||||
FRAMEWORK_SEARCH_PATH = [
|
||||
'/target', '/target/lib', '/Library/Frameworks',
|
||||
os.path.join(os.environ['HOME'], 'Library/Frameworks')
|
||||
]
|
||||
|
||||
LIBRARY_SEARCH_PATH=['/target', '/target/lib', '/usr/local/lib', '/sw/lib']
|
||||
LIBRARY_SEARCH_PATH = ['/target', '/target/lib', '/usr/local/lib', '/sw/lib']
|
||||
|
||||
|
||||
GSTREAMER_PLUGINS=[
|
||||
GSTREAMER_PLUGINS = [
|
||||
# Core plugins
|
||||
'libgstapp.so',
|
||||
'libgstaudioconvert.so',
|
||||
@ -90,7 +87,7 @@ GSTREAMER_PLUGINS=[
|
||||
'libgstrtsp.so',
|
||||
]
|
||||
|
||||
GSTREAMER_SEARCH_PATH=[
|
||||
GSTREAMER_SEARCH_PATH = [
|
||||
'/target/lib/gstreamer-1.0',
|
||||
'/target/libexec/gstreamer-1.0',
|
||||
]
|
||||
@ -121,6 +118,10 @@ INSTALL_NAME_TOOL_CROSS = 'x86_64-apple-darwin-%s' % INSTALL_NAME_TOOL_APPLE
|
||||
INSTALL_NAME_TOOL = INSTALL_NAME_TOOL_CROSS if spawn.find_executable(
|
||||
INSTALL_NAME_TOOL_CROSS) else INSTALL_NAME_TOOL_APPLE
|
||||
|
||||
OTOOL_APPLE = 'otool'
|
||||
OTOOL_CROSS = 'x86_64-apple-darwin-%s' % OTOOL_APPLE
|
||||
OTOOL = OTOOL_CROSS if spawn.find_executable(OTOOL_CROSS) else OTOOL_APPLE
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
@ -154,7 +155,6 @@ class CouldNotParseFrameworkNameError(Error):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print 'Usage: %s <bundle.app>' % sys.argv[0]
|
||||
|
||||
@ -174,11 +174,11 @@ binary = os.path.join(bundle_dir, 'Contents', 'MacOS', bundle_name)
|
||||
fixed_libraries = set()
|
||||
fixed_frameworks = set()
|
||||
|
||||
|
||||
def GetBrokenLibraries(binary):
|
||||
output = subprocess.Popen(['otool', '-L', binary], stdout=subprocess.PIPE).communicate()[0]
|
||||
broken_libs = {
|
||||
'frameworks': [],
|
||||
'libs': []}
|
||||
output = subprocess.Popen(
|
||||
[OTOOL, '-L', binary], stdout=subprocess.PIPE).communicate()[0]
|
||||
broken_libs = {'frameworks': [], 'libs': []}
|
||||
for line in [x.split(' ')[0].lstrip() for x in output.split('\n')[1:]]:
|
||||
if not line: # skip empty lines
|
||||
continue
|
||||
@ -190,7 +190,8 @@ def GetBrokenLibraries(binary):
|
||||
continue # unix style system library
|
||||
elif re.match(r'Breakpad', line):
|
||||
continue # Manually added by cmake.
|
||||
elif re.match(r'^\s*@executable_path', line) or re.match(r'^\s*@loader_path', line):
|
||||
elif re.match(r'^\s*@executable_path', line) or re.match(
|
||||
r'^\s*@loader_path', line):
|
||||
# Potentially already fixed library
|
||||
relative_path = os.path.join(*line.split('/')[3:])
|
||||
if not os.path.exists(os.path.join(frameworks_dir, relative_path)):
|
||||
@ -202,6 +203,7 @@ def GetBrokenLibraries(binary):
|
||||
|
||||
return broken_libs
|
||||
|
||||
|
||||
def FindFramework(path):
|
||||
for search_path in FRAMEWORK_SEARCH_PATH:
|
||||
abs_path = os.path.join(search_path, path)
|
||||
@ -211,6 +213,7 @@ def FindFramework(path):
|
||||
|
||||
raise CouldNotFindFrameworkError(path)
|
||||
|
||||
|
||||
def FindLibrary(path):
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
@ -222,12 +225,14 @@ def FindLibrary(path):
|
||||
|
||||
raise CouldNotFindFrameworkError(path)
|
||||
|
||||
|
||||
def FixAllLibraries(broken_libs):
|
||||
for framework in broken_libs['frameworks']:
|
||||
FixFramework(framework)
|
||||
for lib in broken_libs['libs']:
|
||||
FixLibrary(lib)
|
||||
|
||||
|
||||
def FixFramework(path):
|
||||
if path in fixed_frameworks:
|
||||
return
|
||||
@ -245,8 +250,10 @@ def FixFramework(path):
|
||||
for library in broken_libs['libs']:
|
||||
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(os.path.basename(
|
||||
path)) is not None:
|
||||
return
|
||||
else:
|
||||
fixed_libraries.add(path)
|
||||
@ -261,6 +268,7 @@ def FixLibrary(path):
|
||||
for library in broken_libs['libs']:
|
||||
FixLibraryInstallPath(library, new_path)
|
||||
|
||||
|
||||
def FixPlugin(abs_path, subdir):
|
||||
broken_libs = GetBrokenLibraries(abs_path)
|
||||
FixAllLibraries(broken_libs)
|
||||
@ -271,6 +279,7 @@ def FixPlugin(abs_path, subdir):
|
||||
for library in broken_libs['libs']:
|
||||
FixLibraryInstallPath(library, new_path)
|
||||
|
||||
|
||||
def FixBinary(path):
|
||||
broken_libs = GetBrokenLibraries(path)
|
||||
FixAllLibraries(broken_libs)
|
||||
@ -279,13 +288,15 @@ def FixBinary(path):
|
||||
for library in broken_libs['libs']:
|
||||
FixLibraryInstallPath(library, path)
|
||||
|
||||
|
||||
def CopyLibrary(path):
|
||||
new_path = os.path.join(frameworks_dir, os.path.basename(path))
|
||||
args = ['cp', path, new_path]
|
||||
args = ['cp', path, new_path]
|
||||
commands.append(args)
|
||||
LOGGER.info("Copying library '%s'", path)
|
||||
return new_path
|
||||
|
||||
|
||||
def CopyPlugin(path, subdir):
|
||||
new_path = os.path.join(plugins_dir, subdir, os.path.basename(path))
|
||||
args = ['mkdir', '-p', os.path.dirname(new_path)]
|
||||
@ -295,10 +306,11 @@ def CopyPlugin(path, subdir):
|
||||
LOGGER.info("Copying plugin '%s'", path)
|
||||
return new_path
|
||||
|
||||
|
||||
def CopyFramework(src_binary):
|
||||
while os.path.islink(src_binary):
|
||||
src_binary = os.path.realpath(src_binary)
|
||||
|
||||
|
||||
m = re.match(r'(.*/([^/]+)\.framework)/Versions/([^/]+)/.*', src_binary)
|
||||
if not m:
|
||||
raise CouldNotParseFrameworkNameError(src_binary)
|
||||
@ -307,7 +319,7 @@ def CopyFramework(src_binary):
|
||||
name = m.group(2)
|
||||
version = m.group(3)
|
||||
|
||||
LOGGER.info("Copying framework %s version %s", name, version)
|
||||
LOGGER.info('Copying framework %s version %s', name, version)
|
||||
|
||||
dest_base = os.path.join(frameworks_dir, '%s.framework' % name)
|
||||
dest_dir = os.path.join(dest_base, 'Versions', version)
|
||||
@ -378,14 +390,17 @@ def FindSystemLibrary(library_name):
|
||||
return full_path
|
||||
return None
|
||||
|
||||
|
||||
def FixLibraryInstallPath(library_path, library):
|
||||
system_library = FindSystemLibrary(os.path.basename(library_path))
|
||||
if system_library is None:
|
||||
new_path = '@executable_path/../Frameworks/%s' % os.path.basename(library_path)
|
||||
new_path = '@executable_path/../Frameworks/%s' % os.path.basename(
|
||||
library_path)
|
||||
FixInstallPath(library_path, library, new_path)
|
||||
else:
|
||||
FixInstallPath(library_path, library, system_library)
|
||||
|
||||
|
||||
def FixFrameworkInstallPath(library_path, library):
|
||||
parts = library_path.split(os.sep)
|
||||
for i, part in enumerate(parts):
|
||||
@ -395,6 +410,7 @@ def FixFrameworkInstallPath(library_path, library):
|
||||
new_path = '@executable_path/../Frameworks/%s' % full_path
|
||||
FixInstallPath(library_path, library, new_path)
|
||||
|
||||
|
||||
def FindXinePlugin(name):
|
||||
for path in XINEPLUGIN_SEARCH_PATH:
|
||||
if os.path.exists(path):
|
||||
@ -431,8 +447,10 @@ def FindGioModule(name):
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(filename="macdeploy.log", level=logging.DEBUG,
|
||||
format='%(asctime)s %(levelname)-8s %(message)s')
|
||||
logging.basicConfig(
|
||||
filename='macdeploy.log',
|
||||
level=logging.DEBUG,
|
||||
format='%(asctime)s %(levelname)-8s %(message)s')
|
||||
|
||||
FixBinary(binary)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user