-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqtCC_host.sh
executable file
·208 lines (179 loc) · 6.19 KB
/
qtCC_host.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env bash
#################################################################################
# Cross compilation of Qt for the Raspberry Pi, using official source tarball #
# - Host script #
#################################################################################
set -eu
### Directories
RPIDEV_ROOT=~/raspi # Select root directory (moving this post-build/install will brake qmake for cross-compiling)
RPIDEV_TOOLS=${RPIDEV_ROOT}/tools
RPIDEV_TAR=${RPIDEV_ROOT}/tar
RPIDEV_SRC=${RPIDEV_ROOT}/src
RPIDEV_BUILD=${RPIDEV_ROOT}/build
RPIDEV_INSTALL=${RPIDEV_ROOT}/install
RPIDEV_SYSROOT=${RPIDEV_ROOT}/sysroot
RPIDEV_JOBS=$(grep -c "^processor" /proc/cpuinfo)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RUN_DIR=$(pwd)
### Target device
RPIDEV_DEVICE_VERSION=pi3 # pi1 pi2 pi3 (only tested pi3)
RPIDEV_DEVICE_ADDRESS=192.168.XXX.XX # ip of device
RPIDEV_DEVICE_USER=pi # username
RPIDEV_DEVICE_PW=raspberry # password
### Decide target mkspec
TARGET_DEVICE="linux-rpi3-g++"
if [ "$RPIDEV_DEVICE_VERSION" == "pi1" ]; then
TARGET_DEVICE="linux-rasp-pi-g++"
elif [ "$RPIDEV_DEVICE_VERSION" == "pi2" ]; then
TARGET_DEVICE="linux-rasp-pi2-g++"
elif [ "$RPIDEV_DEVICE_VERSION" == "pi3" ]; then
TARGET_DEVICE="linux-rasp-pi3-g++"
else
echo "${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${FUNCNAME[1]}: Unknown device $RPIDEV_DEVICE_VERSION." >&2
exit 1
fi
### Qt paths
QT_VER=5.9 # Select version to download and install
QT_SUBVER=5.9.4 # Select subversion to download and install
QT_INSTALL_DIR=${RPIDEV_INSTALL}/qt${QT_VER}
QT_INSTALL_DIR_HOST=${RPIDEV_INSTALL}/qt${QT_VER}-host
QT_DEVICE_DIR=/usr/local/qt${QT_VER}
### Synchronization Options
RSH_OPT="/usr/bin/sshpass -p ${RPIDEV_DEVICE_PW} ssh -o StrictHostKeyChecking=no -l ${RPIDEV_DEVICE_USER}"
### Configuration Options
CONF_OPT=""
CONF_OPT+=" -v"
CONF_OPT+=" -opensource"
CONF_OPT+=" -confirm-license"
CONF_OPT+=" -opengl es2"
CONF_OPT+=" -device ${TARGET_DEVICE}"
CONF_OPT+=" -device-option CROSS_COMPILE=${RPIDEV_TOOLS}/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-"
CONF_OPT+=" -sysroot ${RPIDEV_SYSROOT}"
CONF_OPT+=" -prefix ${QT_DEVICE_DIR}"
CONF_OPT+=" -extprefix ${QT_INSTALL_DIR}"
CONF_OPT+=" -hostprefix ${QT_INSTALL_DIR_HOST}"
#CONF_OPT+=" -optimized-qmake"
#CONF_OPT+=" -reduce-exports"
CONF_OPT+=" -release"
CONF_OPT+=" -make libs" # Only make libraries (no tests, examples etc)
CONF_OPT+=" -skip qtserialbus" # Get error when compiling this package
CONF_OPT+=" -skip qtwayland" # Get error when compiling this package
CONF_OPT+=" -skip qtscript" # Get error when compiling this package
#CONF_OPT+=" -skip qtwebengine" # Large (save time by skipping)
#CONF_OPT+=" -skip qtwebkit" # Large (save time by skipping)
CONF_OPT+=" -no-pch" # Some users have reported issues with using precomiled headers
CONF_OPT+=" -no-use-gold-linker" # Seems to have issues with ARMv8
CONF_OPT+=" -no-pulseaudio -alsa" # Don't use buggy pulseaudio
echo
echo "===== Creating root directory ====="
echo
mkdir -p ${RPIDEV_ROOT}
do_sysroot(){
echo "===== Creating sysroot directories ====="
mkdir -p ${RPIDEV_SYSROOT}/usr
mkdir -p ${RPIDEV_SYSROOT}/opt
echo
echo "===== Syncing sysroot with ${RPIDEV_DEVICE_ADDRESS} ====="
set +e # Ignore errors as there are usually some folders without read permission
echo "== Sync /lib =="
echo
rsync -avztr --delete --rsh="${RSH_OPT}" ${RPIDEV_DEVICE_ADDRESS}:/lib ${RPIDEV_SYSROOT} 2>&1 | tee ${RUN_DIR}/sysroot.out
echo
echo "== Sync /usr/include =="
echo
rsync -avztr --delete --rsh="${RSH_OPT}" ${RPIDEV_DEVICE_ADDRESS}:/usr/include ${RPIDEV_SYSROOT}/usr 2>&1 | tee -a ${RUN_DIR}/sysroot.out
echo
echo "== Sync /usr/lib =="
echo
rsync -avztr --delete --rsh="${RSH_OPT}" ${RPIDEV_DEVICE_ADDRESS}:/usr/lib ${RPIDEV_SYSROOT}/usr 2>&1 | tee -a ${RUN_DIR}/sysroot.out
echo
echo "== Sync /opt/vc =="
echo
rsync -avztr --delete --rsh="${RSH_OPT}" ${RPIDEV_DEVICE_ADDRESS}:/opt/vc ${RPIDEV_SYSROOT}/opt 2>&1 | tee -a ${RUN_DIR}/sysroot.out
set -e # Re-enable stop on error
echo
echo "===== Replacing absolute symlinks with relative ones ====="
echo
"${SCRIPT_DIR}/sysroot-relativelinks.py" ${RPIDEV_SYSROOT}
}
do_tools(){
echo
echo "===== Fetching RPi toolchain ====="
echo
git clone https://github.com/raspberrypi/tools.git ${RPIDEV_TOOLS}
}
do_down(){
echo
echo "===== Downloading src tar: qt${QT_VER} ====="
echo
mkdir -p "${RPIDEV_TAR}"
cd "${RPIDEV_TAR}"
wget "http://download.qt.io/official_releases/qt/${QT_VER}/${QT_SUBVER}/single/qt-everywhere-opensource-src-${QT_SUBVER}.tar.xz"
}
do_tar(){
echo
echo "===== Unpacking src tar"
echo
mkdir -p "${RPIDEV_SRC}/qt${QT_VER}"
cd "${RPIDEV_TAR}"
tar xf "qt-everywhere-opensource-src-${QT_SUBVER}.tar.xz" --strip=1 -C ${RPIDEV_SRC}/qt${QT_VER} qt-everywhere-opensource-src-${QT_SUBVER}
}
do_conf(){
echo
echo "===== Creating build directory ====="
echo
mkdir -p "${RPIDEV_BUILD}/qt${QT_VER}"
cd "${RPIDEV_BUILD}/qt${QT_VER}"
echo
echo "===== Configuring shadow build ====="
echo
MAKEFLAGS=-j${RPIDEV_JOBS} ${RPIDEV_SRC}/qt${QT_VER}/configure ${CONF_OPT} 2>&1 | tee ${RUN_DIR}/config.out
}
do_make(){
echo
echo "===== Building qt${QT_VER} ====="
echo
cd "${RPIDEV_BUILD}/qt${QT_VER}"
make -j${RPIDEV_JOBS} 2>&1 | tee ${RUN_DIR}/make.out
}
do_install(){
echo
echo "===== Installing in ${QT_INSTALL_DIR} ====="
echo
cd "${RPIDEV_BUILD}/qt${QT_VER}"
sudo make install -j${RPIDEV_JOBS} 2>&1 | tee ${RUN_DIR}/install.out
sudo cp "${QT_INSTALL_DIR_HOST}/bin/rcc" "${QT_INSTALL_DIR}/bin" # Copy missing binary
}
do_deploy(){
echo
echo "===== Deploying ${QT_INSTALL_DIR} to target ${RPIDEV_DEVICE_ADDRESS}:${QT_DEVICE_DIR} ====="
echo
rsync -avztr --delete --rsh="${RSH_OPT}" ${QT_INSTALL_DIR}/* ${RPIDEV_DEVICE_ADDRESS}:${QT_DEVICE_DIR}
}
do_all(){
do_sysroot
do_tools
do_down
do_tar
do_conf
do_make
do_install
do_deploy
}
while [ "${1+defined}" ];
do
case $1 in
sysroot* ) do_sysroot ;;
tools* ) do_tools ;;
down* ) do_down ;;
tar* ) do_tar ;;
conf* ) do_conf ;;
make* ) do_make ;;
install* ) do_install ;;
deploy* ) do_deploy ;;
all* ) do_all ;;
*) echo "UNKNOWN COMMAND: '$1', SKIPPING..." ;;
esac
shift
done
echo "DONE"