-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest.sh
executable file
·106 lines (81 loc) · 3.21 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
set -e
set -x
if [ "$ARCH" == "" ]; then
echo 'Error: $ARCH is not set'
exit 1
fi
TARGET="$1"
if [ "$TARGET" == "" ]; then
echo 'Error: $TARGET is not set'
exit 1
fi
# use RAM disk if possible
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
TEMP_BASE=/dev/shm
else
TEMP_BASE=/tmp
fi
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" linuxdeploy-plugin-qt-build-XXXXXX)
cleanup () {
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
}
trap cleanup EXIT
wget -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-"$ARCH".AppImage
export LINUXDEPLOY_BIN="$PWD"/linuxdeploy-"$ARCH".AppImage
chmod +x "$LINUXDEPLOY_BIN"
pushd "$BUILD_DIR"
git clone --depth=1 https://github.com/linuxdeploy/linuxdeploy-plugin-qt-examples.git
source /opt/qt5*/bin/qt5*-env.sh || echo "" # hack required, the script returns 1 for some reason
qt5_ver=$(echo "$QT_BASE_DIR" | cut -d/ -f3 | cut -d5 -f2-)
mkdir -p "$HOME"/.config/qtchooser
echo "${QTDIR}/bin" > "$HOME"/.config/qtchooser/qt5."$qt5_ver".conf
echo "${QTDIR}/lib" >> "$HOME"/.config/qtchooser/qt5."$qt5_ver".conf
export CMAKE_PREFIX_PATH="$QTDIR"/lib/cmake
export QT_SELECT=qt5."$qt5_ver"
## Build projects
pushd linuxdeploy-plugin-qt-examples/QtQuickControls2Application
# This env variable is used by the qt plugin to search the qml sources in other paths than the AppDir
# it's mandatory to use when your qml files are embed as Qt resources into the main binary.
export QML_SOURCES_PATHS="$PWD"/src
mkdir build
pushd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr || exit 1
DESTDIR="$PWD"/AppDir make install || exit 1
"$LINUXDEPLOY_BIN" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
mv -v *AppImage "$BUILD_DIR" || exit 1
popd
popd
pushd linuxdeploy-plugin-qt-examples/QtWebEngineApplication
export QML_SOURCES_PATHS="$PWD"
mkdir build
pushd build
qmake CONFIG+=release PREFIX=/usr ../QtWebEngineApplication.pro || exit 1
INSTALL_ROOT="$PWD"/AppDir make install || exit 1
# Include libnss related files
mkdir -p "$PWD"/AppDir/usr/lib/
cp -r /usr/lib/x86_64-linux-gnu/nss "$PWD"/AppDir/usr/lib/
"$LINUXDEPLOY_BIN" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
mv -v *AppImage "$BUILD_DIR" || exit 1
popd
popd
pushd linuxdeploy-plugin-qt-examples/QtWidgetsApplication
mkdir build
pushd build
qmake CONFIG+=release PREFIX=/usr ../QtWidgetsApplication.pro || exit 1
INSTALL_ROOT="$PWD"/AppDir make install || exit 1
"$LINUXDEPLOY_BIN" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
mv -v *AppImage "$BUILD_DIR" || exit 1
popd
mkdir build-platforms
pushd build-platforms
export PLATFORM_PLUGINS="libqoffscreen.so;libqxcb.so"
qmake CONFIG+=release PREFIX=/usr ../QtWidgetsApplication.pro || exit 1
INSTALL_ROOT="$PWD"/AppDir make install || exit 1
"$LINUXDEPLOY_BIN" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
APPIMAGE=(*AppImage)
mv -v "${APPIMAGE[0]}" "$BUILD_DIR/offscreen-${APPIMAGE[0]}" || exit 1
popd
popd