forked from analogdevicesinc/scopy-mingw-build-deps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·327 lines (262 loc) · 10.6 KB
/
build.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#!/usr/bin/bash.exe
LIBIIO_BRANCH=master
LIBAD9361_BRANCH=master
LIBM2K_BRANCH=master
GRIIO_BRANCH=upgrade-3.8
GNURADIO_FORK=analogdevicesinc
GNURADIO_BRANCH=ming-3.8-clean
GRSCOPY_BRANCH=master
GRM2K_BRANCH=master
QWT_BRANCH=qwt-6.1-multiaxes
QWTPOLAR_BRANCH=master # not used
LIBSIGROKDECODE_BRANCH=master
BUILD_STATUS_FILE=/tmp/scopy-mingw-build-status
touch $BUILD_STATUS_FILE
#TODO: make each dep install it's own deps
# Exit immediately if an error occurs
set -e
export PATH=/bin:/usr/bin:/${MINGW_VERSION}/bin:/c/Program\ Files/Git/cmd:/c/Windows/System32:/c/Program\ Files/Appveyor/BuildAgent
WORKDIR=${PWD}
JOBS=-j3
CC=/${MINGW_VERSION}/bin/${ARCH}-w64-mingw32-gcc.exe
CXX=/${MINGW_VERSION}/bin/${ARCH}-w64-mingw32-g++.exe
CMAKE_OPTS="
-DCMAKE_C_COMPILER:FILEPATH=${CC} \
-DCMAKE_CXX_COMPILER:FILEPATH=${CXX} \
-DPKG_CONFIG_EXECUTABLE=/$MINGW_VERSION/bin/pkg-config.exe \
-DCMAKE_INSTALL_PREFIX=/${MINGW_VERSION}\
-DCMAKE_PREFIX_PATH=/c/msys64/$MINGW_VERSION/lib/cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
"
AUTOCONF_OPTS="--prefix=/msys64/${MINGW_VERSION} \
--host=${ARCH}-w64-mingw32 \
--enable-shared \
--disable-static"
if [ ${ARCH} == "i686" ]
then
RC_COMPILER_OPT="-DCMAKE_RC_COMPILER=/c/windres.exe"
else
RC_COMPILER_OPT="-DCMAKE_RC_COMPILER=/c/msys64/mingw64/bin/windres.exe"
fi
install_deps() {
echo "### Download and installed precompiled GNURadio ... "
wget "https://ci.appveyor.com/api/projects/$GNURADIO_FORK/gnuradio/artifacts/gnuradio-$MINGW_VERSION-deps.txt?branch=$GNURADIO_BRANCH&job=Environment: MINGW_VERSION=$MINGW_VERSION, ARCH=$ARCH" -O /tmp/gnuradio-$MINGW_VERSION-deps.txt
wget "https://ci.appveyor.com/api/projects/$GNURADIO_FORK/gnuradio/artifacts/gnuradio-$MINGW_VERSION.tar.xz?branch=$GNURADIO_BRANCH&job=Environment: MINGW_VERSION=$MINGW_VERSION, ARCH=$ARCH" -O /tmp/gnuradio-$MINGW_VERSION.tar.xz
cd $WORKDIR
tar xJf /tmp/gnuradio-$MINGW_VERSION.tar.xz
cd /c
tar xJf /tmp/gnuradio-$MINGW_VERSION.tar.xz
GNURADIO_DEPS=$(</tmp/gnuradio-$MINGW_VERSION-deps.txt)
# mingw-w64-$ARCH-qt \
PACMAN_SYNC_DEPS="
$GNURADIO_DEPS \
mingw-w64-$ARCH-libxml2 \
mingw-w64-$ARCH-libzip \
mingw-w64-$ARCH-fftw \
mingw-w64-$ARCH-libzip \
mingw-w64-$ARCH-libffi \
mingw-w64-$ARCH-glib2 \
mingw-w64-$ARCH-glibmm \
mingw-w64-$ARCH-doxygen\
"
PACMAN_REPO_DEPS="
${WORKDIR}/old_msys_deps_${MINGW_VERSION}/mingw-w64-$ARCH-libusb-1.0.21-2-any.pkg.tar.xz \
${WORKDIR}/old_msys_deps_${MINGW_VERSION}/mingw-w64-$ARCH-boost-1.72.0-3-any.pkg.tar.zst \
${WORKDIR}/old_msys_deps_${MINGW_VERSION}/mingw-w64-$ARCH-qt5-5.14.2-3-any.pkg.tar.zst \
"
echo "Built scopy-mingw-build-deps on Appveyor" >> $BUILD_STATUS_FILE
echo "on $(date)" >> $BUILD_STATUS_FILE
echo "url: ${APPVEYOR_URL}" >> $BUILD_STATUS_FILE
echo "api_url: ${APPVEYOR_API_URL}" >> $BUILD_STATUS_FILE
echo "acc_name: ${APPVEYOR_ACCOUNT_NAME}" >> $BUILD_STATUS_FILE
echo "prj_name: ${APPVEYOR_PROJECT_NAME}" >> $BUILD_STATUS_FILE
echo "build_id: ${APPVEYOR_BUILD_ID}" >> $BUILD_STATUS_FILE
echo "build_nr: ${APPVEYOR_BUILD_NUMBER}" >> $BUILD_STATUS_FILE
echo "build_version: ${APPVEYOR_BUILD_VERSION}" >> $BUILD_STATUS_FILE
echo "job_id: ${APPVEYOR_JOB_ID}" >> $BUILD_STATUS_FILE
echo "job_name: ${APPVEYOR_JOB_NAME}" >> $BUILD_STATUS_FILE
echo "job_nr: ${APPVEYOR_JOB_NUMBER}" >> $BUILD_STATUS_FILE
echo "job_link: ${APPVEYOR_URL}/project/${APPVEYOR_ACCOUNT_NAME}/${APPVEYOR_PROJECT_NAME}/builds/${APPVEYOR_BUILD_ID}/job/${APPVEYOR_JOB_ID}" >> $BUILD_STATUS_FILE
echo $BUILD_STATUS_FILE
echo "Repo deps locations/files" >> $BUILD_STATUS_FILE
echo $PACMAN_REPO_DEPS >> $BUILD_STATUS_FILE
ls ${WORKDIR}/old_msys_deps_${MINGW_VERSION}
echo "### Installing dependencies ... "
pacman --noconfirm --needed -Sy $PACMAN_SYNC_DEPS
pacman --noconfirm -U $PACMAN_REPO_DEPS
# Fix Qt5 spec files
sed -i "s/\$\${CROSS_COMPILE}/${ARCH}-w64-mingw32-/" /${MINGW_VERSION}/share/qt5/mkspecs/win32-g++/qmake.conf
}
build_libiio() {
CURRENT_BUILD=libiio
echo "### Building libiio - branch $LIBIIO_BRANCH"
git clone --depth 1 https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_BRANCH ${WORKDIR}/libiio
mkdir ${WORKDIR}/libiio/build-${ARCH}
cd ${WORKDIR}/libiio/build-${ARCH}
# Download a 32-bit version of windres.exe
cd /c
wget http://swdownloads.analog.com/cse/build/windres.exe.gz
gunzip windres.exe.gz
cd ${WORKDIR}/libiio/build-${ARCH}
cmake -G 'Unix Makefiles' \
${CMAKE_OPTS} \
${RC_COMPILER_OPT} \
-DWITH_TESTS:BOOL=OFF \
-DWITH_DOC:BOOL=OFF \
-DCSHARP_BINDINGS:BOOL=OFF \
-DPYTHON_BINDINGS:BOOL=OFF \
${WORKDIR}/libiio
make ${JOBS} install
DESTDIR=${WORKDIR} make ${JOBS} install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_libm2k() {
echo "### Building libm2k - branch $LIBM2K_BRANCH"
CURRENT_BUILD=libm2k
git clone --depth 1 https://github.com/analogdevicesinc/libm2k.git -b $LIBM2K_BRANCH ${WORKDIR}/libm2k
mkdir ${WORKDIR}/libm2k/build-${ARCH}
cd ${WORKDIR}/libm2k/build-${ARCH}
cmake -G 'Unix Makefiles' \
${CMAKE_OPTS} \
-DENABLE_PYTHON=OFF\
-DENABLE_CSHARP=OFF\
-DENABLE_EXAMPLES=OFF\
-DENABLE_TOOLS=OFF\
-DINSTALL_UDEV_RULES=OFF\
${WORKDIR}/libm2k
make ${JOBS} install
DESTDIR=${WORKDIR} make ${JOBS} install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_libad9361() {
echo "### Building libad9361 - branch $LIBAD9361_BRANCH"
CURRENT_BUILD=libad9361
git clone --depth 1 https://github.com/analogdevicesinc/libad9361-iio.git -b $LIBAD9361_BRANCH ${WORKDIR}/libad9361
mkdir ${WORKDIR}/libad9361/build-${ARCH}
cd ${WORKDIR}/libad9361/build-${ARCH}
cmake -G 'Unix Makefiles' \
${CMAKE_OPTS} \
${WORKDIR}/libad9361
make $JOBS install
DESTDIR=${WORKDIR} make $JOBS install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_griio() {
echo "### Building gr-iio - branch $GRIIO_BRANCH"
CURRENT_BUILD=gr-iio
git clone --depth 1 https://github.com/analogdevicesinc/gr-iio.git -b $GRIIO_BRANCH ${WORKDIR}/gr-iio
mkdir ${WORKDIR}/gr-iio/build-${ARCH}
cd ${WORKDIR}/gr-iio/build-${ARCH}
# -D_hypot=hypot: http://boost.2283326.n4.nabble.com/Boost-Python-Compile-Error-s-GCC-via-MinGW-w64-td3165793.html#a3166757
cmake -G 'Unix Makefiles' \
${CMAKE_OPTS} \
-DCMAKE_CXX_FLAGS="-D_hypot=hypot" \
${WORKDIR}/gr-iio
make $JOBS install
DESTDIR=${WORKDIR} make $JOBS install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_grm2k() {
echo "### Building gr-m2k - branch $GRM2K_BRANCH"
CURRENT_BUILD=gr-m2k
git clone --depth 1 https://github.com/analogdevicesinc/gr-m2k.git -b $GRM2K_BRANCH ${WORKDIR}/gr-m2k
mkdir ${WORKDIR}/gr-m2k/build-${ARCH}
cd ${WORKDIR}/gr-m2k/build-${ARCH}
cmake -G 'Unix Makefiles' \
${CMAKE_OPTS} \
${WORKDIR}/gr-m2k
make $JOBS install
DESTDIR=${WORKDIR} make $JOBS install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_grscopy() {
echo "### Building gr-scopy - branch $GRSCOPY_BRANCH"
CURRENT_BUILD=gr-scopy
git clone --depth 1 https://github.com/analogdevicesinc/gr-scopy.git -b $GRSCOPY_BRANCH ${WORKDIR}/gr-scopy
mkdir ${WORKDIR}/gr-scopy/build-${ARCH}
cd ${WORKDIR}/gr-scopy/build-${ARCH}
cmake -G 'Unix Makefiles' \
${CMAKE_OPTS} \
${WORKDIR}/gr-scopy
make $JOBS install
DESTDIR=${WORKDIR} make $JOBS install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_libsigrokdecode() {
echo "### Building libsigrokdecode - branch $LIBSIGROKDECODE_BRANCH"
CURRENT_BUILD=libsigrokdecode
git clone --depth 1 https://github.com/sigrokproject/libsigrokdecode.git -b $LIBSIGROKDECODE_BRANCH ${WORKDIR}/libsigrokdecode
mkdir -p ${WORKDIR}/libsigrokdecode/build-${ARCH}
cd ${WORKDIR}/libsigrokdecode
patch -p1 < ${WORKDIR}/sigrokdecode-windows-fix.patch
./autogen.sh
cd build-${ARCH}
CPPFLAGS="-DLIBSIGROKDECODE_EXPORT=1" ../configure ${AUTOCONF_OPTS}
make $JOBS install
DESTDIR=${WORKDIR} make $JOBS install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_qwt() {
echo "### Building qwt - branch $QWT_BRANCH"
CURRENT_BUILD=qwt
git clone --depth 1 https://github.com/osakared/qwt.git -b $QWT_BRANCH ${WORKDIR}/qwt
cd ${WORKDIR}/qwt
# Disable components that we won't build
sed -i "s/^QWT_CONFIG\\s*+=\\s*QwtMathML$/#/g" qwtconfig.pri
sed -i "s/^QWT_CONFIG\\s*+=\\s*QwtDesigner$/#/g" qwtconfig.pri
sed -i "s/^QWT_CONFIG\\s*+=\\s*QwtExamples$/#/g" qwtconfig.pri
# Fix prefix
sed -i "s/^\\s*QWT_INSTALL_PREFIX.*$/QWT_INSTALL_PREFIX=\"\"/g" qwtconfig.pri
cd ${WORKDIR}/qwt/src
qmake
make INSTALL_ROOT="/c/msys64/${MINGW_VERSION}" $JOBS -f Makefile.Release install
make INSTALL_ROOT="${WORKDIR}/msys64/${MINGW_VERSION}" $JOBS -f Makefile.Release install
echo "$CURRENT_BUILD - $(git rev-parse --short HEAD)" >> $BUILD_STATUS_FILE
}
build_qwtpolar() {
echo "### Building qwtpolar - branch $QWTPOLAR_BRANCH"
CURRENT_BUILD=qwtpolar
mkdir -p ${WORKDIR}/qwtpolar
cd ${WORKDIR}/qwtpolar
wget https://downloads.sourceforge.net/project/qwtpolar/qwtpolar/1.1.1/qwtpolar-1.1.1.tar.bz2 -O- \
| tar xj --strip-components=1 -C ${WORKDIR}/qwtpolar
patch -p1 < ${WORKDIR}/qwtpolar-qwt-6.1-compat.patch
# Disable components that we won't build
sed -i "s/^QWT_POLAR_CONFIG\\s*+=\\s*QwtPolarDesigner$/#/g" qwtpolarconfig.pri
sed -i "s/^QWT_POLAR_CONFIG\\s*+=\\s*QwtPolarExamples$/#/g" qwtpolarconfig.pri
# Fix prefix
sed -i "s/^\\s*QWT_POLAR_INSTALL_PREFIX.*$/QWT_POLAR_INSTALL_PREFIX=\"\"/g" qwtpolarconfig.pri
cd ${WORKDIR}/qwtpolar/src
qmake LIBS+="-lqwt"
make INSTALL_ROOT="/c/msys64/${MINGW_VERSION}" $JOBS -f Makefile.Release install
make INSTALL_ROOT="${WORKDIR}/msys64/${MINGW_VERSION}" $JOBS -f Makefile.Release install
echo "$CURRENT_BUILD - v1.1.1" >> $BUILD_STATUS_FILE
}
install_deps
build_libiio
build_libad9361
build_libm2k
build_griio
build_grscopy
build_grm2k
build_qwt
build_qwtpolar
build_libsigrokdecode
echo "" >> $BUILD_STATUS_FILE
echo "pacman -Qe output - all explicitly installed packages on build machine" >> $BUILD_STATUS_FILE
pacman -Qe >> $BUILD_STATUS_FILE
#echo "pacman -Qm output - all packages from nonsync sources" >> $BUILD_STATUS_FILE
#pacman -Qm >> $BUILD_STATUS_FILE
# Fix DLLs installed in the wrong path
mv ${WORKDIR}/msys64/${MINGW_VERSION}/lib/qwt.dll \
${WORKDIR}/msys64/${MINGW_VERSION}/lib/qwtpolar.dll \
${WORKDIR}/msys64/${MINGW_VERSION}/bin
rm -rf ${WORKDIR}/msys64/${MINGW_VERSION}/doc \
${WORKDIR}/msys64/${MINGW_VERSION}/share/doc \
${WORKDIR}/msys64/${MINGW_VERSION}/lib/*.la
echo "### Creating archive ... "
tar cavf ${WORKDIR}/scopy-${MINGW_VERSION}-build-deps.tar.xz -C ${WORKDIR} msys64
appveyor PushArtifact $BUILD_STATUS_FILE
pacman -Q > /tmp/AllInstalledPackages
appveyor PushArtifact /tmp/AllInstalledPackages
echo -n ${PACMAN_SYNC_DEPS} > ${WORKDIR}/scopy-$MINGW_VERSION-build-deps-pacman.txt