Merge pull request #134 from doloopuntil/improve_mac_ci

Improve Mac deployment process
This commit is contained in:
corrados 2020-04-24 16:05:46 +02:00 committed by GitHub
commit 94057d57cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 111 additions and 49 deletions

View file

@ -31,9 +31,8 @@ matrix:
- brew install qt5 - brew install qt5
- brew link qt5 --force - brew link qt5 --force
script: script:
- qmake "CONFIG+=istravis" -spec macx-xcode Jamulus.pro - qmake Jamulus.pro
- xcodebuild -list -project Jamulus.xcodeproj - mac/deploy_mac.sh
- xcodebuild -scheme Jamulus build
#deploy function is only available in travis-ci.com (not free) but not in travis-ci.org (free) #deploy function is only available in travis-ci.com (not free) but not in travis-ci.org (free)
#deploy: #deploy:
# provider: releases # provider: releases

View file

@ -76,14 +76,25 @@ win32 {
LIBS += "C:/Program Files (x86)/Jack/lib/libjack64.lib" LIBS += "C:/Program Files (x86)/Jack/lib/libjack64.lib"
} }
} else:macx { } else:macx {
contains(CONFIG, "server_bundle") {
message(The generated application bundle will run a server instance.)
DEFINES += SERVER_BUNDLE
TARGET = $${TARGET}Server
}
QT += macextras QT += macextras
HEADERS += mac/sound.h HEADERS += mac/sound.h
SOURCES += mac/sound.cpp SOURCES += mac/sound.cpp
RC_FILE = mac/mainicon.icns RC_FILE = mac/mainicon.icns
CONFIG += x86 CONFIG += x86
!contains(CONFIG, "istravis") { QMAKE_TARGET_BUNDLE_PREFIX = net.sourceforge.llcon
QMAKE_INFO_PLIST = mac/Info.plist QMAKE_APPLICATION_BUNDLE_NAME. = $$TARGET
QMAKE_TARGET_BUNDLE_PREFIX = net.sourceforge.llcon
macx-xcode {
QMAKE_INFO_PLIST = mac/Info-xcode.plist
} else {
QMAKE_INFO_PLIST = mac/Info-make.plist
} }
LIBS += -framework CoreFoundation \ LIBS += -framework CoreFoundation \

32
mac/Info-xcode.plist Normal file
View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleDisplayName</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>${QMAKE_FULL_VERSION}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleIconFile</key>
<string>mainicon.icns</string>
<key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMicrophoneUsageDescription</key>
<string>Jamulus needs access to the microphone to record and stream your music to other musicians</string>
<!-- Temporarily opt out of Dark Mode as Qt 5.9 does not support it well, see https://bugreports.qt.io/browse/QTBUG-68891 -->
<key>NSRequiresAquaSystemAppearance</key>
<string>true</string>
</dict>
</plist>

View file

@ -1,57 +1,77 @@
#!/bin/bash #!/bin/bash
set -e set -e
APP_NAME="Jamulus" root_path="$(pwd)"
SERVER_NAME="${APP_NAME}Server" project_path="${root_path}/Jamulus.pro"
INSTALLER_NAME="${APP_NAME}-installer" macdeploy_path="${root_path}/mac"
ROOT_PATH="$(pwd)" resources_path="${root_path}/src/res"
MAC_PATH="${ROOT_PATH}/mac" build_path="${root_path}/build"
RES_PATH="${ROOT_PATH}/src/res" deploy_path="${root_path}/deploy"
BUILD_PATH="${ROOT_PATH}/build"
DEPLOY_PATH="${ROOT_PATH}/deploy"
JOB_COUNT=$(sysctl -n hw.ncpu)
function build_app {
# Build Jamulus
qmake "${ROOT_PATH}/${APP_NAME}.pro" -o "${BUILD_PATH}/Makefile" \
"CONFIG+=release" "TARGET=$1" "QMAKE_APPLICATION_BUNDLE_NAME=$1" ${@:2}
make -f "${BUILD_PATH}/Makefile" -C "${BUILD_PATH}" -j${JOB_COUNT} cleanup()
{
# Deploy Jamulus # Clean up previous deployments
macdeployqt "${BUILD_PATH}/$1.app" -verbose=2 -always-overwrite rm -rf "${build_path}"
mv "${BUILD_PATH}/$1.app" "${DEPLOY_PATH}" rm -rf "${deploy_path}"
make -f "${BUILD_PATH}/Makefile" -C "${BUILD_PATH}" distclean mkdir -p "${build_path}"
mkdir -p "${deploy_path}"
} }
# Check we are running from the correct location
if [ ! -f "${ROOT_PATH}/${APP_NAME}.pro" ]; then build_app()
echo Please run this script from the ${APP_NAME} Qt project directory. {
# Build Jamulus
qmake "${project_path}" -o "${build_path}/Makefile" "CONFIG+=release" ${@:2}
local target_name="$(cat "${build_path}/Makefile" | sed -nE 's/^QMAKE_TARGET *= *(.*)$/\1/p')"
local job_count="$(sysctl -n hw.ncpu)"
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}"
# Cleanup
make -f "${build_path}/Makefile" -C "${build_path}" distclean
# Return app name for installer image
eval "$1=${target_name}"
}
build_installer_image()
{
# 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"
}
# Check that we are running from the correct location
if [ ! -f "${project_path}" ];
then
echo Please run this script from the Qt project directory where "$(basename ${project_path})" is located.
echo Usage: mac/$(basename $0) echo Usage: mac/$(basename $0)
exit 1 exit 1
fi fi
# 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
DMGBUILD_BIN="$(python -c 'import site; print(site.USER_BASE)')/bin/dmgbuild"
# Get Jamulus version # Cleanup previous deployments
APP_VERSION=$(cat "${ROOT_PATH}/${APP_NAME}.pro" | sed -nE 's/^VERSION *= *(.*)$/\1/p') cleanup
# Clean up previous deployments # Build Jamulus client and server
rm -rf "${BUILD_PATH}" build_app client_app
rm -rf "${DEPLOY_PATH}" build_app server_app "CONFIG+=server_bundle"
mkdir -p "${BUILD_PATH}"
mkdir -p "${DEPLOY_PATH}"
# Build Jamulus client # Create versioned installer image
build_app "${APP_NAME}" build_installer_image "${client_app}" "${server_app}"
# Build Jamulus server
build_app "${SERVER_NAME}" "DEFINES+=SERVER_BUNDLE"
# Build installer image
"${DMGBUILD_BIN}" -s "${MAC_PATH}/deployment_settings.py" -D background="${RES_PATH}/installerbackground.png" \
-D app_path="${DEPLOY_PATH}/${APP_NAME}.app" -D server_path="${DEPLOY_PATH}/${SERVER_NAME}.app" \
-D license="${ROOT_PATH}/COPYING" "${INSTALLER_NAME}" "${DEPLOY_PATH}/${INSTALLER_NAME}-${APP_VERSION}-mac.dmg"