]> sigrok.org Git - sigrok-build.git/commitdiff
Add CI scripts and contrib files for the macOS build
authorFrank Stettner <redacted>
Tue, 11 Apr 2023 10:57:09 +0000 (12:57 +0200)
committerFrank Stettner <redacted>
Thu, 13 Apr 2023 15:47:15 +0000 (17:47 +0200)
12 files changed:
ci/macos/contrib-macos/Info-pulseview.plist [new file with mode: 0644]
ci/macos/contrib-macos/Info-pulseview.xslt [new file with mode: 0644]
ci/macos/contrib-macos/Info-sigrok-cli.plist [new file with mode: 0644]
ci/macos/contrib-macos/Info-sigrok-cli.xslt [new file with mode: 0644]
ci/macos/contrib-macos/Info-smuview.plist [new file with mode: 0644]
ci/macos/contrib-macos/Info-smuview.xslt [new file with mode: 0644]
ci/macos/contrib-macos/pulseview.icns [new file with mode: 0644]
ci/macos/contrib-macos/sigrok-cli.icns [new file with mode: 0644]
ci/macos/contrib-macos/smuview.icns [new file with mode: 0644]
ci/macos/sigrok-macos-build-dependencies.sh [new file with mode: 0755]
ci/macos/sigrok-macos-create-dmg.sh [new file with mode: 0755]
ci/macos/sigrok-macos-init-toolchain.sh [new file with mode: 0755]

diff --git a/ci/macos/contrib-macos/Info-pulseview.plist b/ci/macos/contrib-macos/Info-pulseview.plist
new file mode 100644 (file)
index 0000000..c595e6b
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+       <key>NSPrincipalClass</key>
+       <string>NSApplication</string>
+       <key>CFBundleIconFile</key>
+       <string>pulseview.icns</string>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleGetInfoString</key>
+       <string>PulseView is a Qt based logic analyzer, oscilloscope and MSO GUI for sigrok.</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleExecutable</key>
+       <string>pulseview</string>
+       <key>CFBundleIdentifier</key>
+       <string>org.sigrok.PulseView</string>
+</dict>
+</plist>
diff --git a/ci/macos/contrib-macos/Info-pulseview.xslt b/ci/macos/contrib-macos/Info-pulseview.xslt
new file mode 100644 (file)
index 0000000..1d8b23a
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+       <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no"/>
+
+       <xsl:template match="@*|node()">
+               <xsl:copy>
+                       <xsl:apply-templates select="@*|node()"/>
+               </xsl:copy>
+       </xsl:template>
+
+       <xsl:template match="string[preceding-sibling::key[1][text() = 'CFBundleVersion' or text() = 'CFBundleShortVersionString']]">
+               <string><xsl:value-of select="$VERSION" /></string>
+       </xsl:template>
+
+</xsl:stylesheet>
diff --git a/ci/macos/contrib-macos/Info-sigrok-cli.plist b/ci/macos/contrib-macos/Info-sigrok-cli.plist
new file mode 100644 (file)
index 0000000..8babac2
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+       <key>NSPrincipalClass</key>
+       <string>NSApplication</string>
+       <key>CFBundleIconFile</key>
+       <string>sigrok-cli.icns</string>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleGetInfoString</key>
+       <string>sigrok-cli is a command-line client for sigrok.</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleExecutable</key>
+       <string>sigrok-cli</string>
+       <key>CFBundleIdentifier</key>
+       <string>org.sigrok.sigrok-cli</string>
+</dict>
+</plist>
diff --git a/ci/macos/contrib-macos/Info-sigrok-cli.xslt b/ci/macos/contrib-macos/Info-sigrok-cli.xslt
new file mode 100644 (file)
index 0000000..1d8b23a
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+       <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no"/>
+
+       <xsl:template match="@*|node()">
+               <xsl:copy>
+                       <xsl:apply-templates select="@*|node()"/>
+               </xsl:copy>
+       </xsl:template>
+
+       <xsl:template match="string[preceding-sibling::key[1][text() = 'CFBundleVersion' or text() = 'CFBundleShortVersionString']]">
+               <string><xsl:value-of select="$VERSION" /></string>
+       </xsl:template>
+
+</xsl:stylesheet>
diff --git a/ci/macos/contrib-macos/Info-smuview.plist b/ci/macos/contrib-macos/Info-smuview.plist
new file mode 100644 (file)
index 0000000..572b26e
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleExecutable</key>
+       <string>smuview</string>
+       <key>CFBundleGetInfoString</key>
+       <string>SmuView is a Qt based source measure unit GUI for sigrok.</string>
+       <key>CFBundleIconFile</key>
+       <string>smuview.icns</string>
+       <key>CFBundleIdentifier</key>
+       <string>org.sigrok.SmuView</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>SmuView</string>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleShortVersionString</key>
+       <string>0.0.0</string>
+       <key>CFBundleVersion</key>
+       <string>0.0.0</string>
+       <key>CSResourcesFileMapped</key>
+       <true/>
+       <key>NSHighResolutionCapable</key>
+       <true/>
+</dict>
+</plist>
diff --git a/ci/macos/contrib-macos/Info-smuview.xslt b/ci/macos/contrib-macos/Info-smuview.xslt
new file mode 100644 (file)
index 0000000..1d8b23a
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+       <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no"/>
+
+       <xsl:template match="@*|node()">
+               <xsl:copy>
+                       <xsl:apply-templates select="@*|node()"/>
+               </xsl:copy>
+       </xsl:template>
+
+       <xsl:template match="string[preceding-sibling::key[1][text() = 'CFBundleVersion' or text() = 'CFBundleShortVersionString']]">
+               <string><xsl:value-of select="$VERSION" /></string>
+       </xsl:template>
+
+</xsl:stylesheet>
diff --git a/ci/macos/contrib-macos/pulseview.icns b/ci/macos/contrib-macos/pulseview.icns
new file mode 100644 (file)
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 (file)
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 (file)
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 (executable)
index 0000000..eabe773
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+##
+## This file is part of the sigrok-util project.
+##
+## Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2021-2023 Frank Stettner <frank-stettner@gmx.net>
+##
+## 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 <http://www.gnu.org/licenses/>.
+##
+
+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 (executable)
index 0000000..e6ece30
--- /dev/null
@@ -0,0 +1,125 @@
+#!/bin/sh
+##
+## This file is part of the sigrok-util project.
+##
+## Copyright (C) 2017 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2021-2023 Frank Stettner <frank-stettner@gmx.net>
+##
+## 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 <http://www.gnu.org/licenses/>.
+##
+
+# 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 (executable)
index 0000000..a1c665a
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+##
+## This file is part of the sigrok-util project.
+##
+## Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2021-2023 Frank Stettner <frank-stettner@gmx.net>
+##
+## 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 <http://www.gnu.org/licenses/>.
+##
+
+# 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"