From: Frank Stettner Date: Tue, 11 Apr 2023 10:57:09 +0000 (+0200) Subject: Add CI scripts and contrib files for the macOS build X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6734b688261d6e15db656bd1a0898147dcb51dde;p=sigrok-build.git Add CI scripts and contrib files for the macOS build --- diff --git a/ci/macos/contrib-macos/Info-pulseview.plist b/ci/macos/contrib-macos/Info-pulseview.plist new file mode 100644 index 0000000..c595e6b --- /dev/null +++ b/ci/macos/contrib-macos/Info-pulseview.plist @@ -0,0 +1,20 @@ + + + + + NSPrincipalClass + NSApplication + CFBundleIconFile + pulseview.icns + CFBundlePackageType + APPL + CFBundleGetInfoString + PulseView is a Qt based logic analyzer, oscilloscope and MSO GUI for sigrok. + CFBundleSignature + ???? + CFBundleExecutable + pulseview + CFBundleIdentifier + org.sigrok.PulseView + + diff --git a/ci/macos/contrib-macos/Info-pulseview.xslt b/ci/macos/contrib-macos/Info-pulseview.xslt new file mode 100644 index 0000000..1d8b23a --- /dev/null +++ b/ci/macos/contrib-macos/Info-pulseview.xslt @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/ci/macos/contrib-macos/Info-sigrok-cli.plist b/ci/macos/contrib-macos/Info-sigrok-cli.plist new file mode 100644 index 0000000..8babac2 --- /dev/null +++ b/ci/macos/contrib-macos/Info-sigrok-cli.plist @@ -0,0 +1,20 @@ + + + + + NSPrincipalClass + NSApplication + CFBundleIconFile + sigrok-cli.icns + CFBundlePackageType + APPL + CFBundleGetInfoString + sigrok-cli is a command-line client for sigrok. + CFBundleSignature + ???? + CFBundleExecutable + sigrok-cli + CFBundleIdentifier + org.sigrok.sigrok-cli + + diff --git a/ci/macos/contrib-macos/Info-sigrok-cli.xslt b/ci/macos/contrib-macos/Info-sigrok-cli.xslt new file mode 100644 index 0000000..1d8b23a --- /dev/null +++ b/ci/macos/contrib-macos/Info-sigrok-cli.xslt @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/ci/macos/contrib-macos/Info-smuview.plist b/ci/macos/contrib-macos/Info-smuview.plist new file mode 100644 index 0000000..572b26e --- /dev/null +++ b/ci/macos/contrib-macos/Info-smuview.plist @@ -0,0 +1,28 @@ + + + + + CFBundleExecutable + smuview + CFBundleGetInfoString + SmuView is a Qt based source measure unit GUI for sigrok. + CFBundleIconFile + smuview.icns + CFBundleIdentifier + org.sigrok.SmuView + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + SmuView + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.0 + CFBundleVersion + 0.0.0 + CSResourcesFileMapped + + NSHighResolutionCapable + + + diff --git a/ci/macos/contrib-macos/Info-smuview.xslt b/ci/macos/contrib-macos/Info-smuview.xslt new file mode 100644 index 0000000..1d8b23a --- /dev/null +++ b/ci/macos/contrib-macos/Info-smuview.xslt @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/ci/macos/contrib-macos/pulseview.icns b/ci/macos/contrib-macos/pulseview.icns new file mode 100644 index 0000000..a569ce7 Binary files /dev/null and b/ci/macos/contrib-macos/pulseview.icns differ diff --git a/ci/macos/contrib-macos/sigrok-cli.icns b/ci/macos/contrib-macos/sigrok-cli.icns new file mode 100644 index 0000000..a569ce7 Binary files /dev/null and b/ci/macos/contrib-macos/sigrok-cli.icns differ diff --git a/ci/macos/contrib-macos/smuview.icns b/ci/macos/contrib-macos/smuview.icns new file mode 100644 index 0000000..a569ce7 Binary files /dev/null and b/ci/macos/contrib-macos/smuview.icns differ diff --git a/ci/macos/sigrok-macos-build-dependencies.sh b/ci/macos/sigrok-macos-build-dependencies.sh new file mode 100755 index 0000000..eabe773 --- /dev/null +++ b/ci/macos/sigrok-macos-build-dependencies.sh @@ -0,0 +1,79 @@ +#!/bin/sh +## +## This file is part of the sigrok-util project. +## +## Copyright (C) 2015 Uwe Hermann +## Copyright (C) 2021-2023 Frank Stettner +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . +## + +set -e + +mkdir -p $INSTALL_DIR + +BUILD_DIR=./build +mkdir $BUILD_DIR +cd $BUILD_DIR + +# libserialport +$GIT_CLONE $LIBSERIALPORT_REPO libserialport +cd libserialport +./autogen.sh +./configure $C +make $PARALLEL $V +make install $V +cd .. + +# libsigrok +$GIT_CLONE -b ${LIBSIGROK_BRANCH:-master} $LIBSIGROK_REPO libsigrok +cd libsigrok +./autogen.sh +PKG_CONFIG_PATH=$P ./configure $C +make $PARALLEL $V +make install $V +cd .. +# +# libsigrokdecode +$GIT_CLONE $LIBSIGROKDECODE_REPO libsigrokdecode +cd libsigrokdecode +./autogen.sh +PKG_CONFIG_PATH=$P ./configure $C +make $PARALLEL $V +make install $V +cd .. + +# sigrok-firmware +$GIT_CLONE $SIGROK_FIRMWARE_REPO sigrok-firmware +cd sigrok-firmware +./autogen.sh +PKG_CONFIG_PATH=$P ./configure $C +make install $V +cd .. + +# sigrok-firmware-fx2lafw +$GIT_CLONE $SIGROK_FIRMWARE_FX2LAFW_REPO sigrok-firmware-fx2lafw +cd sigrok-firmware-fx2lafw +./autogen.sh +PKG_CONFIG_PATH=$P ./configure $C +make $PARALLEL $V +make install $V +cd .. + +# sigrok-dumps (not needed for the macOS DMG build) +# $GIT_CLONE $SIGROK_DUMPS_REPO sigrok-dumps +# cd sigrok-dumps +# make install $V +# cd .. + diff --git a/ci/macos/sigrok-macos-create-dmg.sh b/ci/macos/sigrok-macos-create-dmg.sh new file mode 100755 index 0000000..e6ece30 --- /dev/null +++ b/ci/macos/sigrok-macos-create-dmg.sh @@ -0,0 +1,125 @@ +#!/bin/sh +## +## This file is part of the sigrok-util project. +## +## Copyright (C) 2017 Uwe Hermann +## Copyright (C) 2021-2023 Frank Stettner +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . +## + +# NOTE: $TARGET, $BREW_QT_VERSION, $BREW_PYTHON_VERSION, $ARTIFACT_* are defined +# as environment variables in the github workflow yml + +set -e +set -x + +# Path to Qt5 binaries +QT_BIN_DIR=$(brew list "$BREW_QT_VERSION" | grep bin | head -n 1 | xargs dirname) +QT_TRANSLATIONS_DIR=$(brew --prefix "$BREW_QT_VERSION")/translations + +# Path to Python 3 framework +PYTHON_FRAMEWORK_DIR=$(brew list "$BREW_PYTHON_VERSION" | grep Python.framework/Python | head -n 1 | xargs dirname) +PYTHON_PREFIX_DIR=$(brew --prefix "$BREW_PYTHON_VERSION") + +# Get Python version +PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[0:2])))') + +DMG_BUILD_DIR=./build_dmg +mkdir $DMG_BUILD_DIR +cd $DMG_BUILD_DIR + +CONTENTS_DIR="$ARTIFACT_TITLE.app/Contents" +MACOS_DIR="$CONTENTS_DIR/MacOS" +FRAMEWORKS_DIR="$CONTENTS_DIR/Frameworks" +SHARE_DIR="$CONTENTS_DIR/share" +PYTHON_DIR="$FRAMEWORKS_DIR/Python.framework/Versions/$PYTHON_VERSION" + +mkdir -p $MACOS_DIR $FRAMEWORKS_DIR $SHARE_DIR + +# Copy executable +cp "$INSTALL_DIR"/bin/$ARTIFACT_BIN_NAME $MACOS_DIR +# Copy and cleanup decoders +cp -R "$INSTALL_DIR"/share/libsigrokdecode $SHARE_DIR +rm -rf $SHARE_DIR/libsigrokdecode/decoders/**/__pycache__ +rm -rf $SHARE_DIR/libsigrokdecode/decoders/common/**/__pycache__ +# Copy firmware +cp -R "$INSTALL_DIR"/share/sigrok-firmware $SHARE_DIR + +if [ "$ARTIFACT_BIN_NAME" = "pulseview" ]; then + # Copy translations ("macdeployqt" won't copy them). + mkdir -p $CONTENTS_DIR/translations + cp "$QT_TRANSLATIONS_DIR"/qt_*.qm $CONTENTS_DIR/translations + cp "$QT_TRANSLATIONS_DIR"/qtbase_*.qm $CONTENTS_DIR/translations + + # Copy some boost libs that "macdeployqt" won't copy. + # cp $BOOSTLIBDIR/libboost_timer-mt.dylib $FRAMEWORKS_DIR + # cp $BOOSTLIBDIR/libboost_chrono-mt.dylib $FRAMEWORKS_DIR + # chmod 644 $FRAMEWORKS_DIR/*boost* +fi + +"$QT_BIN_DIR"/macdeployqt $ARTIFACT_TITLE.app + +# Copy Python framework and fix it up. +cp -R "$PYTHON_FRAMEWORK_DIR" $FRAMEWORKS_DIR +chmod 644 "$PYTHON_DIR"/lib/libpython*.dylib +rm -rf "$PYTHON_DIR"/Headers +rm -rf "$PYTHON_DIR"/bin +rm -rf "$PYTHON_DIR"/include +rm -rf "$PYTHON_DIR"/share +rm -rf "$PYTHON_DIR"/lib/pkgconfig +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/lib2to3 +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/distutils +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/idlelib +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/test +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/**/test +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/tkinter +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/turtledemo +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/unittest +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/__pycache__ +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/**/__pycache__ +rm -rf "$PYTHON_DIR"/lib/python$PYTHON_VERSION/**/**/__pycache__ +rm -rf "$PYTHON_DIR"/Resources + +# Replace paths +install_name_tool -change \ + "$PYTHON_PREFIX_DIR"/Frameworks/Python.framework/Versions/$PYTHON_VERSION/Python \ + @executable_path/../Frameworks/Python.framework/Versions/$PYTHON_VERSION/Python \ + $FRAMEWORKS_DIR/libsigrokdecode.*.dylib + +# Add wrapper for executable (sets PYTHONHOME/SIGROK_FIRMWARE_DIR/SIGROKDECODE_DIR). +mv $MACOS_DIR/$ARTIFACT_BIN_NAME $MACOS_DIR/$ARTIFACT_BIN_NAME.real +cat > $MACOS_DIR/$ARTIFACT_BIN_NAME << EOF +#!/bin/sh + +DIR="\$(dirname "\$0")" +cd "\$DIR" +export PYTHONHOME="../Frameworks/Python.framework/Versions/$PYTHON_VERSION" +export SIGROK_FIRMWARE_DIR="../share/sigrok-firmware" +export SIGROKDECODE_DIR="../share/libsigrokdecode/decoders" +exec ./$ARTIFACT_BIN_NAME.real "\$@" +EOF +chmod 755 $MACOS_DIR/$ARTIFACT_BIN_NAME + +xsltproc --stringparam VERSION "${ARTIFACT_VERSION}" -o $CONTENTS_DIR/Info.plist \ + ../contrib-macos/Info-${ARTIFACT_BIN_NAME}.xslt ../contrib-macos/Info-${ARTIFACT_BIN_NAME}.plist +cp ../contrib-macos/${ARTIFACT_BIN_NAME}.icns $CONTENTS_DIR/Resources + +hdiutil create "${ARTIFACT_TITLE}-${ARTIFACT_VERSION}-${TARGET}.dmg" \ + -volname "$ARTIFACT_TITLE $ARTIFACT_VERSION" \ + -fs HFS+ -srcfolder "$ARTIFACT_TITLE.app" + +# Move DMG to parent directory, so it is accessible without knowing $DMG_BUILD_DIR +mv "${ARTIFACT_TITLE}-${ARTIFACT_VERSION}-${TARGET}.dmg" .. + diff --git a/ci/macos/sigrok-macos-init-toolchain.sh b/ci/macos/sigrok-macos-init-toolchain.sh new file mode 100755 index 0000000..a1c665a --- /dev/null +++ b/ci/macos/sigrok-macos-init-toolchain.sh @@ -0,0 +1,42 @@ +#!/bin/sh +## +## This file is part of the sigrok-util project. +## +## Copyright (C) 2015 Uwe Hermann +## Copyright (C) 2021-2023 Frank Stettner +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . +## + +# NOTE: $BREW_QT_VERSION and $BREW_PYTHON_VERSION are defined as environment variables of the +# github workflow + +set -e + +export PARALLEL="-j $(sysctl -n hw.ncpu)" + +# Path to the binaries installed by homebrew (needed for cmake to find the Qt5 +# and Python libs). +export PATH="$(brew --prefix "$BREW_PYTHON_VERSION")/bin:$(brew --prefix "$BREW_QT_VERSION")/bin:$PATH" + +# PKG_CONFIG_PATH will need to point to pkg-config files of Homebrew's +# keg-only formulae. +P="$INSTALL_DIR/lib/pkgconfig" +for FORMULA in libffi "$BREW_PYTHON_VERSION" "$BREW_QT_VERSION"; do + P=$(brew --prefix "$FORMULA")/lib/pkgconfig:"$P" +done +export P + +# Extra options to pass to configure. +export C="$C --prefix=$INSTALL_DIR"