]> sigrok.org Git - sigrok-util.git/blame - cross-compile/macosx/create_dmg
sigrok-native-macosx: Fix an issue with recent boost versions.
[sigrok-util.git] / cross-compile / macosx / create_dmg
CommitLineData
5d2c0f55
UH
1#!/bin/sh
2##
3## This file is part of the sigrok-util project.
4##
5## Copyright (C) 2017 Uwe Hermann <uwe@hermann-uwe.de>
6##
7## This program is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; either version 2 of the License, or
10## (at your option) any later version.
11##
12## This program is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with this program; if not, see <http://www.gnu.org/licenses/>.
19##
20
21set -e
22
23# The path where the installed sigrok libraries/binaries are located.
24PREFIX=$HOME/sr_macosx
25
26# The path where to download files to and where to build packages.
27BUILDDIR=./build_app
28
20e302a2
UH
29# We use Qt 5.5 in order to remain compatible with more versions of Mac OS X.
30QTVER=qt@5.5
31
5d2c0f55 32# Path to Qt5 binaries.
20e302a2 33QTBINDIR=`brew list $QTVER | grep bin | head -n 1 | xargs dirname`
610b09fa 34QTTRANSLATIONSDIR=`brew --prefix $QTVER`/translations
5d2c0f55
UH
35
36# Path to boost libraries.
b1181fe1 37BOOSTLIBDIR=`brew list boost | grep libboost_system | grep -v cmake | head -n 1 | xargs dirname`
5d2c0f55
UH
38
39# Path to Python 3 framework.
40PYTHONFRAMEWORKDIR=`brew list python3 | grep Python.framework | head -n 1 | xargs dirname`/../../../..
41
c6ed5a3a 42PYVER="3.7"
5d2c0f55
UH
43
44# You usually don't need to change anything below this line.
45
46# -----------------------------------------------------------------------------
47
48# Remove build directory contents (if any) and create a new build dir.
49rm -rf $BUILDDIR
50mkdir $BUILDDIR
51cd $BUILDDIR
52
53APPNAME="PulseView"
54APPNAME_BINARY="pulseview"
40176503 55APPVER="NIGHTLY"
5d2c0f55
UH
56
57CONTENTSDIR="$APPNAME.app/Contents"
58MACOSDIR="$CONTENTSDIR/MacOS"
59FRAMEWORKSDIR="$CONTENTSDIR/Frameworks"
60SHARE_DIR="$CONTENTSDIR/share"
61PYDIR="$FRAMEWORKSDIR/Python.framework/Versions/$PYVER"
62
63mkdir -p $MACOSDIR $FRAMEWORKSDIR $SHARE_DIR
64
65cp $PREFIX/bin/$APPNAME_BINARY $MACOSDIR
66cp -R $PREFIX/share/libsigrokdecode $SHARE_DIR
67rm -rf $SHARE_DIR/libsigrokdecode/decoders/**/__pycache__
68rm -rf $SHARE_DIR/libsigrokdecode/decoders/common/**/__pycache__
69cp -R $PREFIX/share/sigrok-firmware $SHARE_DIR
70
71# Manually copy some boost libs that "macdeployqt" won't copy.
72cp $BOOSTLIBDIR/libboost_timer-mt.dylib $FRAMEWORKSDIR
73cp $BOOSTLIBDIR/libboost_chrono-mt.dylib $FRAMEWORKSDIR
74chmod 644 $FRAMEWORKSDIR/*boost*
75
610b09fa
UH
76# Manually copy translations ("macdeployqt" won't copy them).
77mkdir -p $CONTENTSDIR/translations
78for lang in "de"; do
79 cp $QTTRANSLATIONSDIR/qt_$lang.qm $CONTENTSDIR/translations
80 cp $QTTRANSLATIONSDIR/qtbase_$lang.qm $CONTENTSDIR/translations
81done
82
5d2c0f55
UH
83$QTBINDIR/macdeployqt $APPNAME.app
84
85# Copy Python framework and fix it up.
86cp -R $PYTHONFRAMEWORKDIR $FRAMEWORKSDIR
87chmod 644 $PYDIR/lib/libpython*.dylib
88rm -rf $PYDIR/Headers
89rm -rf $PYDIR/bin
90rm -rf $PYDIR/include
91rm -rf $PYDIR/share
92rm -rf $PYDIR/lib/pkgconfig
93rm -rf $PYDIR/lib/python$PYVER/lib2to3
94rm -rf $PYDIR/lib/python$PYVER/distutils
95rm -rf $PYDIR/lib/python$PYVER/idlelib
96rm -rf $PYDIR/lib/python$PYVER/test
97rm -rf $PYDIR/lib/python$PYVER/**/test
98rm -rf $PYDIR/lib/python$PYVER/tkinter
99rm -rf $PYDIR/lib/python$PYVER/turtledemo
100rm -rf $PYDIR/lib/python$PYVER/unittest
101rm -rf $PYDIR/lib/python$PYVER/__pycache__
102rm -rf $PYDIR/lib/python$PYVER/**/__pycache__
103rm -rf $PYDIR/lib/python$PYVER/**/**/__pycache__
104rm -rf $PYDIR/Resources
105install_name_tool -change \
d6503156 106 /usr/local/opt/python/Frameworks/Python.framework/Versions/$PYVER/Python \
5d2c0f55
UH
107 @executable_path/../Frameworks/Python.framework/Versions/$PYVER/Python \
108 $FRAMEWORKSDIR/libsigrokdecode.*.dylib
109
ffbad165 110# Add PulseView wrapper (sets PYTHONHOME/SIGROK_FIRMWARE_DIR/SIGROKDECODE_DIR).
5d2c0f55
UH
111mv $MACOSDIR/$APPNAME_BINARY $MACOSDIR/$APPNAME_BINARY.real
112cp ../contrib/pulseview $MACOSDIR
113chmod 755 $MACOSDIR/$APPNAME_BINARY
114
115cp ../contrib/Info.plist $CONTENTSDIR
116cp ../contrib/pulseview.icns $CONTENTSDIR/Resources
117
40176503 118hdiutil create "${APPNAME}-${APPVER}.dmg" -volname "$APPNAME $APPVER" \
5d2c0f55 119 -fs HFS+ -srcfolder "$APPNAME.app"