From 7e6b4e79411d83954ccc81f13c23cdaa5bad329e Mon Sep 17 00:00:00 2001 From: Manuel Pietschmann Date: Mon, 24 Jul 2023 13:56:57 +0200 Subject: [PATCH] Add macOS build script (Intel / x86_64) The script compiles the plugin with CMake and adjusts the framework loading paths. --- BUILDING.md | 10 ++++++++-- build-macos.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 build-macos.sh diff --git a/BUILDING.md b/BUILDING.md index 7ba2cba6a9..ebdd328077 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -79,7 +79,10 @@ After compilation the plugin can be found in the build directory: `de_rest_plugi ### macOS +Currently only supported on Intel Macs (x86_64). + Install dependencies via Homebrew. + ``` brew install qt@5 ninja cmake ``` @@ -94,11 +97,14 @@ brew install qt@5 ninja cmake 4. Compile the plugin with CMake - cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 -G Ninja -B build . - cmake --build build + ./build-macos.sh After compilation the plugin can be found in the build directory: `de_rest_plugin.dylib` +5. Copy the plugin to the app bundle + + cp build/de_rest_plugin.dylib /Applications/deCONZ.app/Contents/Plugins + ## Build with QMake **Important:** Building via QMake is deprecated and will be removed in future. diff --git a/build-macos.sh b/build-macos.sh new file mode 100755 index 0000000000..293d201314 --- /dev/null +++ b/build-macos.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh + +# Helper script to build libde_rest_plugin.dylib +# that can be copied into deCONZ.app/Contents/Plugins. + +MACHINE=$(uname -m) +QTLOC=/usr/local/opt/qt@5 + +if [[ "$MACHINE" != "x86_64" ]]; then + echo "building currently only supported on x86_64" + exit 1 +fi + +if [ ! -d "$QTLOC" ]; then + echo "Homebrew (x86_64) or Qt5 not installed in $QTLOC" + exit 1 +fi + +rm -fr build + +cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$QTLOC -G Ninja -B build . +cmake --build build + +pushd build + +for i in `otool -L libde_rest_plugin.dylib | grep /opt/qt | cut -f1 -d' '` +do + # fixup framework paths + # /usr/local/opt/qt@5/lib/ QtWidgets.framework/Versions/5/QtWidgets + # @executable_path/../Frameworks/ QtWidgets.framework/Versions/5/QtWidgets + newpath=`echo $i | awk '{gsub(/.*qt.*\/lib/,"@executable_path/../Frameworks");}1'` + install_name_tool -change $i $newpath libde_rest_plugin.dylib +done + +popd