doc: add IP DSCP rewrite to mlx5 and release notes
[dpdk.git] / devtools / test-build.sh
1 #! /bin/sh -e
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2015 6WIND S.A.
4
5 default_path=$PATH
6
7 # Load config options:
8 # - ARMV8_CRYPTO_LIB_PATH
9 # - DPDK_ABI_REF_DIR
10 # - DPDK_ABI_REF_VERSION
11 # - DPDK_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2)
12 # - DPDK_BUILD_TEST_DIR
13 # - DPDK_DEP_ARCHIVE
14 # - DPDK_DEP_BPF (y/[n])
15 # - DPDK_DEP_CFLAGS
16 # - DPDK_DEP_ELF (y/[n])
17 # - DPDK_DEP_FDT (y/[n])
18 # - DPDK_DEP_ISAL (y/[n])
19 # - DPDK_DEP_JSON (y/[n])
20 # - DPDK_DEP_LDFLAGS
21 # - DPDK_DEP_MLX (y/[n])
22 # - DPDK_DEP_NFB (y/[n])
23 # - DPDK_DEP_NUMA ([y]/n)
24 # - DPDK_DEP_PCAP (y/[n])
25 # - DPDK_DEP_SSL (y/[n])
26 # - DPDK_DEP_IPSEC_MB (y/[n])
27 # - DPDK_DEP_SZE (y/[n])
28 # - DPDK_DEP_ZLIB (y/[n])
29 # - DPDK_MAKE_JOBS (int)
30 # - DPDK_NOTIFY (notify-send)
31 # - FLEXRAN_SDK
32 # - LIBMUSDK_PATH
33 devtools_dir=$(dirname $(readlink -f $0))
34 . $devtools_dir/load-devel-config
35
36 print_usage () {
37         echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]"
38 }
39
40 print_help () {
41         echo 'Test building several targets with different options'
42         echo
43         print_usage
44         cat <<- END_OF_HELP
45
46         options:
47                 -h    this help
48                 -jX   use X parallel jobs in "make"
49                 -s    short test only first config without tests|examples|doc
50                 -v    verbose build
51
52         config: defconfig[[~][+]option1[[~][+]option2...]]
53                 Example: x86_64-native-linux-gcc+debug~RXTX_CALLBACKS
54                 The lowercase options are defined inside $(basename $0).
55                 The uppercase options can be the end of a defconfig option
56                 to enable if prefixed with '+' or to disable if prefixed with '~'.
57                 Default is to automatically enable most of the options.
58                 The external dependencies are setup with DPDK_DEP_* variables.
59                 If no config on command line, DPDK_BUILD_TEST_CONFIGS is used.
60         END_OF_HELP
61 }
62
63 [ -z $MAKE ] && command -v gmake > /dev/null && MAKE=gmake
64 [ -z $MAKE ] && command -v make > /dev/null && MAKE=make
65 [ -z $MAKE ] && echo "Cannot find make or gmake" && exit 1
66
67 J=$DPDK_MAKE_JOBS
68 builds_dir=${DPDK_BUILD_TEST_DIR:-.}
69 short=false
70 unset verbose
71 # for ABI checks, we need debuginfo
72 test_cflags="-Wfatal-errors -g"
73 while getopts hj:sv ARG ; do
74         case $ARG in
75                 j ) J=$OPTARG ;;
76                 s ) short=true ;;
77                 v ) verbose='V=1' ;;
78                 h ) print_help ; exit 0 ;;
79                 ? ) print_usage ; exit 1 ;;
80         esac
81 done
82 shift $(($OPTIND - 1))
83 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
84
85 success=false
86 on_exit ()
87 {
88         if $success ; then
89                 [ "$DPDK_NOTIFY" != notify-send ] || \
90                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
91         elif [ -z "$signal" ] ; then
92                 [ -z "$dir" ] || echo "failed to build $dir" >&2
93                 [ "$DPDK_NOTIFY" != notify-send ] || \
94                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
95         fi
96 }
97 # catch manual interrupt to ignore notification
98 trap "signal=INT ; trap - INT ; kill -INT $$" INT
99 # notify result on exit
100 trap on_exit EXIT
101
102 cd $devtools_dir/..
103
104 reset_env ()
105 {
106         export PATH=$default_path
107         unset CROSS
108         unset DPDK_DEP_ARCHIVE
109         unset DPDK_DEP_BPF
110         unset DPDK_DEP_CFLAGS
111         unset DPDK_DEP_ELF
112         unset DPDK_DEP_FDT
113         unset DPDK_DEP_ISAL
114         unset DPDK_DEP_JSON
115         unset DPDK_DEP_LDFLAGS
116         unset DPDK_DEP_MLX
117         unset DPDK_DEP_NFB
118         unset DPDK_DEP_NUMA
119         unset DPDK_DEP_PCAP
120         unset DPDK_DEP_SSL
121         unset DPDK_DEP_IPSEC_MB
122         unset DPDK_DEP_SZE
123         unset DPDK_DEP_ZLIB
124         unset ARMV8_CRYPTO_LIB_PATH
125         unset FLEXRAN_SDK
126         unset LIBMUSDK_PATH
127         unset PQOS_INSTALL_PATH
128 }
129
130 config () # <directory> <target> <options>
131 {
132         reconfig=false
133         if git rev-parse 2>&- && [ -n "$(git diff HEAD~ -- config)" ] ; then
134                 echo 'Default config may have changed'
135                 reconfig=true
136         fi
137         if [ ! -e $1/.config ] || $reconfig ; then
138                 echo "================== Configure $1"
139                 ${MAKE} T=$2 O=$1 config
140
141                 echo 'Customize configuration'
142                 # Built-in options (lowercase)
143                 ! echo $3 | grep -q '+default' || \
144                 sed -ri="" 's,(RTE_MACHINE=")native,\1default,' $1/.config
145                 ! echo $3 | grep -q '+kmods' || \
146                 sed -ri="" 's,(IGB_UIO=|KNI_KMOD=)n,\1y,' $1/.config
147                 echo $3 | grep -q '+next' || \
148                 sed -ri=""           's,(NEXT_ABI=)y,\1n,' $1/.config
149                 ! echo $3 | grep -q '+shared' || \
150                 sed -ri=""         's,(SHARED_LIB=)n,\1y,' $1/.config
151                 ! echo $3 | grep -q '+debug' || ( \
152                 sed -ri=""  's,(RTE_LOG_DP_LEVEL=).*,\1RTE_LOG_DEBUG,' $1/.config
153                 sed -ri=""           's,(_DEBUG.*=)n,\1y,' $1/.config
154                 sed -ri=""  's,(_STAT)([S_].*=|=)n,\1\2y,' $1/.config
155                 sed -ri="" 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config )
156
157                 # Automatic configuration
158                 ! echo $2 | grep -q 'arm64' || \
159                 sed -ri=""        's,(ARM_USE_WFE=)n,\1y,' $1/.config
160                 test "$DPDK_DEP_NUMA" != n || \
161                 sed -ri=""             's,(NUMA.*=)y,\1n,' $1/.config
162                 sed -ri=""    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
163                 sed -ri=""             's,(BYPASS=)n,\1y,' $1/.config
164                 test "$DPDK_DEP_ARCHIVE" != y || \
165                 sed -ri=""       's,(RESOURCE_TAR=)n,\1y,' $1/.config
166                 test "$DPDK_DEP_BPF" != y || \
167                 sed -ri=""         's,(PMD_AF_XDP=)n,\1y,' $1/.config
168                 test "$DPDK_DEP_FDT" != y || \
169                 sed -ri=""   's,(PMD_IFPGA_RAWDEV=)n,\1y,' $1/.config
170                 test "$DPDK_DEP_FDT" != y || \
171                 sed -ri=""         's,(IPN3KE_PMD=)n,\1y,' $1/.config
172                 test "$DPDK_DEP_ISAL" != y || \
173                 sed -ri=""           's,(PMD_ISAL=)n,\1y,' $1/.config
174                 test "$DPDK_DEP_MLX" != y || \
175                 sed -ri=""          's,(MLX.*_PMD=)n,\1y,' $1/.config
176                 test "$DPDK_DEP_NFB" != y || \
177                 sed -ri=""            's,(NFB_PMD=)n,\1y,' $1/.config
178                 test "$DPDK_DEP_SZE" != y || \
179                 sed -ri=""       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
180                 test "$DPDK_DEP_ZLIB" != y || \
181                 sed -ri=""          's,(BNX2X_PMD=)n,\1y,' $1/.config
182                 test "$DPDK_DEP_ZLIB" != y || \
183                 sed -ri=""           's,(PMD_ZLIB=)n,\1y,' $1/.config
184                 test "$DPDK_DEP_ZLIB" != y || \
185                 sed -ri=""   's,(COMPRESSDEV_TEST=)n,\1y,' $1/.config
186                 test "$DPDK_DEP_PCAP" != y || \
187                 sed -ri=""               's,(PCAP=)n,\1y,' $1/.config
188                 test -z "$ARMV8_CRYPTO_LIB_PATH" || \
189                 sed -ri=""   's,(PMD_ARMV8_CRYPTO=)n,\1y,' $1/.config
190                 test "$DPDK_DEP_IPSEC_MB" != y || \
191                 sed -ri=""       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
192                 test "$DPDK_DEP_IPSEC_MB" != y || \
193                 sed -ri=""      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
194                 test "$DPDK_DEP_IPSEC_MB" != y || \
195                 sed -ri=""            's,(PMD_ZUC=)n,\1y,' $1/.config
196                 test "$DPDK_DEP_IPSEC_MB" != y || \
197                 sed -ri=""         's,(PMD_KASUMI=)n,\1y,' $1/.config
198                 test "$DPDK_DEP_IPSEC_MB" != y || \
199                 sed -ri=""         's,(PMD_SNOW3G=)n,\1y,' $1/.config
200                 test "$DPDK_DEP_SSL" != y || \
201                 sed -ri=""            's,(PMD_CCP=)n,\1y,' $1/.config
202                 test "$DPDK_DEP_SSL" != y || \
203                 sed -ri=""        's,(PMD_OPENSSL=)n,\1y,' $1/.config
204                 test "$DPDK_DEP_SSL" != y || \
205                 sed -ri=""            's,(QAT_SYM=)n,\1y,' $1/.config
206                 test -z "$FLEXRAN_SDK" || \
207                 sed -ri=""     's,(BBDEV_TURBO_SW=)n,\1y,' $1/.config
208                 sed -ri=""           's,(SCHED_.*=)n,\1y,' $1/.config
209                 test -z "$LIBMUSDK_PATH" || \
210                 sed -ri=""   's,(PMD_MVSAM_CRYPTO=)n,\1y,' $1/.config
211                 test -z "$LIBMUSDK_PATH" || \
212                 sed -ri=""          's,(MVPP2_PMD=)n,\1y,' $1/.config
213                 test -z "$LIBMUSDK_PATH" || \
214                 sed -ri=""         's,(MVNETA_PMD=)n,\1y,' $1/.config
215                 test "$DPDK_DEP_ELF" != y || \
216                 sed -ri=""            's,(BPF_ELF=)n,\1y,' $1/.config
217                 test "$DPDK_DEP_JSON" != y || \
218                 sed -ri=""          's,(TELEMETRY=)n,\1y,' $1/.config
219                 build_config_hook $1 $2 $3
220
221                 # Explicit enabler/disabler (uppercase)
222                 for option in $(echo $3 | sed 's,[~+], &,g') ; do
223                         pattern=$(echo $option | cut -c2-)
224                         if echo $option | grep -q '^~' ; then
225                                 sed -ri="" "s,($pattern=)y,\1n," $1/.config
226                         elif echo $option | grep -q '^+' ; then
227                                 sed -ri="" "s,($pattern=)n,\1y," $1/.config
228                         fi
229                 done
230         fi
231 }
232
233 # default empty hook to override in devel config
234 build_config_hook () # <directory> <target> <options>
235 {
236         :
237 }
238
239 for conf in $configs ; do
240         target=$(echo $conf | sed 's,[~+].*,,')
241         # reload config with DPDK_TARGET set
242         DPDK_TARGET=$target
243         reset_env
244         . $devtools_dir/load-devel-config
245
246         options=$(echo $conf | sed 's,[^~+]*,,')
247         dir=$builds_dir/$conf
248         config $dir $target $options
249
250         echo "================== Build $conf"
251         ${MAKE} -j$J EXTRA_CFLAGS="$test_cflags $DPDK_DEP_CFLAGS" \
252                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
253         ! $short || break
254         export RTE_TARGET=$target
255         rm -rf $dir/install
256         ${MAKE} install O=$dir DESTDIR=$dir/install prefix=
257         echo "================== Build examples for $conf"
258         export RTE_SDK=$(readlink -f $dir)/install/share/dpdk
259         ln -sTf $(pwd)/lib $RTE_SDK/lib # workaround for vm_power_manager
260         ${MAKE} -j$J -sC examples \
261                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
262                 O=$(readlink -f $dir)/examples
263         unset RTE_TARGET
264         if [ -n "$DPDK_ABI_REF_VERSION" ]; then
265                 abirefdir=${DPDK_ABI_REF_DIR:-reference}/$DPDK_ABI_REF_VERSION
266                 if [ ! -d $abirefdir/$conf ]; then
267                         # clone current sources
268                         if [ ! -d $abirefdir/src ]; then
269                                 git clone --local --no-hardlinks \
270                                         --single-branch \
271                                         -b $DPDK_ABI_REF_VERSION \
272                                         $(pwd) $abirefdir/src
273                         fi
274
275                         cd $abirefdir/src
276
277                         rm -rf $abirefdir/build
278                         config $abirefdir/build $target $options
279
280                         echo -n "================== Build $conf "
281                         echo "($DPDK_ABI_REF_VERSION)"
282                         ${MAKE} -j$J \
283                                 EXTRA_CFLAGS="$test_cflags $DPDK_DEP_CFLAGS" \
284                                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
285                                 O=$abirefdir/build
286                         export RTE_TARGET=$target
287                         ${MAKE} install O=$abirefdir/build \
288                                 DESTDIR=$abirefdir/$conf \
289                                 prefix=
290                         unset RTE_TARGET
291                         $devtools_dir/gen-abi.sh $abirefdir/$conf
292
293                         # back to current workdir
294                         cd $devtools_dir/..
295                 fi
296
297                 echo "================== Check ABI $conf"
298                 $devtools_dir/gen-abi.sh $dir/install
299                 $devtools_dir/check-abi.sh $abirefdir/$conf $dir/install
300         fi
301         echo "################## $conf done."
302         unset dir
303 done
304
305 if ! $short ; then
306         mkdir -p .check
307         echo "================== Build doxygen HTML API"
308         ${MAKE} doc-api-html >/dev/null 2>.check/doc.txt
309         echo "================== Build sphinx HTML guides"
310         ${MAKE} doc-guides-html >/dev/null 2>>.check/doc.txt
311         echo "================== Check docs"
312         diff -u /dev/null .check/doc.txt
313 fi
314
315 success=true