meson: enable building Aegisub.app on macOS

This commit is contained in:
Ryan Lucia 2019-10-06 20:54:47 -04:00 committed by odrling
parent e46a7b2d2b
commit fe1813ec03
8 changed files with 64 additions and 45 deletions

View File

@ -1,4 +1,4 @@
automation_dir = get_option('datadir') / 'aegisub' / 'automation' automation_dir = dataroot / 'automation'
install_data( install_data(
'autoload/cleantags-autoload.lua', 'autoload/cleantags-autoload.lua',

View File

@ -1,6 +1,6 @@
project('Aegisub', ['c', 'cpp'], project('Aegisub', ['c', 'cpp'],
license: 'BSD-3-Clause', license: 'BSD-3-Clause',
meson_version: '>=0.49.0', meson_version: '>=0.50.0',
default_options: ['c_std=c11', 'cpp_std=c++11', 'b_lto=true'], default_options: ['c_std=c11', 'cpp_std=c++11', 'b_lto=true'],
version: '3.2.2') version: '3.2.2')
@ -16,7 +16,19 @@ version_h = custom_target('git_version.h',
build_always_stale: true, # has internal check whether target file will be refreshed build_always_stale: true, # has internal check whether target file will be refreshed
output: ['git_version.h', 'git_version.xml']) output: ['git_version.h', 'git_version.xml'])
dataroot = get_option('prefix') / get_option('datadir') / 'aegisub' if host_machine.system() == 'darwin' and get_option('build_osx_bundle')
prefix = meson.current_build_dir() / 'Aegisub.app' / 'Contents'
bindir = prefix / 'MacOS'
datadir = prefix / 'SharedSupport'
localedir = prefix / 'Resources'
else
prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
datadir = prefix / get_option('datadir')
localedir = prefix / get_option('localedir')
endif
docdir = prefix / 'doc'
dataroot = datadir / 'aegisub'
add_project_arguments('-DP_DATA="@0@"'.format(dataroot), language: 'cpp') add_project_arguments('-DP_DATA="@0@"'.format(dataroot), language: 'cpp')
if host_machine.system() == 'windows' if host_machine.system() == 'windows'

View File

@ -21,3 +21,5 @@ option('credit', type: 'string', value: '', description: 'Build credit shown in
option('enable_update_checker', type: 'boolean', value: false, description: 'Enable the update checker') option('enable_update_checker', type: 'boolean', value: false, description: 'Enable the update checker')
option('update_server', type: 'string', value: 'updates.aegisub.org', description: 'Server to use for the update checker') option('update_server', type: 'string', value: 'updates.aegisub.org', description: 'Server to use for the update checker')
option('update_url', type: 'string', value: '/trunk', description: 'Base path to use for the update checker') option('update_url', type: 'string', value: '/trunk', description: 'Base path to use for the update checker')
option('build_osx_bundle', type: 'boolean', value: 'false', description: 'Package Aegisub.app on OSX')

View File

@ -2,6 +2,12 @@ conf_pkg = configuration_data()
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
elif host_machine.system() == 'darwin' elif host_machine.system() == 'darwin'
# temporary hack until version.sh generates this properly
run_command('cp', meson.source_root() / 'tools' / 'osx-bundle.sed', meson.build_root())
fontconfig_conf = run_command('pkg-config', '--variable=confdir', 'fontconfig').stdout().strip()
run_target('osx-bundle',
command: ['../tools/osx-bundle.sh', meson.source_root(), meson.build_root(), 'wx-config', fontconfig_conf, '',
get_option('build_osx_bundle') ? 'TRUE' : 'FALSE'])
else else
conf_pkg.set('AEGISUB_COMMAND', 'aegisub') conf_pkg.set('AEGISUB_COMMAND', 'aegisub')
@ -15,7 +21,7 @@ else
type: 'desktop', type: 'desktop',
po_dir: '../po', po_dir: '../po',
install: true, install: true,
install_dir: join_paths(get_option('datadir'), 'applications')) install_dir: datadir / 'applications')
aegisub_logos = ['16x16.png', '22x22.png', '24x24.png', '32x32.png', '48x48.png', '64x64.png', 'scalable.svg'] aegisub_logos = ['16x16.png', '22x22.png', '24x24.png', '32x32.png', '48x48.png', '64x64.png', 'scalable.svg']
@ -23,6 +29,6 @@ else
dir = s.split('.')[0] dir = s.split('.')[0]
ext = s.split('.')[1] ext = s.split('.')[1]
install_data('desktop' / dir / 'aegisub.' + ext, install_data('desktop' / dir / 'aegisub.' + ext,
install_dir: get_option('datadir') / 'icons' / 'hicolor' / dir / 'apps') install_dir: datadir / 'icons' / 'hicolor' / dir / 'apps')
endforeach endforeach
endif endif

View File

@ -1,2 +1,4 @@
i18n = import('i18n') i18n = import('i18n')
i18n.gettext('aegisub') # This is currently busted on OSX
i18n.gettext('aegisub',
install_dir: localedir)

View File

@ -207,4 +207,5 @@ aegisub = executable('aegisub', aegisub_src, version_h, acconf,
include_directories: [libaegisub_inc, libresrc_inc, version_inc, deps_inc], include_directories: [libaegisub_inc, libresrc_inc, version_inc, deps_inc],
cpp_pch: aegisub_cpp_pch, cpp_pch: aegisub_cpp_pch,
install: true, install: true,
install_dir: bindir,
dependencies: deps) dependencies: deps)

View File

@ -2,22 +2,25 @@
set -e set -e
PKG_DIR=Aegisub.app SRC_DIR="${1}"
SKEL_DIR="packages/osx_bundle" BUILD_DIR="${2}"
AEGISUB_BIN="${1}" WX_PREFIX=`${3} --prefix`
SRCDIR=`pwd` FONTCONFIG_CONF_DIR="${4}"
HOME_DIR=`echo ~` DICT_DIR="${5}"
WX_PREFIX=`${2} --prefix` MESON_BUILD_OSX_BUNDLE="${6}"
FONTCONFIG_CONF_DIR="${3}"
if ! test -d packages/osx_bundle; then if [ "${MESON_BUILD_OSX_BUNDLE}" != "TRUE" ]; then
echo echo "Project not built with \`build_osx_bundle\`"
echo "Make sure you're in the toplevel source directory" echo "Please run \`meson configure -Dbuild_osx_bundle=true\` and rebuild"
exit 1 exit 1
fi fi
PKG_DIR="${BUILD_DIR}/Aegisub.app"
SKEL_DIR="${SRC_DIR}/packages/osx_bundle"
if test -d "${PKG_DIR}"; then if test -d "${PKG_DIR}"; then
rm -rf "${PKG_DIR}" rm -rf "${PKG_DIR}"
echo "Removing old Aegisub.app"
fi fi
echo echo
@ -31,41 +34,34 @@ mkdir -v "${PKG_DIR}/Contents/SharedSupport/dictionaries"
echo echo
echo "---- Copying Skel Files ----" echo "---- Copying Skel Files ----"
if ! test -f "tools/osx-bundle.sed"; then if ! test -f "${BUILD_DIR}/osx-bundle.sed"; then
echo echo
echo "NOT FOUND: tools/osx-bundle.sed" echo "NOT FOUND: ${BUILD_DIR}/osx-bundle.sed"
exit 1 exit 1
fi fi
# used by osx-bundle.sed # used by osx-bundle.sed
find po -name *.po | sed 's/.*\/\(.*\)\.po/ <string>\1<\/string>/; s/RS/YU/' > languages find "${SRC_DIR}/po" -name *.po | sed 's/.*\/\(.*\)\.po/ <string>\1<\/string>/; s/RS/YU/' > "${BUILD_DIR}/languages"
find ${SKEL_DIR} -type f -not -regex ".*.svn.*" #find "${SKEL_DIR}" -type f -not -regex ".*.svn.*"
cp ${SKEL_DIR}/Contents/Resources/*.icns "${PKG_DIR}/Contents/Resources" cp -v ${SKEL_DIR}/Contents/Resources/*.icns "${PKG_DIR}/Contents/Resources"
cat ${SKEL_DIR}/Contents/Info.plist | sed -f tools/osx-bundle.sed > "${PKG_DIR}/Contents/Info.plist" cat "${SKEL_DIR}/Contents/Info.plist" | sed -f "${BUILD_DIR}/osx-bundle.sed" > "${PKG_DIR}/Contents/Info.plist"
rm languages rm "${BUILD_DIR}/languages"
echo echo
echo "---- Installing files ----" echo "---- Installing files ----"
make install \ CURRENT_DIR=`pwd`
DESTDIR="${PKG_DIR}/Contents" \ cd ${BUILD_DIR}
P_DATA="/SharedSupport" \ ninja install
P_DOC="/SharedSupport/doc" \ cd ${CURRENT_DIR}
P_LOCALE="/Resources" \
P_BINDIR="/MacOS"
echo echo
echo "---- Copying dictionaries ----" echo "---- Copying dictionaries ----"
if test -z "${DICT_DIR}"; then if test -f "${DICT_DIR}"; then
DICT_DIR="${HOME_DIR}/dict" cp -v "${DICT_DIR}/*" "${PKG_DIR}/Contents/SharedSupport/dictionaries"
fi
if test -d "${DICT_DIR}"; then
cp -v ${DICT_DIR}/* "${PKG_DIR}/Contents/SharedSupport/dictionaries"
else else
echo "WARNING: Dictionaries not found, please set $$DICT_DIR to a directiory" echo "Specified dictionary directory ${DICT_DIR} not found!"
echo " where the *.aff and *.dic files can be found"
fi fi
echo echo
@ -74,14 +70,15 @@ echo "---- Copying Aegisub locale files ----"
# internal so we don't need an aegisub.mo file. # internal so we don't need an aegisub.mo file.
mkdir -vp "${PKG_DIR}/Contents/Resources/en.lproj" mkdir -vp "${PKG_DIR}/Contents/Resources/en.lproj"
# FIXME
# 10.8 wants sr_YU rather than sr_RS # 10.8 wants sr_YU rather than sr_RS
mv "${PKG_DIR}/Contents/Resources/sr_RS.lproj" "${PKG_DIR}/Contents/Resources/sr_YU.lproj" #mv "${PKG_DIR}/Contents/Resources/sr_RS.lproj" "${PKG_DIR}/Contents/Resources/sr_YU.lproj"
mv "${PKG_DIR}/Contents/Resources/sr_RS@latin.lproj" "${PKG_DIR}/Contents/Resources/sr_YU@latin.lproj" #mv "${PKG_DIR}/Contents/Resources/sr_RS@latin.lproj" "${PKG_DIR}/Contents/Resources/sr_YU@latin.lproj"
echo echo
echo "---- Copying WX locale files ----" echo "---- Copying WX locale files ----"
for i in `ls -1 po/*.mo|sed "s|po/\(.*\).mo|\1|"`; do for i in `ls -1 ${SRC_DIR}/po/*.mo|sed "s|po/\(.*\).mo|\1|"`; do
WX_MO="${WX_PREFIX}/share/locale/${i}/LC_MESSAGES/wxstd.mo" WX_MO="${WX_PREFIX}/share/locale/${i}/LC_MESSAGES/wxstd.mo"
if ! test -f "${WX_MO}"; then if ! test -f "${WX_MO}"; then
@ -95,10 +92,9 @@ for i in `ls -1 po/*.mo|sed "s|po/\(.*\).mo|\1|"`; do
fi fi
done done
echo
echo "---- Fixing libraries ----"
sudo python "${SRC_DIR}/tools/osx-fix-libs.py" "${PKG_DIR}/Contents/MacOS/aegisub" || exit $?
echo echo
echo "---- Libraries ----" echo "Done creating \"${PKG_DIR}\""
python tools/osx-fix-libs.py "${PKG_DIR}/Contents/MacOS/aegisub" || exit $?
echo
echo "Done Creating \"${PKG_DIR}\""