Fix up the rest of the macOS builder

This commit is contained in:
Raoul Snyman 2016-12-03 17:22:08 +02:00
parent dbd59b9a3c
commit 05dde36a9e
3 changed files with 46 additions and 30 deletions

View File

@ -31,22 +31,30 @@ from subprocess import Popen, PIPE
BUILDER_DESCRIPTION = 'Build OpenLP for {platform}. Options are provided on both the command line and a ' \
'configuration file. Options in the configuration file are overridden by the command line options.\n\n' \
'This build system can produce either development or release builds. A development release uses the code ' \
'as-is in the specified branch directory. The release build exports a tag from bzr and uses the exported ' \
'code for building. The two modes are invoked by the presence or absence of the --release option. If this ' \
'option is omitted, a development build is built, while including the --release option with a version ' \
'number will produce a build of that exact version.'
'This build system can produce either development or release builds. A development release uses the ' \
'code as-is in the specified branch directory. The release build exports a tag from bzr and uses the ' \
'exported code for building. The two modes are invoked by the presence or absence of the --release ' \
'option. If this option is omitted, a development build is built, while including the --release ' \
'option with a version number will produce a build of that exact version.'
def _which(command):
def _which(program):
"""
Return absolute path to a command found on system PATH.
"""
if command.startswith('/'):
return command
for path in os.environ["PATH"].split(os.pathsep):
if os.access(os.path.join(path, command), os.X_OK):
return "%s/%s" % (path, command)
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath and is_exe(program):
return program
else:
for path in os.environ['PATH'].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
class Builder(object):
@ -168,7 +176,11 @@ class Builder(object):
"""
self._print_verbose('Executables:')
for option in self.config.options('executables'):
value = _which(self.config.get('executables', option))
value = self.config.get('executables', option)
if not value.strip():
value = None
else:
value = _which(value)
setattr(self, '{option}_exe'.format(option=option), value)
self._print_verbose(' {option:.<30}: {value}'.format(option=option + ' ', value=value))
@ -233,6 +245,7 @@ class Builder(object):
Run PyInstaller on the branch to build an executable.
"""
self._print('Running PyInstaller...')
copy(os.path.join(self.work_path, 'openlp.py'), self.openlp_script)
os.chdir(self.work_path)
cmd = [self.python,
self.pyinstaller_exe,
@ -249,7 +262,7 @@ class Builder(object):
cmd.append('--log-level=ERROR')
else:
cmd.append('--log-level=DEBUG')
if self.args.devel:
if not self.args.release:
cmd.append('-d')
self._run_command(cmd, 'Error running PyInstaller')
@ -381,10 +394,10 @@ class Builder(object):
"""
Run Sphinx to build the manual
"""
self._print('Deleting previous help manual build... %s', self.manual_build_path)
self._print('Running Sphinx...')
self._print_verbose(' Deleting previous help manual build... %s', self.manual_build_path)
if os.path.exists(self.manual_build_path):
rmtree(self.manual_build_path)
self._print('Running Sphinx...')
os.chdir(self.manual_path)
sphinx_build = self.get_sphinx_build()
command = [self.sphinx_exe, '-b', sphinx_build, '-d', 'build/doctrees', 'source', 'build/{}'.format(sphinx_build)]
@ -420,8 +433,6 @@ class Builder(object):
self.copy_default_theme()
self.copy_plugins()
self.copy_media_player()
self.copy_extra_files()
# TODO creating help on Mac
if os.path.exists(self.manual_path):
self.run_sphinx()
else:
@ -429,13 +440,12 @@ class Builder(object):
self._print('WARNING: Documentation trunk not found')
self._print(' Help file will not be included in build')
self._print('')
self.copy_macosx_files()
self.copy_extra_files()
if not self.args.skip_translations:
if self.args.update_translations:
self.update_translations()
self.compile_translations()
self.code_sign()
self.create_dmg_file()
self.build_package()
self._print('Done.')
raise SystemExit()

View File

@ -119,14 +119,20 @@ class MacosxBuilder(Builder):
dir_size += os.path.getsize(filename)
return dir_size
def get_sphinx_build(self):
"""
The type of build Sphinx should be doing
"""
return 'applehelp'
def setup_paths(self):
"""
Extra setup to run
"""
super().setup_paths()
if hasattr(self, 'mutoolbin'):
self.mutoollib = os.path.abspath(
os.path.join(os.path.dirname(self.mutoolbin), '..', 'lib', 'libjbig2dec.0.dylib'))
if hasattr(self, 'mutool_exe'):
self.mutool_lib = os.path.abspath(
os.path.join(os.path.dirname(self.mutool_exe), '..', 'lib', 'libjbig2dec.0.dylib'))
self.dist_app_path = os.path.join(self.work_path, 'dist', 'OpenLP.app')
self.dist_path = os.path.join(self.work_path, 'dist', 'OpenLP.app', 'Contents', 'MacOS')
@ -157,15 +163,15 @@ class MacosxBuilder(Builder):
"""
self._print('Copying extra files for Mac OS X...')
self._print_verbose('... LICENSE.txt')
copy(os.path.join(self.script_path, 'LICENSE.txt'), os.path.join(self.dist_path, 'LICENSE.txt'))
copy(self.license_path, os.path.join(self.dist_path, 'LICENSE.txt'))
self._print_verbose('... mudraw')
if hasattr(self, 'mudrawbin') and os.path.isfile(self.mudrawbin):
copy(self.mudrawbin, os.path.join(self.dist_path, 'mudraw'))
if hasattr(self, 'mudraw_exe') and self.mudraw_exe and os.path.isfile(self.mudraw_exe):
copy(self.mudraw_exe, os.path.join(self.dist_path, 'mudraw'))
self.relink_mudraw()
elif hasattr(self, 'mutoolbin') and os.path.isfile(self.mutoolbin):
copy(self.mutoolbin, os.path.join(self.dist_path, 'mutool'))
elif hasattr(self, 'mutool_exe') and self.mutool_exe and os.path.isfile(self.mutool_exe):
copy(self.mutool_exe, os.path.join(self.dist_path, 'mutool'))
self.relink_mutool()
copy(self.mutoollib, os.path.join(self.dist_path, 'libjbig2dec.0.dylib'))
copy(self.mutool_lib, os.path.join(self.dist_path, 'libjbig2dec.0.dylib'))
else:
self._print('... WARNING: mudraw and mutool not found')
@ -274,7 +280,7 @@ class MacosxBuilder(Builder):
size += 10
self._print('... %s' % self.script_path)
os.chdir(self.script_path)
os.chdir(os.path.dirname(self.dmg_settings_path))
self._run_command([self.dmgbuild_exe, '-s', self.dmg_settings_path, '-D', 'size={size}M'.format(size=size),
'-D', 'icon={icon_path}'.format(icon_path=self.icon_path),
'-D', 'app={dist_app_path}'.format(dist_app_path=self.dist_app_path), dmg_title, self.dmg_file],

0
builders/windows-builder.py Executable file → Normal file
View File