Fix various parts of the build script for the macOS build

merge-requests/5/head
Raoul Snyman 2019-12-10 04:07:44 +00:00
parent 2a26e6c03d
commit bb1b6b773b
4 changed files with 22 additions and 10 deletions

2
.flake8 100644
View File

@ -0,0 +1,2 @@
[flake8]
max-line-length=120

3
.gitignore vendored 100644
View File

@ -0,0 +1,3 @@
__pycache__
*.pyc
config.ini

View File

@ -135,7 +135,7 @@ class MacOSXBuilder(Builder):
folder.symlink_to(good_path)
def _fix_qt_dll(self, dll):
def _fix_qt_dll(self, dll_file):
"""
Fix the DLL lookup paths to use relative ones for Qt dependencies.
Inspiration: PyInstaller/depend/dylib.py:mac_set_relative_dylib_deps()
@ -158,15 +158,19 @@ class MacOSXBuilder(Builder):
return None
return f'@loader_path{good_path}/{basename}'
# Skip it if it's not a dylib file
if dll_file.suffix != '.dylib':
return
# Resources/PyQt5/Qt/qml/QtQuick/Controls.2/Fusion
root = str(dll.parent).partition('Contents')[2][1:]
root = str(dll_file.parent).partition('Contents')[2][1:]
# /../../../../../../..
backward = '/..' * len(root.split('/'))
# /../../../../../../../MacOS
good_path = f'{backward}/MacOS'
# Rewrite Mach headers with corrected @loader_path
dll = MachO(dll)
dll = MachO(dll_file)
dll.rewriteLoadCommands(match_func)
with open(dll.filename, 'rb+') as f:
for header in dll.headers:
@ -183,7 +187,7 @@ class MacOSXBuilder(Builder):
if not path.is_dir() or path.is_symlink():
# Skip simlinks as they are allowed (even with a dot)
continue
if '.' in path.name:
if path.name == 'qml':
yield path
else:
yield from self._find_problematic_qt_folders(path)
@ -199,6 +203,7 @@ class MacOSXBuilder(Builder):
yield from self._move_contents_to_resources(path)
else:
sibling = Path(str(path).replace('MacOS', 'Resources'))
sibling.parent.mkdir(parents=True, exist_ok=True)
move(path, sibling)
yield sibling
@ -213,9 +218,9 @@ class MacOSXBuilder(Builder):
rmtree(folder)
self._create_symlink(folder)
def _relink_mupdf(self, bin_name):
def _relink_binary(self, bin_name):
"""
Relink mupdf to bundled libraries
Relink bundled libraries
"""
self._print('Linking {bin_name} with bundled libraries...'.format(bin_name=bin_name))
libname = os.path.join(self.dist_path, bin_name)
@ -263,13 +268,13 @@ class MacOSXBuilder(Builder):
"""
Relink mudraw to bundled libraries
"""
self._relink_mupdf('mudraw')
self._relink_binary('mudraw')
def _relink_mutool(self):
"""
Relink mudraw to bundled libraries
"""
self._relink_mupdf('mutool')
self._relink_binary('mutool')
def _install_pyro4(self):
"""
@ -296,6 +301,7 @@ class MacOSXBuilder(Builder):
for fname in ['libvlc.dylib', 'libvlccore.dylib']:
self._print_verbose('... {}'.format(fname))
copy(os.path.join(vlc_path, 'lib', fname), os.path.join(vlc_dest, fname))
self._relink_binary(os.path.join('vlc', fname))
if os.path.exists(os.path.join(vlc_dest, 'plugins')):
rmtree(os.path.join(vlc_dest, 'plugins'))
self._print_verbose('... copying VLC plugins')
@ -404,7 +410,8 @@ class MacOSXBuilder(Builder):
Copy any extra files which are particular to a platform
"""
self._print('Copying extra files for macOS...')
self._copy_vlc_files()
# Exclude VLC for now, at least
# self._copy_vlc_files()
self._copy_bundle_files()
self._copy_macosx_files()

View File

@ -29,7 +29,7 @@ import os
HERE = os.getcwd()
format = 'UDBZ'
size = '600M'
size = '850M'
files = [defines.get('app', '/Applications/OpenLP.app')]
symlinks = { 'Applications': '/Applications' }
badge_icon = os.path.join(HERE, 'OpenLP.icns')