From d42881ed11388a652482e1d7d7e5ebc471553877 Mon Sep 17 00:00:00 2001 From: Antoine Lambert Date: Mon, 27 May 2024 19:08:51 +0200 Subject: [PATCH] bundlers/mac: Add Qt6 support for building Talipot bundles --- .github/workflows/macos-homebrew-build.yml | 21 ++++++- bundlers/mac/mac_bundle.sh.in | 67 +++++++++++++++++----- 2 files changed, 71 insertions(+), 17 deletions(-) diff --git a/.github/workflows/macos-homebrew-build.yml b/.github/workflows/macos-homebrew-build.yml index 82895bc60a..de38201dc2 100644 --- a/.github/workflows/macos-homebrew-build.yml +++ b/.github/workflows/macos-homebrew-build.yml @@ -103,12 +103,29 @@ jobs: working-directory: ./build/install/bin run: ./talipot --check-application-starts --debug-plugins-load - name: Generate Talipot dmg bundle - if: matrix.config.os == 'macos-12' || matrix.config.os == 'macos-14' working-directory: ./build run: make bundle + - name: Check bundled Talipot can be installed and executed + working-directory: ./build + run: | + hdiutil attach Talipot*.dmg + cp /Volumes/Talipot*/Talipot*.app /Applications/ + sudo xattr -r -d com.apple.quarantine /Applications/Talipot*.app + /Applications/Talipot*.app/Contents/MacOS/Talipot \ + --check-application-starts \ + --debug-plugins-load + hdiutil detach /Volumes/Talipot* - name: Upload Talipot bundle to GitHub Actions artifacts - if: matrix.config.os == 'macos-12' || matrix.config.os == 'macos-14' uses: actions/upload-artifact@v4 with: name: Talipot-macOS-bundles-${{ matrix.config.os }} path: ./build/Talipot*.dmg + - name: Upload Talipot bundle to dev-latest prerelease + if: github.ref == 'refs/tags/dev-latest' + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + name: Talipot development build + prerelease: true + artifacts: ./build/Talipot*.dmg + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/bundlers/mac/mac_bundle.sh.in b/bundlers/mac/mac_bundle.sh.in index 6418332c6e..ff5a18d652 100755 --- a/bundlers/mac/mac_bundle.sh.in +++ b/bundlers/mac/mac_bundle.sh.in @@ -27,6 +27,9 @@ then QT_BINARY_DIR=@_qt5Gui_install_prefix@/bin fi +export PATH=${QT_BINARY_DIR}:${PATH} +export QT_VERSION=$(qmake -query QT_VERSION) + if [ ! -d ${TALIPOT_DIR} ] then echo "Error : the specified Talipot installation directory does not exist" @@ -71,31 +74,60 @@ cd "${DEST_DIR}/application" cp "${SRC_DIR}/../../LICENSE" . QT_LIB_DIR="@QT_QTCORE_LIBRARY@/.." +TALIPOT_APP=${DEST_DIR}/application/Talipot.app echo 'Copying Resources' -cd "${DEST_DIR}/application/Talipot.app/Contents/Frameworks/" +cd "${TALIPOT_APP}/Contents/Frameworks/" cp -r "${QT_LIB_DIR}/QtGui.framework/Resources/qt_menu.nib" ../Resources 2>/dev/null cp "@QT_QTCLUCENE_LIBRARY@" . 2>/dev/null -# use macdeployqt to configure exe & libraries cd .. # configure talipot mv bin/talipot MacOS/Talipot -# run macdeployqt with Talipot Python dynamic modules (not processed by macdeployqt as -# they are suffixed by .so instead of .dylib) -${QT_BINARY_DIR}/macdeployqt ${DEST_DIR}/application/Talipot.app \ - -executable=${DEST_DIR}/application/Talipot.app/Contents/lib/talipot/python/talipot/native/_talipot.so +# tell macdeployqt to also process Talipot Python dynamic module (not processed by default as +# its extension is .so instead of .dylib) +mac_deploy_qt_opts=-executable=${TALIPOT_APP}/Contents/lib/talipot/python/talipot/native/_talipot.so +if [ $(echo ${QT_VERSION} | cut -c1) -ge 6 ] +then + # qt plugins end up with broken rpaths when using macdeployt from Qt6 + # so we will copy them manually afterwards + mac_deploy_qt_opts+=" -no-plugins" +fi -# ensure libc++* are present in bundle -LIB_CXX_DIR="/opt/local/libexec/llvm-${CLANG_VERSION}/lib" +# use macdeployqt to copy and relink executable and libraries +${QT_BINARY_DIR}/macdeployqt ${TALIPOT_APP} $mac_deploy_qt_opts + +# ensure clang libc++* are present in bundle +LIB_CXX_DIR=$(echo "@CMAKE_SHARED_LINKER_FLAGS@" | cut -f1 -d" " | cut -c3-) if [ -d ${LIB_CXX_DIR} ] then - cp ${LIB_CXX_DIR}/libc++.1.dylib ${DEST_DIR}/application/Talipot.app/Contents/Frameworks/ - cp ${LIB_CXX_DIR}/libc++abi.1.dylib ${DEST_DIR}/application/Talipot.app/Contents/Frameworks/ + cp ${LIB_CXX_DIR}/libc++.1.dylib ${TALIPOT_APP}/Contents/Frameworks/ + cp ${LIB_CXX_DIR}/libc++abi.1.dylib ${TALIPOT_APP}/Contents/Frameworks/ +fi + +# also needed when compiled with homebrew clang +if [ -f ${LIB_CXX_DIR}/../libunwind.1.dylib ] +then + cp ${LIB_CXX_DIR}/../libunwind.1.dylib ${TALIPOT_APP}/Contents/Frameworks/ +fi + +# copy missing dependencies when using Qt6 +if [ $(qmake -query QT_VERSION | cut -c1) -ge 6 ] +then + mkdir ${TALIPOT_APP}/Contents/PlugIns + for plugins in iconengines imageformats networkinformation platforminputcontexts \ +platforms position styles tls + do + cp -r ${QT_BINARY_DIR}/../share/qt/plugins/${plugins} ${TALIPOT_APP}/Contents/PlugIns + done + for framework in QtSvg QtQuickWidgets + do + cp -r ${QT_BINARY_DIR}/../lib/${framework}.framework ${TALIPOT_APP}/Contents/Frameworks + done fi mv MacOS/Talipot bin/talipot # rename -mv ${DEST_DIR}/application/Talipot.app ${DEST_DIR}/application/${APP_NAME}-@TalipotVersion@.app +mv ${TALIPOT_APP} ${DEST_DIR}/application/${APP_NAME}-@TalipotVersion@.app # create launcher cat > MacOS/Talipot <