devtools: add checks for ABI symbol addition
[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_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2)
10 # - DPDK_DEP_ARCHIVE
11 # - DPDK_DEP_CFLAGS
12 # - DPDK_DEP_ISAL (y/[n])
13 # - DPDK_DEP_LDFLAGS
14 # - DPDK_DEP_MLX (y/[n])
15 # - DPDK_DEP_NUMA ([y]/n)
16 # - DPDK_DEP_PCAP (y/[n])
17 # - DPDK_DEP_SSL (y/[n])
18 # - DPDK_DEP_IPSEC_MB (y/[n])
19 # - DPDK_DEP_SZE (y/[n])
20 # - DPDK_DEP_ZLIB (y/[n])
21 # - DPDK_MAKE_JOBS (int)
22 # - DPDK_NOTIFY (notify-send)
23 # - FLEXRAN_SDK
24 # - LIBMUSDK_PATH
25 # - LIBSSO_SNOW3G_PATH
26 # - LIBSSO_KASUMI_PATH
27 # - LIBSSO_ZUC_PATH
28 . $(dirname $(readlink -e $0))/load-devel-config
29
30 print_usage () {
31         echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]"
32 }
33
34 print_help () {
35         echo 'Test building several targets with different options'
36         echo
37         print_usage
38         cat <<- END_OF_HELP
39
40         options:
41                 -h    this help
42                 -jX   use X parallel jobs in "make"
43                 -s    short test only first config without tests|examples|doc
44                 -v    verbose build
45
46         config: defconfig[[~][+]option1[[~][+]option2...]]
47                 Example: x86_64-native-linuxapp-gcc+debug~RXTX_CALLBACKS
48                 The lowercase options are defined inside $(basename $0).
49                 The uppercase options can be the end of a defconfig option
50                 to enable if prefixed with '+' or to disable if prefixed with '~'.
51                 Default is to automatically enable most of the options.
52                 The external dependencies are setup with DPDK_DEP_* variables.
53                 If no config on command line, DPDK_BUILD_TEST_CONFIGS is used.
54         END_OF_HELP
55 }
56
57 J=$DPDK_MAKE_JOBS
58 short=false
59 unset verbose
60 maxerr=-Wfatal-errors
61 while getopts hj:sv ARG ; do
62         case $ARG in
63                 j ) J=$OPTARG ;;
64                 s ) short=true ;;
65                 v ) verbose='V=1' ;;
66                 h ) print_help ; exit 0 ;;
67                 ? ) print_usage ; exit 1 ;;
68         esac
69 done
70 shift $(($OPTIND - 1))
71 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
72
73 success=false
74 on_exit ()
75 {
76         if $success ; then
77                 [ "$DPDK_NOTIFY" != notify-send ] || \
78                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
79         elif [ -z "$signal" ] ; then
80                 [ -z "$dir" ] || echo "failed to build $dir" >&2
81                 [ "$DPDK_NOTIFY" != notify-send ] || \
82                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
83         fi
84 }
85 # catch manual interrupt to ignore notification
86 trap "signal=INT ; trap - INT ; kill -INT $$" INT
87 # notify result on exit
88 trap on_exit EXIT
89
90 cd $(dirname $(readlink -m $0))/..
91
92 reset_env ()
93 {
94         export PATH=$default_path
95         unset CROSS
96         unset DPDK_DEP_ARCHIVE
97         unset DPDK_DEP_CFLAGS
98         unset DPDK_DEP_ISAL
99         unset DPDK_DEP_LDFLAGS
100         unset DPDK_DEP_MLX
101         unset DPDK_DEP_NUMA
102         unset DPDK_DEP_PCAP
103         unset DPDK_DEP_SSL
104         unset DPDK_DEP_IPSEC_MB
105         unset DPDK_DEP_SZE
106         unset DPDK_DEP_ZLIB
107         unset ARMV8_CRYPTO_LIB_PATH
108         unset FLEXRAN_SDK
109         unset LIBMUSDK_PATH
110         unset LIBSSO_SNOW3G_PATH
111         unset LIBSSO_KASUMI_PATH
112         unset LIBSSO_ZUC_PATH
113         unset PQOS_INSTALL_PATH
114 }
115
116 config () # <directory> <target> <options>
117 {
118         reconfig=false
119         if git rev-parse 2>&- && [ -n "$(git diff HEAD~ -- config)" ] ; then
120                 echo 'Default config may have changed'
121                 reconfig=true
122         fi
123         if [ ! -e $1/.config ] || $reconfig ; then
124                 echo "================== Configure $1"
125                 make T=$2 O=$1 config
126
127                 echo 'Customize configuration'
128                 # Built-in options (lowercase)
129                 ! echo $3 | grep -q '+default' || \
130                 sed -ri 's,(RTE_MACHINE=")native,\1default,' $1/.config
131                 echo $3 | grep -q '+next' || \
132                 sed -ri           's,(NEXT_ABI=)y,\1n,' $1/.config
133                 ! echo $3 | grep -q '+shared' || \
134                 sed -ri         's,(SHARED_LIB=)n,\1y,' $1/.config
135                 ! echo $3 | grep -q '+debug' || ( \
136                 sed -ri  's,(RTE_LOG_DP_LEVEL=).*,\1RTE_LOG_DEBUG,' $1/.config
137                 sed -ri           's,(_DEBUG.*=)n,\1y,' $1/.config
138                 sed -ri            's,(_STAT.*=)n,\1y,' $1/.config
139                 sed -ri 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config )
140
141                 # Automatic configuration
142                 test "$DPDK_DEP_NUMA" != n || \
143                 sed -ri             's,(NUMA.*=)y,\1n,' $1/.config
144                 sed -ri    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
145                 sed -ri             's,(BYPASS=)n,\1y,' $1/.config
146                 test "$DPDK_DEP_ARCHIVE" != y || \
147                 sed -ri       's,(RESOURCE_TAR=)n,\1y,' $1/.config
148                 test "$DPDK_DEP_ISAL" != y || \
149                 sed -ri           's,(ISAL_PMD=)n,\1y,' $1/.config
150                 test "$DPDK_DEP_MLX" != y || \
151                 sed -ri           's,(MLX._PMD=)n,\1y,' $1/.config
152                 test "$DPDK_DEP_SZE" != y || \
153                 sed -ri       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
154                 test "$DPDK_DEP_ZLIB" != y || \
155                 sed -ri          's,(BNX2X_PMD=)n,\1y,' $1/.config
156                 sed -ri            's,(NFP_PMD=)n,\1y,' $1/.config
157                 test "$DPDK_DEP_PCAP" != y || \
158                 sed -ri               's,(PCAP=)n,\1y,' $1/.config
159                 test -z "$ARMV8_CRYPTO_LIB_PATH" || \
160                 sed -ri   's,(PMD_ARMV8_CRYPTO=)n,\1y,' $1/.config
161                 test "$DPDK_DEP_IPSEC_MB" != y || \
162                 sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
163                 test "$DPDK_DEP_IPSEC_MB" != y || \
164                 sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
165                 test -z "$LIBSSO_SNOW3G_PATH" || \
166                 sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
167                 test -z "$LIBSSO_KASUMI_PATH" || \
168                 sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
169                 test -z "$LIBSSO_ZUC_PATH" || \
170                 sed -ri            's,(PMD_ZUC=)n,\1y,' $1/.config
171                 test "$DPDK_DEP_SSL" != y || \
172                 sed -ri            's,(PMD_CCP=)n,\1y,' $1/.config
173                 test "$DPDK_DEP_SSL" != y || \
174                 sed -ri        's,(PMD_OPENSSL=)n,\1y,' $1/.config
175                 test "$DPDK_DEP_SSL" != y || \
176                 sed -ri            's,(PMD_QAT=)n,\1y,' $1/.config
177                 test -z "$FLEXRAN_SDK" || \
178                 sed -ri     's,(BBDEV_TURBO_SW=)n,\1y,' $1/.config
179                 sed -ri           's,(SCHED_.*=)n,\1y,' $1/.config
180                 test -z "$LIBMUSDK_PATH" || \
181                 sed -ri    's,(PMD_MVSAM_CRYPTO=)n,\1y,' $1/.config
182                 test -z "$LIBMUSDK_PATH" || \
183                 sed -ri          's,(MVPP2_PMD=)n,\1y,' $1/.config
184                 build_config_hook $1 $2 $3
185
186                 # Explicit enabler/disabler (uppercase)
187                 for option in $(echo $3 | sed 's,[~+], &,g') ; do
188                         pattern=$(echo $option | cut -c2-)
189                         if echo $option | grep -q '^~' ; then
190                                 sed -ri "s,($pattern=)y,\1n," $1/.config
191                         elif echo $option | grep -q '^+' ; then
192                                 sed -ri "s,($pattern=)n,\1y," $1/.config
193                         fi
194                 done
195         fi
196 }
197
198 # default empty hook to override in devel config
199 build_config_hook () # <directory> <target> <options>
200 {
201         :
202 }
203
204 for conf in $configs ; do
205         target=$(echo $conf | sed 's,[~+].*,,')
206         # reload config with DPDK_TARGET set
207         DPDK_TARGET=$target
208         reset_env
209         . $(dirname $(readlink -e $0))/load-devel-config
210
211         options=$(echo $conf | sed 's,[^~+]*,,')
212         dir=$conf
213         config $dir $target $options
214
215         echo "================== Build $dir"
216         make -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
217                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
218         ! $short || break
219         echo "================== Build tests for $dir"
220         make test-build -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
221                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
222         echo "================== Build examples for $dir"
223         export RTE_SDK=$(pwd)
224         export RTE_TARGET=$dir
225         make -j$J -sC examples \
226                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
227                 O=$(readlink -m $dir/examples)
228         unset RTE_TARGET
229         echo "################## $dir done."
230         unset dir
231 done
232
233 if ! $short ; then
234         mkdir -p .check
235         echo "================== Build doxygen HTML API"
236         make doc-api-html >/dev/null 2>.check/doc.txt
237         echo "================== Build sphinx HTML guides"
238         make doc-guides-html >/dev/null 2>>.check/doc.txt
239         echo "================== Check docs"
240         diff -u /dev/null .check/doc.txt
241 fi
242
243 success=true