2020-04-18 18:49:11 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2020-04-23 20:12:59 +02:00
|
|
|
root_path="$(pwd)"
|
|
|
|
project_path="${root_path}/Jamulus.pro"
|
|
|
|
macdeploy_path="${root_path}/mac"
|
|
|
|
resources_path="${root_path}/src/res"
|
|
|
|
build_path="${root_path}/build"
|
|
|
|
deploy_path="${root_path}/deploy"
|
|
|
|
|
|
|
|
|
2020-04-23 21:27:33 +02:00
|
|
|
cleanup()
|
2020-04-23 20:12:59 +02:00
|
|
|
{
|
2020-04-23 21:27:33 +02:00
|
|
|
# Clean up previous deployments
|
|
|
|
rm -rf "${build_path}"
|
|
|
|
rm -rf "${deploy_path}"
|
|
|
|
mkdir -p "${build_path}"
|
|
|
|
mkdir -p "${deploy_path}"
|
2020-04-23 20:12:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-23 21:27:33 +02:00
|
|
|
build_app()
|
2020-04-23 20:12:59 +02:00
|
|
|
{
|
2020-04-18 18:49:11 +02:00
|
|
|
# Build Jamulus
|
2020-04-23 20:12:59 +02:00
|
|
|
qmake "${project_path}" -o "${build_path}/Makefile" "CONFIG+=release" ${@:2}
|
2020-04-23 21:27:33 +02:00
|
|
|
local target_name="$(cat "${build_path}/Makefile" | sed -nE 's/^QMAKE_TARGET *= *(.*)$/\1/p')"
|
|
|
|
local job_count="$(sysctl -n hw.ncpu)"
|
|
|
|
|
2020-04-23 20:12:59 +02:00
|
|
|
make -f "${build_path}/Makefile" -C "${build_path}" -j "${job_count}"
|
|
|
|
|
|
|
|
# Add Qt deployment dependencies
|
|
|
|
macdeployqt "${build_path}/${target_name}.app" -verbose=2 -always-overwrite
|
|
|
|
mv "${build_path}/${target_name}.app" "${deploy_path}"
|
2020-04-23 21:27:33 +02:00
|
|
|
|
|
|
|
# Cleanup
|
2020-04-23 20:12:59 +02:00
|
|
|
make -f "${build_path}/Makefile" -C "${build_path}" distclean
|
2020-04-23 21:27:33 +02:00
|
|
|
|
|
|
|
# Return app name for installer image
|
|
|
|
eval "$1=${target_name}"
|
2020-04-23 20:12:59 +02:00
|
|
|
}
|
2020-04-18 18:49:11 +02:00
|
|
|
|
|
|
|
|
2020-04-23 21:27:33 +02:00
|
|
|
build_installer_image()
|
2020-04-23 20:12:59 +02:00
|
|
|
{
|
2020-04-23 21:27:33 +02:00
|
|
|
# Install dmgbuild (for the current user), this is required to build the installer image
|
|
|
|
python -m ensurepip --user --default-pip
|
|
|
|
python -m pip install --user dmgbuild
|
|
|
|
local dmgbuild_bin="$(python -c 'import site; print(site.USER_BASE)')/bin/dmgbuild"
|
|
|
|
|
|
|
|
# Get Jamulus version
|
|
|
|
local app_version="$(cat "${project_path}" | sed -nE 's/^VERSION *= *(.*)$/\1/p')"
|
|
|
|
|
|
|
|
# Build installer image
|
|
|
|
"${dmgbuild_bin}" -s "${macdeploy_path}/deployment_settings.py" -D background="${resources_path}/installerbackground.png" \
|
|
|
|
-D app_path="${deploy_path}/$1.app" -D server_path="${deploy_path}/$2.app" \
|
|
|
|
-D license="${root_path}/COPYING" "$1 Installer" "${deploy_path}/$1-${app_version}-installer-mac.dmg"
|
2020-04-18 18:49:11 +02:00
|
|
|
}
|
|
|
|
|
2020-04-23 20:12:59 +02:00
|
|
|
|
|
|
|
# Check that we are running from the correct location
|
2020-04-23 21:27:33 +02:00
|
|
|
if [ ! -f "${project_path}" ];
|
2020-04-23 20:12:59 +02:00
|
|
|
then
|
|
|
|
echo Please run this script from the Qt project directory where "$(basename ${project_path})" is located.
|
2020-04-18 18:49:11 +02:00
|
|
|
echo Usage: mac/$(basename $0)
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-04-23 20:12:59 +02:00
|
|
|
# Cleanup previous deployments
|
|
|
|
cleanup
|
2020-04-18 18:49:11 +02:00
|
|
|
|
2020-04-23 20:12:59 +02:00
|
|
|
# Build Jamulus client and server
|
|
|
|
build_app client_app
|
|
|
|
build_app server_app "CONFIG+=server_bundle"
|
2020-04-18 18:49:11 +02:00
|
|
|
|
2020-04-23 20:12:59 +02:00
|
|
|
# Create versioned installer image
|
|
|
|
build_installer_image "${client_app}" "${server_app}"
|