2020-05-02 19:30:18 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Use the same verbose variable as CMake
|
2021-09-22 21:46:52 +00:00
|
|
|
[ "$VERBOSE" = "1" ] && set -x
|
2020-05-02 19:30:18 +00:00
|
|
|
|
|
|
|
# Exit on unset variables or pipe errors
|
|
|
|
set -uo pipefail
|
|
|
|
|
|
|
|
B_MACOS="Barrier.app/Contents/MacOS"
|
|
|
|
B_VERSION="@BARRIER_VERSION@"
|
|
|
|
B_BINDIR="@CMAKE_RUNTIME_OUTPUT_DIRECTORY@"
|
|
|
|
B_BUILDTYPE="@CMAKE_BUILD_TYPE@"
|
2020-05-04 16:37:18 +00:00
|
|
|
B_BARRIERC="Barrier.app/Contents/MacOS/barrierc"
|
|
|
|
B_BARRIERS="Barrier.app/Contents/MacOS/barriers"
|
2020-05-02 19:30:18 +00:00
|
|
|
|
|
|
|
# Colorized output
|
2021-09-22 21:46:52 +00:00
|
|
|
info() { tput bold; echo "$@"; tput sgr0 ; }
|
|
|
|
error() { tput bold; tput setaf 1; echo "$@"; tput sgr0 ; }
|
|
|
|
success() { tput bold; tput setaf 2; echo "$@"; tput sgr0 ; }
|
|
|
|
warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
|
2020-05-02 19:30:18 +00:00
|
|
|
|
|
|
|
info "Checking for bundle contents"
|
|
|
|
if [ ! -d "Barrier.app/Contents" ]; then
|
|
|
|
error "Please make sure that the build completed successfully"
|
|
|
|
error "before trying to create the installer."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$B_MACOS" ]; then
|
|
|
|
info "Removing old binaries from bundle"
|
|
|
|
rm -r "$B_MACOS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
info "Copying binaries into bundle"
|
|
|
|
# Copy the folder instead of globbing unquoted path
|
|
|
|
cp -r "$B_BINDIR" "$B_MACOS" || exit 1
|
|
|
|
|
|
|
|
# Check for macdeployqt on MacPorts
|
|
|
|
if which -s port ; then
|
|
|
|
info "MacPorts found, searching for macdeployqt"
|
|
|
|
DEPLOYQT="$(port contents qt5-qttools | grep --only --max-count 1 '/.*macdeployqt')"
|
|
|
|
if [ ! -x "$DEPLOYQT" ]; then
|
2021-09-22 21:46:52 +00:00
|
|
|
error "Please install package qt5-qttools"
|
2020-05-02 19:30:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for macdeployqt on Homebrew
|
|
|
|
if which -s brew ; then
|
|
|
|
info "Homebrew found, searching for macdeployqt"
|
2021-06-22 16:05:58 +00:00
|
|
|
DEPLOYQT="$(brew list qt@5 | grep --only '/.*macdeployqt' | head -1)"
|
2020-05-02 19:30:18 +00:00
|
|
|
if [ ! -x "$DEPLOYQT" ]; then
|
2021-09-22 21:46:52 +00:00
|
|
|
error "Please install package qt"
|
2020-05-02 19:30:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Use macdeployqt to include libraries and create dmg
|
2021-09-22 21:46:52 +00:00
|
|
|
if [ "$B_BUILDTYPE" = "Release" ]; then
|
2020-05-02 19:30:18 +00:00
|
|
|
info "Building Release disk image (dmg)"
|
2020-05-04 16:37:18 +00:00
|
|
|
"$DEPLOYQT" Barrier.app -dmg \
|
|
|
|
-executable="$B_BARRIERC" \
|
|
|
|
-executable="$B_BARRIERS" || exit 1
|
2020-05-02 19:30:18 +00:00
|
|
|
mv "Barrier.dmg" "Barrier-$B_VERSION.dmg" || exit 1
|
|
|
|
success "Created Barrier-$B_VERSION.dmg"
|
|
|
|
else
|
|
|
|
warn "Disk image (dmg) only created for Release builds"
|
|
|
|
info "Building debug bundle"
|
2020-05-04 16:37:18 +00:00
|
|
|
"$DEPLOYQT" Barrier.app -no-strip \
|
|
|
|
-executable="$B_BARRIERC" \
|
|
|
|
-executable="$B_BARRIERS" || exit 1
|
2020-05-02 19:30:18 +00:00
|
|
|
success "Bundle created successfully"
|
2021-06-22 16:05:58 +00:00
|
|
|
fi
|