From e37277fe8f5ecd1ec0c625d19923f3e49c0cd6e8 Mon Sep 17 00:00:00 2001 From: Chris Simons Date: Sat, 2 May 2020 12:30:18 -0700 Subject: [PATCH 1/6] Add script that uses macdeployqt instead of `reref_dylibs.sh` shell script to create the `.app` bundle --- dist/macos/bundle/build_dist.sh.in | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 dist/macos/bundle/build_dist.sh.in diff --git a/dist/macos/bundle/build_dist.sh.in b/dist/macos/bundle/build_dist.sh.in new file mode 100755 index 00000000..f9565d63 --- /dev/null +++ b/dist/macos/bundle/build_dist.sh.in @@ -0,0 +1,67 @@ +#!/bin/sh + +# Use the same verbose variable as CMake +[ "$VERBOSE" == "1" ] && set -x + +# 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@" + +# Colorized output +function info() { tput bold; echo "$@" ; tput sgr0 ;} +function error() { tput bold; tput setaf 1; echo "$@"; tput sgr0 ; } +function success() { tput bold; tput setaf 2; echo "$@"; tput sgr0 ; } +function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; } + +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 + error Please install package qt5-qttools + exit 1 + fi +fi + +# Check for macdeployqt on Homebrew +if which -s brew ; then + info "Homebrew found, searching for macdeployqt" + DEPLOYQT="$(brew list qt | grep --only --max-count 1 '/.*macdeployqt')" + if [ ! -x "$DEPLOYQT" ]; then + error Please install package qt + exit 1 + fi +fi + +# Use macdeployqt to include libraries and create dmg +if [ "$B_BUILDTYPE" == "Release" ]; then + info "Building Release disk image (dmg)" + "$DEPLOYQT" Barrier.app -dmg || exit 1 + 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" + "$DEPLOYQT" Barrier.app -use-debug-libs -no-strip || exit 1 + success "Bundle created successfully" +fi \ No newline at end of file From 8cd59ebee7f04706a42c2c7dfa684d2ecdb7ac98 Mon Sep 17 00:00:00 2001 From: Chris Simons Date: Sat, 2 May 2020 12:33:09 -0700 Subject: [PATCH 2/6] Use `build_dist.sh` in CMake instead of `build_installer.sh` Have CMake always build a bundle, the `build_dist.sh` script will only build a dmg if the build type is "Release" --- CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee0835ec..946fb265 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -400,12 +400,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") configure_files (${BARRIER_BUNDLE_SOURCE_DIR} ${BARRIER_BUNDLE_DIR}) - if (CMAKE_BUILD_TYPE STREQUAL "Release") - add_custom_target(Barrier_dmg ALL - bash build_installer.sh - DEPENDS barrier barriers barrierc - WORKING_DIRECTORY ${BARRIER_BUNDLE_DIR}) - endif() + add_custom_target(Barrier_dmg ALL + bash build_dist.sh + DEPENDS barrier barriers barrierc + WORKING_DIRECTORY ${BARRIER_BUNDLE_DIR}) endif() # From fb3eaa3e3cde0f448b2f7d2aaf5445accef2f56d Mon Sep 17 00:00:00 2001 From: Chris Simons Date: Sat, 2 May 2020 13:27:58 -0700 Subject: [PATCH 3/6] Add warnings for users manually running `build_installer.sh` and `reref_dylibs.sh` manually --- dist/macos/bundle/build_installer.sh.in | 5 +++++ dist/macos/bundle/reref_dylibs.sh | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/dist/macos/bundle/build_installer.sh.in b/dist/macos/bundle/build_installer.sh.in index e31f2a91..0d2ccfc7 100755 --- a/dist/macos/bundle/build_installer.sh.in +++ b/dist/macos/bundle/build_installer.sh.in @@ -1,5 +1,10 @@ #!/bin/sh +# add warning for users running manually +function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; } +warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated." +warn "Please use build_dist.sh instead to deploy using macdeployqt" + # change this to rename the installer package B_DMG="Barrier-@BARRIER_VERSION@.dmg" diff --git a/dist/macos/bundle/reref_dylibs.sh b/dist/macos/bundle/reref_dylibs.sh index c06c7410..029ca4ae 100755 --- a/dist/macos/bundle/reref_dylibs.sh +++ b/dist/macos/bundle/reref_dylibs.sh @@ -3,6 +3,12 @@ # $1 = binary (program or dylib) B_TARGET=$1 if [ "x$B_TARGET" = "x" ]; then + + # add warning for users running manually + function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; } + warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated." + warn "Please use build_dist.sh instead to deploy using macdeployqt" + echo Which binary needs to be re-referenced? exit 1 fi From e0051d17d89f25f88c65e1b7fa6e934e44166682 Mon Sep 17 00:00:00 2001 From: Chris Simons Date: Sat, 2 May 2020 13:58:22 -0700 Subject: [PATCH 4/6] Homebrew (Ruby) throws an error when it gets `SIGPIPE` from the `--max-count` on `grep`. --- dist/macos/bundle/build_dist.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/macos/bundle/build_dist.sh.in b/dist/macos/bundle/build_dist.sh.in index f9565d63..2bd73027 100755 --- a/dist/macos/bundle/build_dist.sh.in +++ b/dist/macos/bundle/build_dist.sh.in @@ -46,7 +46,7 @@ fi # Check for macdeployqt on Homebrew if which -s brew ; then info "Homebrew found, searching for macdeployqt" - DEPLOYQT="$(brew list qt | grep --only --max-count 1 '/.*macdeployqt')" + DEPLOYQT="$(brew list qt | grep --only '/.*macdeployqt' | head -1)" if [ ! -x "$DEPLOYQT" ]; then error Please install package qt exit 1 From 0deaaad2c978ef4ee5e20bace8112dc7bd811d67 Mon Sep 17 00:00:00 2001 From: Chris Simons Date: Mon, 4 May 2020 09:37:18 -0700 Subject: [PATCH 5/6] added barrierc and barriers to macdeployqt targets macdeployqt needs "-executable=filename" to propery change linking on other variables also renamed the cmake target from "Barrier_dmg" to "Barrier_MacOS" to properly reflect earlier changes --- CMakeLists.txt | 2 +- dist/macos/bundle/build_dist.sh.in | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 946fb265..fc8882e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -400,7 +400,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") configure_files (${BARRIER_BUNDLE_SOURCE_DIR} ${BARRIER_BUNDLE_DIR}) - add_custom_target(Barrier_dmg ALL + add_custom_target(Barrier_MacOS ALL bash build_dist.sh DEPENDS barrier barriers barrierc WORKING_DIRECTORY ${BARRIER_BUNDLE_DIR}) diff --git a/dist/macos/bundle/build_dist.sh.in b/dist/macos/bundle/build_dist.sh.in index 2bd73027..c96da790 100755 --- a/dist/macos/bundle/build_dist.sh.in +++ b/dist/macos/bundle/build_dist.sh.in @@ -10,6 +10,8 @@ B_MACOS="Barrier.app/Contents/MacOS" B_VERSION="@BARRIER_VERSION@" B_BINDIR="@CMAKE_RUNTIME_OUTPUT_DIRECTORY@" B_BUILDTYPE="@CMAKE_BUILD_TYPE@" +B_BARRIERC="Barrier.app/Contents/MacOS/barrierc" +B_BARRIERS="Barrier.app/Contents/MacOS/barriers" # Colorized output function info() { tput bold; echo "$@" ; tput sgr0 ;} @@ -56,12 +58,16 @@ fi # Use macdeployqt to include libraries and create dmg if [ "$B_BUILDTYPE" == "Release" ]; then info "Building Release disk image (dmg)" - "$DEPLOYQT" Barrier.app -dmg || exit 1 + "$DEPLOYQT" Barrier.app -dmg \ + -executable="$B_BARRIERC" \ + -executable="$B_BARRIERS" || exit 1 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" - "$DEPLOYQT" Barrier.app -use-debug-libs -no-strip || exit 1 + "$DEPLOYQT" Barrier.app -no-strip \ + -executable="$B_BARRIERC" \ + -executable="$B_BARRIERS" || exit 1 success "Bundle created successfully" fi \ No newline at end of file From b5c7eb45efd0aa363c06a60e31a834c231b3aeb6 Mon Sep 17 00:00:00 2001 From: Chris Simons Date: Tue, 5 May 2020 19:57:05 -0700 Subject: [PATCH 6/6] Change MacOS Build Steps The Azure Pipelines MacOS vmImage has an old version of OpenSSL (1.0.2t) installed at /usr/local/opt/openssl. Normally with Homebrew this directory would be linked to the currenly installed version of OpenSSL (1.1.x) in /usr/local/Cellar, but since it has been installed manually here it interferes with linking libssl.a and libcrypto.a static libraries which causes the build to fail. --- azure-pipelines.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bd773d33..e12cdd60 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -82,11 +82,16 @@ jobs: Release: B_BUILD_TYPE: Release BARRIER_VERSION_STAGE: Release + variables: + VERBOSE: 1 + TERM: xterm-256color steps: - - script: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aac86fc018c48d7b6f23a2e7535276899774567a/Formula/qt.rb - displayName: Installed Pinned Qt - - script: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aac86fc018c48d7b6f23a2e7535276899774567a/Formula/openssl.rb - displayName: Installed Pinned OpenSSL + - script: rm -rf /usr/local/opt/openssl + displayName: Remove incompatible OpenSSL 1.0.2t from macOS-10.14 vmImage + - script: brew reinstall openssl + displayName: Installed newer OpenSSL 1.1.x + - script: brew install pkg-config qt5 + displayName: Install Qt5 and pkg-config prereqs - script: sh -x ./clean_build.sh displayName: Clean Build - task: PublishBuildArtifacts@1