]> sigrok.org Git - sigrok-util.git/blame - cross-compile/macosx/create_dmg
sigrok-cross-android: Bump VER_SIGROK_FIRMWARE_FX2LAFW to 0.1.6.
[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
29# Path to Qt5 binaries.
30QTBINDIR=`brew list qt5 | grep bin | head -n 1 | xargs dirname`
31
32# Path to boost libraries.
33BOOSTLIBDIR=`brew list boost | grep libboost_system | head -n 1 | xargs dirname`
34
35# Path to Python 3 framework.
36PYTHONFRAMEWORKDIR=`brew list python3 | grep Python.framework | head -n 1 | xargs dirname`/../../../..
37
38PYVER="3.6"
39
40# You usually don't need to change anything below this line.
41
42# -----------------------------------------------------------------------------
43
44# Remove build directory contents (if any) and create a new build dir.
45rm -rf $BUILDDIR
46mkdir $BUILDDIR
47cd $BUILDDIR
48
49APPNAME="PulseView"
50APPNAME_BINARY="pulseview"
51APPVER="nightly"
52
53CONTENTSDIR="$APPNAME.app/Contents"
54MACOSDIR="$CONTENTSDIR/MacOS"
55FRAMEWORKSDIR="$CONTENTSDIR/Frameworks"
56SHARE_DIR="$CONTENTSDIR/share"
57PYDIR="$FRAMEWORKSDIR/Python.framework/Versions/$PYVER"
58
59mkdir -p $MACOSDIR $FRAMEWORKSDIR $SHARE_DIR
60
61cp $PREFIX/bin/$APPNAME_BINARY $MACOSDIR
62cp -R $PREFIX/share/libsigrokdecode $SHARE_DIR
63rm -rf $SHARE_DIR/libsigrokdecode/decoders/**/__pycache__
64rm -rf $SHARE_DIR/libsigrokdecode/decoders/common/**/__pycache__
65cp -R $PREFIX/share/sigrok-firmware $SHARE_DIR
66
67# Manually copy some boost libs that "macdeployqt" won't copy.
68cp $BOOSTLIBDIR/libboost_timer-mt.dylib $FRAMEWORKSDIR
69cp $BOOSTLIBDIR/libboost_chrono-mt.dylib $FRAMEWORKSDIR
70chmod 644 $FRAMEWORKSDIR/*boost*
71
72$QTBINDIR/macdeployqt $APPNAME.app
73
74# Copy Python framework and fix it up.
75cp -R $PYTHONFRAMEWORKDIR $FRAMEWORKSDIR
76chmod 644 $PYDIR/lib/libpython*.dylib
77rm -rf $PYDIR/Headers
78rm -rf $PYDIR/bin
79rm -rf $PYDIR/include
80rm -rf $PYDIR/share
81rm -rf $PYDIR/lib/pkgconfig
82rm -rf $PYDIR/lib/python$PYVER/lib2to3
83rm -rf $PYDIR/lib/python$PYVER/distutils
84rm -rf $PYDIR/lib/python$PYVER/idlelib
85rm -rf $PYDIR/lib/python$PYVER/test
86rm -rf $PYDIR/lib/python$PYVER/**/test
87rm -rf $PYDIR/lib/python$PYVER/tkinter
88rm -rf $PYDIR/lib/python$PYVER/turtledemo
89rm -rf $PYDIR/lib/python$PYVER/unittest
90rm -rf $PYDIR/lib/python$PYVER/__pycache__
91rm -rf $PYDIR/lib/python$PYVER/**/__pycache__
92rm -rf $PYDIR/lib/python$PYVER/**/**/__pycache__
93rm -rf $PYDIR/Resources
94install_name_tool -change \
95 /usr/local/opt/python3/Frameworks/Python.framework/Versions/$PYVER/Python \
96 @executable_path/../Frameworks/Python.framework/Versions/$PYVER/Python \
97 $FRAMEWORKSDIR/libsigrokdecode.*.dylib
98
ffbad165 99# Add PulseView wrapper (sets PYTHONHOME/SIGROK_FIRMWARE_DIR/SIGROKDECODE_DIR).
5d2c0f55
UH
100mv $MACOSDIR/$APPNAME_BINARY $MACOSDIR/$APPNAME_BINARY.real
101cp ../contrib/pulseview $MACOSDIR
102chmod 755 $MACOSDIR/$APPNAME_BINARY
103
104cp ../contrib/Info.plist $CONTENTSDIR
105cp ../contrib/pulseview.icns $CONTENTSDIR/Resources
106
107hdiutil create "${APPNAME}_${APPVER}.dmg" -volname "$APPNAME $APPVER" \
108 -fs HFS+ -srcfolder "$APPNAME.app"