]> sigrok.org Git - sigrok-util.git/blame - cross-compile/macosx/create_dmg
sigrok-fwextract-kingst-la2016: concentrate RCC flags in one spot
[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##
5872b25f 5## Copyright (C) 2017-2020 Uwe Hermann <uwe@hermann-uwe.de>
5d2c0f55
UH
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
5872b25f
UH
26if [ "x$1" = "xsigrok-cli" ]; then
27 APPNAME="sigrok-cli"
28 APPNAME_BINARY="sigrok-cli"
29else
30 APPNAME="PulseView"
31 APPNAME_BINARY="pulseview"
32fi
33
5d2c0f55 34# The path where to download files to and where to build packages.
5872b25f 35BUILDDIR=./build_app_$APPNAME_BINARY
5d2c0f55 36
20e302a2
UH
37# We use Qt 5.5 in order to remain compatible with more versions of Mac OS X.
38QTVER=qt@5.5
39
5d2c0f55 40# Path to Qt5 binaries.
20e302a2 41QTBINDIR=`brew list $QTVER | grep bin | head -n 1 | xargs dirname`
610b09fa 42QTTRANSLATIONSDIR=`brew --prefix $QTVER`/translations
5d2c0f55
UH
43
44# Path to boost libraries.
b1181fe1 45BOOSTLIBDIR=`brew list boost | grep libboost_system | grep -v cmake | head -n 1 | xargs dirname`
5d2c0f55
UH
46
47# Path to Python 3 framework.
db6a2f15 48PYTHONFRAMEWORKDIR=`brew list python3 | grep libpython | head -n 1 | xargs dirname`/../../../..
5d2c0f55 49
c6ed5a3a 50PYVER="3.7"
5d2c0f55
UH
51
52# You usually don't need to change anything below this line.
53
54# -----------------------------------------------------------------------------
55
56# Remove build directory contents (if any) and create a new build dir.
57rm -rf $BUILDDIR
58mkdir $BUILDDIR
59cd $BUILDDIR
60
40176503 61APPVER="NIGHTLY"
5d2c0f55
UH
62
63CONTENTSDIR="$APPNAME.app/Contents"
64MACOSDIR="$CONTENTSDIR/MacOS"
65FRAMEWORKSDIR="$CONTENTSDIR/Frameworks"
66SHARE_DIR="$CONTENTSDIR/share"
67PYDIR="$FRAMEWORKSDIR/Python.framework/Versions/$PYVER"
68
69mkdir -p $MACOSDIR $FRAMEWORKSDIR $SHARE_DIR
70
71cp $PREFIX/bin/$APPNAME_BINARY $MACOSDIR
daa83fda 72# Implementation detail: Shared libraries are handled below.
5d2c0f55
UH
73cp -R $PREFIX/share/libsigrokdecode $SHARE_DIR
74rm -rf $SHARE_DIR/libsigrokdecode/decoders/**/__pycache__
75rm -rf $SHARE_DIR/libsigrokdecode/decoders/common/**/__pycache__
76cp -R $PREFIX/share/sigrok-firmware $SHARE_DIR
77
f2904ee5 78if [ "x$APPNAME_BINARY" = "xpulseview" ]; then
5872b25f
UH
79 # Manually copy some boost libs that "macdeployqt" won't copy.
80 cp $BOOSTLIBDIR/libboost_timer-mt.dylib $FRAMEWORKSDIR
81 cp $BOOSTLIBDIR/libboost_chrono-mt.dylib $FRAMEWORKSDIR
82 chmod 644 $FRAMEWORKSDIR/*boost*
daa83fda 83
5872b25f
UH
84 # Manually copy translations ("macdeployqt" won't copy them).
85 mkdir -p $CONTENTSDIR/translations
6e6c47d0
UH
86 cp $QTTRANSLATIONSDIR/qt_*.qm $CONTENTSDIR/translations
87 cp $QTTRANSLATIONSDIR/qtbase_*.qm $CONTENTSDIR/translations
5872b25f 88fi
610b09fa 89
5d2c0f55
UH
90$QTBINDIR/macdeployqt $APPNAME.app
91
92# Copy Python framework and fix it up.
93cp -R $PYTHONFRAMEWORKDIR $FRAMEWORKSDIR
94chmod 644 $PYDIR/lib/libpython*.dylib
95rm -rf $PYDIR/Headers
96rm -rf $PYDIR/bin
97rm -rf $PYDIR/include
98rm -rf $PYDIR/share
99rm -rf $PYDIR/lib/pkgconfig
100rm -rf $PYDIR/lib/python$PYVER/lib2to3
101rm -rf $PYDIR/lib/python$PYVER/distutils
102rm -rf $PYDIR/lib/python$PYVER/idlelib
103rm -rf $PYDIR/lib/python$PYVER/test
104rm -rf $PYDIR/lib/python$PYVER/**/test
105rm -rf $PYDIR/lib/python$PYVER/tkinter
106rm -rf $PYDIR/lib/python$PYVER/turtledemo
107rm -rf $PYDIR/lib/python$PYVER/unittest
108rm -rf $PYDIR/lib/python$PYVER/__pycache__
109rm -rf $PYDIR/lib/python$PYVER/**/__pycache__
110rm -rf $PYDIR/lib/python$PYVER/**/**/__pycache__
111rm -rf $PYDIR/Resources
112install_name_tool -change \
d6503156 113 /usr/local/opt/python/Frameworks/Python.framework/Versions/$PYVER/Python \
5d2c0f55
UH
114 @executable_path/../Frameworks/Python.framework/Versions/$PYVER/Python \
115 $FRAMEWORKSDIR/libsigrokdecode.*.dylib
daa83fda
GS
116install_name_tool -change \
117 /usr/local/opt/python/Frameworks/Python.framework/Versions/$PYVER/Python \
118 @executable_path/../Frameworks/Python.framework/Versions/$PYVER/Python \
04cb58f8 119 $PREFIX/lib/libirmp.*.dylib
5d2c0f55 120
5872b25f 121# Add wrapper (sets PYTHONHOME/SIGROK_FIRMWARE_DIR/SIGROKDECODE_DIR).
5d2c0f55 122mv $MACOSDIR/$APPNAME_BINARY $MACOSDIR/$APPNAME_BINARY.real
5872b25f 123cp ../contrib/$APPNAME_BINARY $MACOSDIR
5d2c0f55
UH
124chmod 755 $MACOSDIR/$APPNAME_BINARY
125
5872b25f
UH
126cp ../contrib/Info.plist_$APPNAME_BINARY $CONTENTSDIR/Info.plist
127cp ../contrib/$APPNAME_BINARY.icns $CONTENTSDIR/Resources
5d2c0f55 128
40176503 129hdiutil create "${APPNAME}-${APPVER}.dmg" -volname "$APPNAME $APPVER" \
5d2c0f55 130 -fs HFS+ -srcfolder "$APPNAME.app"